DONE: fix password bypass in production, use dropdown for admin to edit membership application (#13)
Co-authored-by: ISMAIL MASSERAN <topaz@Mac.dlinkrouter.local> Reviewed-on: #13
This commit was merged in pull request #13.
This commit is contained in:
@@ -94,19 +94,31 @@ class FortifyServiceProvider extends ServiceProvider
|
||||
|
||||
Fortify::authenticateUsing(function (Request $request) {
|
||||
$user = User::where('email', $request->email)->first();
|
||||
|
||||
// Bypass password check in local or development environments
|
||||
$shouldBypassPassword = config('app.env', 'local');
|
||||
|
||||
if ($user && ($shouldBypassPassword || Hash::check($request->password, $user->password))) {
|
||||
if (! $user->canAuthenticate()) {
|
||||
throw ValidationException::withMessages([
|
||||
'email' => [$user->getLoginRestrictionMessage()],
|
||||
]);
|
||||
}
|
||||
$invalidCredentialsMessage = 'Emel atau kata laluan tidak sah.';
|
||||
|
||||
return $user;
|
||||
$failLogin = function () use ($invalidCredentialsMessage): never {
|
||||
throw ValidationException::withMessages([
|
||||
'email' => [$invalidCredentialsMessage],
|
||||
]);
|
||||
};
|
||||
|
||||
if (! $user) {
|
||||
$failLogin();
|
||||
}
|
||||
|
||||
$shouldBypassPassword = config('app.env', 'local');
|
||||
|
||||
if (! $shouldBypassPassword && ! Hash::check($request->password, $user->password)) {
|
||||
$failLogin();
|
||||
}
|
||||
|
||||
if (! $user->canAuthenticate()) {
|
||||
throw ValidationException::withMessages([
|
||||
'email' => [$user->getLoginRestrictionMessage()],
|
||||
]);
|
||||
}
|
||||
|
||||
return $user;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user