todo/app/Http/Controllers/Auth/ConfirmablePasswordControll...

43 lines
1.0 KiB
PHP
Raw Permalink Normal View History

2024-05-02 10:06:39 +03:00
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Validation\ValidationException;
use Illuminate\View\View;
class ConfirmablePasswordController extends Controller
{
/**
* Show the confirm password view.
*/
public function show(): View
{
return view('auth.confirm-password');
}
/**
* Confirm the user's password.
*/
public function store(Request $request): RedirectResponse
{
2024-05-02 17:02:46 +03:00
if (
! Auth::guard('web')->validate([
2024-05-02 10:06:39 +03:00
'email' => $request->user()->email,
'password' => $request->password,
2024-05-02 17:02:46 +03:00
])
) {
2024-05-02 10:06:39 +03:00
throw ValidationException::withMessages([
'password' => __('auth.password'),
]);
}
$request->session()->put('auth.password_confirmed_at', time());
return redirect()->intended(route('dashboard', absolute: false));
}
}