Skip to content

Commit 60eaca3

Browse files
committed
Merge branch '3.4' into 4.1
* 3.4: fix the command output Fixed the logic of the custom password authenticator
2 parents 5ed501f + a945671 commit 60eaca3

File tree

2 files changed

+24
-30
lines changed

2 files changed

+24
-30
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)

service_container.rst

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,16 @@ What other services are available? Find out by running:
5050
$ php bin/console debug:autowiring
5151
5252
# this is just a *small* sample of the output...
53-
=============================================================== =====================================
54-
Class/Interface Type Alias Service ID
55-
=============================================================== =====================================
56-
``Psr\Cache\CacheItemPoolInterface`` alias for "cache.app.recorder"
57-
``Psr\Log\LoggerInterface`` alias for "monolog.logger"
58-
``Symfony\Component\EventDispatcher\EventDispatcherInterface`` alias for "debug.event_dispatcher"
59-
``Symfony\Component\HttpFoundation\RequestStack`` alias for "request_stack"
60-
``Symfony\Component\HttpFoundation\Session\SessionInterface`` alias for "session"
61-
``Symfony\Component\Routing\RouterInterface`` alias for "router.default"
62-
=============================================================== =====================================
53+
========================================================== ==================================
54+
Class/Interface Type Alias Service ID
55+
========================================================== ==================================
56+
Psr\Cache\CacheItemPoolInterface alias for "cache.app.recorder"
57+
Psr\Log\LoggerInterface alias for "monolog.logger"
58+
Symfony\Component\EventDispatcher\EventDispatcherInterface alias for "debug.event_dispatcher"
59+
Symfony\Component\HttpFoundation\RequestStack alias for "request_stack"
60+
Symfony\Component\HttpFoundation\Session\SessionInterface alias for "session"
61+
Symfony\Component\Routing\RouterInterface alias for "router.default"
62+
========================================================== ==================================
6363
6464
When you use these type-hints in your controller methods or inside your
6565
:ref:`own services <service-container-creating-service>`, Symfony will automatically

0 commit comments

Comments
 (0)