Skip to content

Commit e00007f

Browse files
committed
minor #10448 Fixed the logic of the custom password authenticator (javiereguiluz)
This PR was merged into the 3.4 branch. Discussion ---------- Fixed the logic of the custom password authenticator This finishes #10146. Commits ------- 2b1e5b5 Fixed the logic of the custom password authenticator
2 parents 6a5a17a + 2b1e5b5 commit e00007f

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

security/custom_password_authenticator.rst

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -68,29 +68,23 @@ the user::
6868
}
6969
}
7070

71-
if ($isPasswordValid) {
72-
$currentHour = date('G');
73-
if ($currentHour < 14 || $currentHour > 16) {
74-
// CAUTION: this message will be returned to the client
75-
// (so don't put any un-trusted messages / error strings here)
76-
throw new CustomUserMessageAuthenticationException(
77-
'You can only log in between 2 and 4!',
78-
array(), // Message Data
79-
412 // HTTP 412 Precondition Failed
80-
);
81-
}
82-
83-
return new UsernamePasswordToken(
84-
$user,
85-
$user->getPassword(),
86-
$providerKey,
87-
$user->getRoles()
71+
$currentHour = date('G');
72+
if ($currentHour < 14 || $currentHour > 16) {
73+
// CAUTION: this message will be returned to the client
74+
// (so don't put any un-trusted messages / error strings here)
75+
throw new CustomUserMessageAuthenticationException(
76+
'You can only log in between 2 and 4!',
77+
array(), // Message Data
78+
412 // HTTP 412 Precondition Failed
8879
);
8980
}
9081

91-
// CAUTION: this message will be returned to the client
92-
// (so don't put any un-trusted messages / error strings here)
93-
throw new CustomUserMessageAuthenticationException('Invalid username or password');
82+
return new UsernamePasswordToken(
83+
$user,
84+
$user->getPassword(),
85+
$providerKey,
86+
$user->getRoles()
87+
);
9488
}
9589

9690
public function supportsToken(TokenInterface $token, $providerKey)

0 commit comments

Comments
 (0)