BookStack/app/Http/Controllers/Auth/ResetPasswordController.php

78 lines
2.2 KiB
PHP
Raw Normal View History

2015-07-12 15:01:42 -04:00
<?php
namespace BookStack\Http\Controllers\Auth;
2015-07-12 15:01:42 -04:00
use BookStack\Actions\ActivityType;
use BookStack\Http\Controllers\Controller;
2015-07-12 15:01:42 -04:00
use Illuminate\Foundation\Auth\ResetsPasswords;
2019-09-06 18:36:16 -04:00
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Password;
2015-07-12 15:01:42 -04:00
class ResetPasswordController extends Controller
2015-07-12 15:01:42 -04:00
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset requests
| and uses a simple trait to include this behavior. You're free to
| explore this trait and override any methods you wish to tweak.
|
*/
use ResetsPasswords;
2016-11-12 06:40:54 -05:00
protected $redirectTo = '/';
2015-07-12 15:01:42 -04:00
/**
* Create a new controller instance.
*
* @return void
2015-07-12 15:01:42 -04:00
*/
public function __construct()
{
$this->middleware('guest');
$this->middleware('guard:standard');
2015-07-12 15:01:42 -04:00
}
2016-11-12 06:40:54 -05:00
/**
* Get the response for a successful password reset.
*
2019-09-06 18:36:16 -04:00
* @param Request $request
2021-06-26 11:23:15 -04:00
* @param string $response
*
2016-11-12 06:40:54 -05:00
* @return \Illuminate\Http\Response
*/
2019-09-06 18:36:16 -04:00
protected function sendResetResponse(Request $request, $response)
2016-11-12 06:40:54 -05:00
{
2016-12-04 11:51:39 -05:00
$message = trans('auth.reset_password_success');
$this->showSuccessNotification($message);
$this->logActivity(ActivityType::AUTH_PASSWORD_RESET_UPDATE, user());
2021-06-26 11:23:15 -04:00
2016-11-12 06:40:54 -05:00
return redirect($this->redirectPath())
->with('status', trans($response));
}
/**
* Get the response for a failed password reset.
*
2021-06-26 11:23:15 -04:00
* @param \Illuminate\Http\Request $request
* @param string $response
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
*/
protected function sendResetFailedResponse(Request $request, $response)
{
// We show invalid users as invalid tokens as to not leak what
// users may exist in the system.
if ($response === Password::INVALID_USER) {
$response = Password::INVALID_TOKEN;
}
return redirect()->back()
->withInput($request->only('email'))
->withErrors(['email' => trans($response)]);
}
}