Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
9
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Open sidebar
Gigadrive
qpost
qpost
Commits
e47564eb
Verified
Commit
e47564eb
authored
Aug 25, 2020
by
Mehdi Baaboura
Browse files
Validate all current tokens in TokenService
parent
ea5faee9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
1 deletion
+14
-1
src/Service/TokenService.php
src/Service/TokenService.php
+14
-1
No files found.
src/Service/TokenService.php
View file @
e47564eb
...
...
@@ -31,6 +31,7 @@ use Symfony\Component\HttpFoundation\RequestStack;
use
Symfony\Component\HttpFoundation\Response
;
use
function
array_merge
;
use
function
array_slice
;
use
function
is_null
;
use
function
is_string
;
use
function
json_decode
;
use
function
json_encode
;
...
...
@@ -99,7 +100,19 @@ class TokenService {
public
function
getCookieTokens
(
Request
$request
):
array
{
if
(
!
$request
->
cookies
->
has
(
self
::
TOKEN_COOKIE_IDENTIFIER
))
return
[];
return
json_decode
(
$request
->
cookies
->
get
(
self
::
TOKEN_COOKIE_IDENTIFIER
));
$tokens
=
[];
foreach
(
json_decode
(
$request
->
cookies
->
get
(
self
::
TOKEN_COOKIE_IDENTIFIER
))
as
$token
)
{
if
(
$this
->
validateToken
(
$token
))
{
$tokens
[]
=
$token
;
}
}
return
$tokens
;
}
private
function
validateToken
(
string
$token
):
bool
{
return
!
is_null
(
$this
->
entityManager
->
getRepository
(
Token
::
class
)
->
getTokenById
(
$token
));
}
public
function
addToken
(
string
$token
,
Request
$request
,
Response
$response
):
void
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment