Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
floodControl example
if
(
!
isset
(
$credentials
[
'name'
]
)
&& !
isset
(
$credentials
[
'pass'
]
)
)
{
throw
new
BadRequestHttpException
(
'Missing credentials.'
)
;
}
if
(
!
isset
(
$credentials
[
'name'
]
)
)
{
throw
new
BadRequestHttpException
(
'Missing credentials.name.'
)
;
}
if
(
!
isset
(
$credentials
[
'pass'
]
)
)
{
throw
new
BadRequestHttpException
(
'Missing credentials.pass.'
)
;
}
$this
->
floodControl
(
$request
,
$credentials
[
'name'
]
)
;
if
(
$this
->
userIsBlocked
(
$credentials
[
'name'
]
)
)
{
throw
new
BadRequestHttpException
(
'The user has not been activated or is blocked.'
)
;
}
if
(
$uid
=
$this
->userAuth->
authenticate
(
$credentials
[
'name'
]
,
$credentials
[
'pass'
]
)
)
{
$this
->userFloodControl->
clear
(
'user.http_login',
$this
->
getLoginFloodIdentifier
(
$request
,
$credentials
[
'name'
]
)
)
;
/** @var \Drupal\user\UserInterface $user */
$user
=
$this
->userStorage->
load
(
$uid
)
;
$this
->
userLoginFinalize
(
$user
)
;