From 8db6764c94b2212c340b64bef4c32177f3a440ac Mon Sep 17 00:00:00 2001 From: Spitfire Date: Fri, 26 Apr 2024 16:57:40 -0600 Subject: [PATCH 1/2] Login form optional password --- app/Http/Controllers/Auth/LoginController.php | 13 +++ resources/views/auth/login.blade.php | 81 ++++++++++--------- routes/auth.php | 1 + 3 files changed, 58 insertions(+), 37 deletions(-) diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 35e2e9da16..c64551346a 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -50,6 +50,19 @@ public function loginAsUser(Request $request, User $user) return redirect()->route('login'); } + /** + * @return \Illuminate\Http\RedirectResponse + */ + public function loginAs(Request $request) + { + if (config('auth.user_list')) { + $user = User::where('id', $request->get('user'))->first(); + Auth::login($user, true); + return $this->sendLoginResponse($request); + } + return redirect()->route('login'); + } + protected function authenticated(Request $request, $user) { $response = $this->userAuthService->authenticated($user); diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php index afb1ab1b76..1d40f80848 100644 --- a/resources/views/auth/login.blade.php +++ b/resources/views/auth/login.blade.php @@ -21,51 +21,58 @@ @endforeach - @endif -
- {{ csrf_field() }} -
- @if(config('auth.user_list')) - - @else - - @endif + + {{ csrf_field() }} + @if(config('auth.user_list')) + + @endif - @if ($errors->has('email')) - - {{ $errors->first('email') }} - - @endif -
+ +
+ @else +
+ {{ csrf_field() }} +
+ -
-
- - - - {{ __('auth.helpers.password') }} - + @if ($errors->has('email')) + + {{ $errors->first('email') }} + + @endif
- @if ($errors->has('password')) - - {{ $errors->first('password') }} - - @endif -
+
+ - + @if ($errors->has('password')) + + {{ $errors->first('password') }} + + @endif +
+ + - - + + + @endif @if(config('auth.register_enabled'))