Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
BearerTokenValidator example
$userRepository
=
$this
->
getContainer
(
)
->
get
(
'user.repository'
)
;
// Change user password
$userRepository
->
update
(
[
[
'id' =>
$admin
->
getUserId
(
)
,
'password' => Uuid::
randomHex
(
)
,
]
]
, Context::
createDefaultContext
(
)
)
;
$mockDecoratedValidator
=
$this
->
getMockBuilder
(
AuthorizationValidatorInterface::
class
)
->
disableOriginalConstructor
(
)
->
getMock
(
)
;
$mockDecoratedValidator
->
method
(
'validateAuthorization'
)
->
willReturn
(
$request
)
;
$bearerTokenValidator
=
new
BearerTokenValidator
(
$mockDecoratedValidator
,
$connection
,
$this
->
getContainer
(
)
->
get
(
'shopware.jwt_config'
)
)
;
$bearerTokenValidator
->
validateAuthorization
(
$request
)
;
}
}