|
|
|
|
@ -4,12 +4,14 @@ namespace App\Http\Controllers\Auth;
|
|
|
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
|
use App\Services\BouncerService;
|
|
|
|
|
use Illuminate\Auth\Events\PasswordReset;
|
|
|
|
|
use Illuminate\Contracts\View\Factory;
|
|
|
|
|
use Illuminate\Foundation\Auth\ResetsPasswords;
|
|
|
|
|
use Illuminate\Http\JsonResponse;
|
|
|
|
|
use Illuminate\Http\RedirectResponse;
|
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
use Illuminate\Support\Facades\Password;
|
|
|
|
|
use Illuminate\Support\Str;
|
|
|
|
|
use Illuminate\Validation\Rules;
|
|
|
|
|
use Illuminate\Validation\ValidationException;
|
|
|
|
|
use Illuminate\View\View;
|
|
|
|
|
@ -116,7 +118,8 @@ class ResetPasswordController 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.
|
|
|
|
|
$response = $this->broker()->reset(
|
|
|
|
|
$this->credentials($request), function ($user, $password) {
|
|
|
|
|
$this->credentials($request),
|
|
|
|
|
function ($user, $password) {
|
|
|
|
|
$this->resetPassword($user, $password);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
@ -125,8 +128,8 @@ class ResetPasswordController extends Controller
|
|
|
|
|
// 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);
|
|
|
|
|
? $this->sendResetResponse($request, $response)
|
|
|
|
|
: $this->sendResetFailedResponse($request, $response);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -137,7 +140,10 @@ class ResetPasswordController extends Controller
|
|
|
|
|
protected function credentials(Request $request)
|
|
|
|
|
{
|
|
|
|
|
return $request->only(
|
|
|
|
|
'email', 'password', 'password_confirmation', 'token'
|
|
|
|
|
'email',
|
|
|
|
|
'password',
|
|
|
|
|
'password_confirmation',
|
|
|
|
|
'token'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -157,4 +163,18 @@ class ResetPasswordController extends Controller
|
|
|
|
|
->withInput($request->only('email'))
|
|
|
|
|
->withErrors(['email' => [trans($response)]]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function resetPassword($user, $password): void
|
|
|
|
|
{
|
|
|
|
|
$this->setUserPassword($user, $password);
|
|
|
|
|
$user->setRememberToken(Str::random(60));
|
|
|
|
|
$user->save();
|
|
|
|
|
|
|
|
|
|
event(new PasswordReset($user));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function sendResetResponse(Request $request, $response): RedirectResponse
|
|
|
|
|
{
|
|
|
|
|
return redirect()->route('login')->with('status', trans($response));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|