Password reset views.

This commit is contained in:
Graphictoria 2022-05-02 22:59:29 -04:00
parent 6f0a7e790a
commit 0fed56e37a
3 changed files with 76 additions and 82 deletions

View File

@ -35,7 +35,6 @@ class NewPasswordController extends Controller
{ {
$request->validate([ $request->validate([
'token' => ['required'], 'token' => ['required'],
'email' => ['required', 'email'],
'password' => ['required', 'confirmed', Rules\Password::defaults()], 'password' => ['required', 'confirmed', Rules\Password::defaults()],
]); ]);
@ -43,7 +42,7 @@ class NewPasswordController extends Controller
// will update the password on an actual user model and persist it to the // will update the password on an actual user model and persist it to the
// database. Otherwise we will parse the error and return the response. // database. Otherwise we will parse the error and return the response.
$status = Password::reset( $status = Password::reset(
$request->only('email', 'password', 'password_confirmation', 'token'), $request->only('password', 'password_confirmation', 'token'),
function ($user) use ($request) { function ($user) use ($request) {
$user->forceFill([ $user->forceFill([
'password' => Hash::make($request->password), 'password' => Hash::make($request->password),
@ -59,7 +58,6 @@ class NewPasswordController extends Controller
// redirect them back to where they came from with their error message. // redirect them back to where they came from with their error message.
return $status == Password::PASSWORD_RESET return $status == Password::PASSWORD_RESET
? redirect()->route('login')->with('status', __($status)) ? redirect()->route('login')->with('status', __($status))
: back()->withInput($request->only('email')) : back()->withErrors(['status' => __($status)]);
->withErrors(['email' => __($status)]);
} }
} }

View File

@ -1,36 +1,41 @@
<x-guest-layout> @php
<x-auth-card> $fields = [
<x-slot name="logo"> 'email' => 'Email Address'
<a href="/"> ];
<x-application-logo class="w-20 h-20 fill-current text-gray-500" /> @endphp
</a>
</x-slot>
<div class="mb-4 text-sm text-gray-600"> @extends('layouts.app')
{{ __('Forgot your password? No problem. Just let us know your email address and we will email you a password reset link that will allow you to choose a new one.') }}
</div>
<!-- Session Status --> @section('title', 'Forgot Password')
<x-auth-session-status class="mb-4" :status="session('status')" />
<!-- Validation Errors --> @section('content')
<x-auth-validation-errors class="mb-4" :errors="$errors" /> <div class="container graphictoria-center-vh">
<x-card>
<form method="POST" action="{{ route('password.email') }}"> <x-slot name="title">
@csrf <i class="fa-solid fa-magnifying-glass"></i> FORGOT PASSWORD
</x-slot>
<!-- Email Address --> <x-slot name="body">
<div> <div class="p-2 mb-2 d-flex flex-column justify-content-center">
<x-label for="email" :value="__('Email')" /> @if ($errors->any())
<div class="px-3 mb-10">
<x-input id="email" class="block mt-1 w-full" type="email" name="email" :value="old('email')" required autofocus /> <div class="alert alert-danger graphictoria-alert graphictoria-error-popup">{{ $errors->first() }}</div>
</div> </div>
@endif
<div class="flex items-center justify-end mt-4">
<x-button> <h5 class="m-0">Forgot your password? No problem!</h5>
{{ __('Email Password Reset Link') }} <p class="mb-3">Enter the email address associated with your account and we'll send you a reset link.</p>
</x-button>
</div> <form method="POST" action="{{ route('password.email') }}">
</form> @csrf
</x-auth-card> @foreach($fields as $field => $label)
</x-guest-layout> <input type="{{ $field }}" @class(['form-control', 'mb-2', 'is-invalid'=>($errors->first($field) != null)]) placeholder="{{ $label }}" name="{{ $field }}" :value="old($field)" />
@endforeach
<a href="{{ route('login') }}" class="btn btn-secondary px-5" ><i class="fa-solid fa-angles-left"></i> Back</a>&nbsp;
<button class="btn btn-primary px-5" type="submit">Send Reset Link</button>
</form>
</div>
</x-slot>
<x-slot name="footer"></x-slot>
</x-card>
</div>
@endsection

View File

@ -1,48 +1,39 @@
<x-guest-layout> @php
<x-auth-card> $fields = [
<x-slot name="logo"> 'password' => 'New Password',
<a href="/"> 'password_confirmation' => 'Confirm New Password'
<x-application-logo class="w-20 h-20 fill-current text-gray-500" /> ];
</a> @endphp
</x-slot>
<!-- Validation Errors --> @extends('layouts.app')
<x-auth-validation-errors class="mb-4" :errors="$errors" />
<form method="POST" action="{{ route('password.update') }}"> @section('title', 'Reset Password')
@csrf
<!-- Password Reset Token --> @section('content')
<input type="hidden" name="token" value="{{ $request->route('token') }}"> <div class="container graphictoria-center-vh">
<x-card>
<!-- Email Address --> <x-slot name="title">
<div> <i class="fa-solid fa-magnifying-glass"></i> RESET PASSWORD
<x-label for="email" :value="__('Email')" /> </x-slot>
<x-slot name="body">
<x-input id="email" class="block mt-1 w-full" type="email" name="email" :value="old('email', $request->email)" required autofocus /> <div class="p-2 mb-2 d-flex flex-column justify-content-center">
</div> @if ($errors->any())
<div class="px-3 mb-10">
<!-- Password --> <div class="alert alert-danger graphictoria-alert graphictoria-error-popup">{{ $errors->first() }}</div>
<div class="mt-4"> </div>
<x-label for="password" :value="__('Password')" /> @endif
<x-input id="password" class="block mt-1 w-full" type="password" name="password" required /> <form method="POST" action="{{ route('password.update') }}">
</div> @csrf
<input type="hidden" name="token" value="{{ $request->route('token') }}" />
<!-- Confirm Password --> @foreach($fields as $field => $label)
<div class="mt-4"> <input type="{{ $field == 'password_confirmation' ? 'password' : $field }}" @class(['form-control', 'mb-2', 'is-invalid'=>($errors->first($field) != null)]) placeholder="{{ $label }}" name="{{ $field }}" :value="old($field)" />
<x-label for="password_confirmation" :value="__('Confirm Password')" /> @endforeach
<button class="btn btn-primary px-5" type="submit">Change Password</button>
<x-input id="password_confirmation" class="block mt-1 w-full" </form>
type="password" </div>
name="password_confirmation" required /> </x-slot>
</div> <x-slot name="footer"></x-slot>
</x-card>
<div class="flex items-center justify-end mt-4"> </div>
<x-button> @endsection
{{ __('Reset Password') }}
</x-button>
</div>
</form>
</x-auth-card>
</x-guest-layout>