From 0b6e9b5acee23bd2a7b69e845272a4ef7ecf86d2 Mon Sep 17 00:00:00 2001 From: Julian Prieber <60265788+JulianPrieber@users.noreply.github.com> Date: Mon, 18 Dec 2023 15:29:24 +0100 Subject: [PATCH] Added Page URL to register page + validation --- .../Auth/RegisteredUserController.php | 55 ++++++++----------- resources/views/auth/register.blade.php | 20 ++++--- resources/views/auth/url-validation.blade.php | 38 +++++++++++++ 3 files changed, 74 insertions(+), 39 deletions(-) create mode 100644 resources/views/auth/url-validation.blade.php diff --git a/app/Http/Controllers/Auth/RegisteredUserController.php b/app/Http/Controllers/Auth/RegisteredUserController.php index d9f1512..4b0b700 100755 --- a/app/Http/Controllers/Auth/RegisteredUserController.php +++ b/app/Http/Controllers/Auth/RegisteredUserController.php @@ -11,33 +11,36 @@ use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Mail; +use Illuminate\Support\Facades\Validator; class RegisteredUserController extends Controller { - /** - * Display the registration view. - * - * @return \Illuminate\View\View - */ + public function create() { return view('auth.register'); } - /** - * Handle an incoming registration request. - * - * @param \Illuminate\Http\Request $request - * @return \Illuminate\Http\RedirectResponse - * - * @throws \Illuminate\Validation\ValidationException - */ + public function validateHandle(Request $request) + { + $validator = Validator::make($request->all(), [ + 'littlelink_name' => 'required|string|max:50|unique:users', + ]); + + if ($validator->fails()) { + return response()->json(['valid' => false]); + } + + return response()->json(['valid' => true]); + } + public function store(Request $request) { $request->validate([ 'name' => 'required|string|max:255', + 'littlelink_name' => 'required|string|max:50|unique:users', 'email' => 'required|string|email|max:255|unique:users', - 'password' => 'required|string|confirmed|min:8', + 'password' => 'required|string|min:8', ]); $name = $request->input('name'); @@ -48,23 +51,13 @@ class RegisteredUserController extends Controller $block = 'no'; } - if(DB::table('users')->where('littlelink_name', $request->name)->exists()) - { - Auth::login($user = User::create([ - 'name' => $request->name, - 'email' => $request->email, - 'password' => Hash::make($request->password), - 'role' => 'user', - ])); - } else { - Auth::login($user = User::create([ - 'name' => $request->name, - 'email' => $request->email, - 'littlelink_name' => $request->name, - 'password' => Hash::make($request->password), - 'role' => 'user', - ])); - } + Auth::login($user = User::create([ + 'name' => $request->name, + 'email' => $request->email, + 'littlelink_name' => $request->littlelink_name, + 'password' => Hash::make($request->password), + 'role' => 'user', + ])); $user->block = $block; $user->save(); diff --git a/resources/views/auth/register.blade.php b/resources/views/auth/register.blade.php index 455b0ab..b16612a 100755 --- a/resources/views/auth/register.blade.php +++ b/resources/views/auth/register.blade.php @@ -18,7 +18,7 @@ foreach($pages as $page) -
+ +
+
+ +
+ {{str_replace(['http://', 'https://'], '', url(''))}}/@ + +
+
+
+ @include('auth.url-validation')
@@ -65,12 +75,6 @@ foreach($pages as $page)
-
-
- - -
-
@@ -79,7 +83,7 @@ foreach($pages as $page)
- +
@if(env('ENABLE_SOCIAL_LOGIN') == 'true')

{{__('messages.or sign in with other accounts?')}}

diff --git a/resources/views/auth/url-validation.blade.php b/resources/views/auth/url-validation.blade.php new file mode 100644 index 0000000..708b58b --- /dev/null +++ b/resources/views/auth/url-validation.blade.php @@ -0,0 +1,38 @@ + + \ No newline at end of file