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([
'token' => ['required'],
'email' => ['required', 'email'],
'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
// database. Otherwise we will parse the error and return the response.
$status = Password::reset(
$request->only('email', 'password', 'password_confirmation', 'token'),
$request->only('password', 'password_confirmation', 'token'),
function ($user) use ($request) {
$user->forceFill([
'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.
return $status == Password::PASSWORD_RESET
? redirect()->route('login')->with('status', __($status))
: back()->withInput($request->only('email'))
->withErrors(['email' => __($status)]);
: back()->withErrors(['status' => __($status)]);
}
}

View File

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

View File

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