mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-11-28 03:34:32 -06:00
Make password reset impossible for blocked users.
This commit is contained in:
parent
a96e171cbf
commit
d4e759754d
@ -2,7 +2,12 @@
|
||||
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Mail\Message;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Password;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
/**
|
||||
* Class PasswordController
|
||||
*
|
||||
@ -41,4 +46,35 @@ class PasswordController extends Controller
|
||||
$this->middleware('guest');
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a reset link to the given user.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function postEmail(Request $request)
|
||||
{
|
||||
$this->validate($request, ['email' => 'required|email']);
|
||||
|
||||
$user = User::whereEmail($request->get('email'))->first();
|
||||
|
||||
if (!is_null($user) && intval($user->blocked) === 1) {
|
||||
$response = 'passwords.blocked';
|
||||
} else {
|
||||
$response = Password::sendResetLink($request->only('email'), function (Message $message) {
|
||||
$message->subject($this->getEmailSubject());
|
||||
});
|
||||
}
|
||||
|
||||
switch ($response) {
|
||||
case Password::RESET_LINK_SENT:
|
||||
return redirect()->back()->with('status', trans($response));
|
||||
|
||||
case Password::INVALID_USER:
|
||||
case 'passwords.blocked':
|
||||
return redirect()->back()->withErrors(['email' => trans($response)]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,5 +17,6 @@ return [
|
||||
"token" => "This password reset token is invalid.",
|
||||
"sent" => "We have e-mailed your password reset link!",
|
||||
"reset" => "Your password has been reset!",
|
||||
'blocked' => 'Nice try though.'
|
||||
|
||||
];
|
||||
|
@ -17,5 +17,6 @@ return [
|
||||
"token" => "Ongeldig token! Sorry",
|
||||
"sent" => "Je krijgt een mailtje met een linkje om je wachtwoord te herstellen!",
|
||||
"reset" => "Je wachtwoord is hersteld!",
|
||||
'blocked' => 'Leuk geprobeerd wel.'
|
||||
|
||||
];
|
||||
|
Loading…
Reference in New Issue
Block a user