Skip to content

Commit

Permalink
confirmed password status controller
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Sep 14, 2020
1 parent 661555a commit fe5821f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
4 changes: 4 additions & 0 deletions routes/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@
Route::post('/user/confirm-password', 'ConfirmablePasswordController@store')
->middleware(['auth']);

Route::get('/user/confirmed-password-status', 'ConfirmedPasswordStatusController@show')
->middleware(['auth'])
->name('password.confirmation');

// Two Factor Authentication...
if (Features::enabled(Features::twoFactorAuthentication())) {
Route::post('/user/two-factor-authentication', 'TwoFactorAuthenticationController@store')
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Controllers/ConfirmablePasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct(StatefulGuard $guard)
* Show the confirm password view.
*
* @param \Illuminate\Http\Request $request
* @return \Laravel\Fortify\Contracts\VerifyPasswordViewResponse
* @return \Laravel\Fortify\Contracts\ConfirmPasswordViewResponse
*/
public function show(Request $request)
{
Expand Down
22 changes: 22 additions & 0 deletions src/Http/Controllers/ConfirmedPasswordStatusController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace Laravel\Fortify\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Routing\Controller;

class ConfirmedPasswordStatusController extends Controller
{
/**
* Get the password confirmation status.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function show(Request $request)
{
return response()->json([
'confirmed' => (time() - $request->session()->get('auth.password_confirmed_at', 0)) < $request->input('seconds', 900),
]);
}
}

0 comments on commit fe5821f

Please sign in to comment.