Inheritance: use trait Webiny\Component\StdLib\StdLibTrait
Example #1
0
 /**
  * This method compares the $tokenData against the current user and returns true if users are identical,
  * otherwise false is returned.
  *
  * @param TokenData $tokenData
  *
  * @return bool
  */
 public function isTokenValid(TokenData $tokenData)
 {
     $roles = [];
     foreach ($this->roles as $role) {
         $roles[] = $role->getRole();
     }
     $currentUser = $this->str($this->getUsername() . implode(',', $roles))->hash('md5');
     $tokenRoles = [];
     foreach ($tokenData->getRoles() as $role) {
         $tokenRoles[] = $role->getRole();
     }
     $tokenUser = $this->str($tokenData->getUsername() . implode(',', $tokenRoles))->hash('md5');
     return $currentUser == $tokenUser;
 }
Example #2
0
 /**
  * @param TokenData $tokenData
  *
  * @dataProvider dataProvider
  */
 public function testGetAuthProviderName($tokenData)
 {
     $this->assertSame('MockProvider', $tokenData->getAuthProviderName());
 }