2018-10-04 19:10:43 +02:00
|
|
|
<?php
|
2019-05-11 05:32:07 +02:00
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
2019-05-11 05:32:07 +02:00
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2020-01-07 01:13:47 +01:00
|
|
|
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
2019-05-11 05:32:07 +02:00
|
|
|
*
|
|
|
|
* @license https://opensource.org/licenses/AAL
|
|
|
|
*/
|
2018-10-04 19:10:43 +02:00
|
|
|
|
|
|
|
namespace App\Http\Controllers\Auth;
|
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
use Illuminate\Foundation\Auth\ResetsPasswords;
|
2020-03-13 22:17:08 +01:00
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use Illuminate\Support\Facades\Password;
|
2018-10-04 19:10:43 +02:00
|
|
|
|
|
|
|
class ResetPasswordController extends Controller
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
| 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;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Where to redirect users after resetting their password.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2020-03-13 22:17:08 +01:00
|
|
|
protected $redirectTo = '/';
|
2018-10-04 19:10:43 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new controller instance.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$this->middleware('guest');
|
|
|
|
}
|
2020-03-13 22:17:08 +01:00
|
|
|
|
|
|
|
public function showResetForm(Request $request, $token = null)
|
|
|
|
{
|
|
|
|
return $this->render('auth.passwords.reset', ['root' => 'themes', 'token' => $token]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reset the given user's password.
|
|
|
|
*
|
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
|
|
|
|
*/
|
|
|
|
public function reset(Request $request)
|
|
|
|
{
|
|
|
|
$request->validate($this->rules(), $this->validationErrorMessages());
|
|
|
|
|
|
|
|
// Here we will attempt to reset the user's password. If it is successful we
|
|
|
|
// 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.
|
|
|
|
$response = $this->broker()->reset(
|
2020-03-21 06:37:30 +01:00
|
|
|
$this->credentials($request),
|
|
|
|
function ($user, $password) {
|
|
|
|
$this->resetPassword($user, $password);
|
|
|
|
}
|
2020-03-13 22:17:08 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
// Added this because it collides the session between
|
|
|
|
// client & main portal giving unlimited redirects.
|
|
|
|
auth()->logout();
|
|
|
|
|
|
|
|
// If the password was successfully reset, we will redirect the user back to
|
|
|
|
// the application's home authenticated view. If there is an error we can
|
|
|
|
// redirect them back to where they came from with their error message.
|
|
|
|
return $response == Password::PASSWORD_RESET
|
|
|
|
? $this->sendResetResponse($request, $response)
|
|
|
|
: $this->sendResetFailedResponse($request, $response);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function afterReset()
|
|
|
|
{
|
|
|
|
auth()->logout();
|
|
|
|
|
|
|
|
return redirect('/');
|
|
|
|
}
|
2018-10-04 19:10:43 +02:00
|
|
|
}
|