Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
CookieTheftException example
[
$series
,
$tokenValue
]
=
explode
(
':',
$rememberMeDetails
->
getValue
(
)
)
;
$persistentToken
=
$this
->tokenProvider->
loadTokenBySeries
(
$series
)
;
if
(
$this
->tokenVerifier
)
{
$isTokenValid
=
$this
->tokenVerifier->
verifyToken
(
$persistentToken
,
$tokenValue
)
;
}
else
{
$isTokenValid
=
hash_equals
(
$persistentToken
->
getTokenValue
(
)
,
$tokenValue
)
;
}
if
(
!
$isTokenValid
)
{
throw
new
CookieTheftException
(
'This token was already used. The account is possibly compromised.'
)
;
}
if
(
$persistentToken
->
getLastUsed
(
)
->
getTimestamp
(
)
+
$this
->options
[
'lifetime'
]
<
time
(
)
)
{
throw
new
AuthenticationException
(
'The cookie has expired.'
)
;
}
return
parent::
consumeRememberMeCookie
(
$rememberMeDetails
->
withValue
(
$persistentToken
->
getLastUsed
(
)
->
getTimestamp
(
)
.':'.
$rememberMeDetails
->
getValue
(
)
.':'.
$persistentToken
->
getClass
(
)
)
)
;
}
public
function
processRememberMe
(
RememberMeDetails
$rememberMeDetails
, UserInterface
$user
)
: void
{
[