getUsername() public method

Returns the username stored in token data.
public getUsername ( ) : string
return string
Exemplo n.º 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;
 }
Exemplo n.º 2
0
 /**
  * @param TokenData $tokenData
  *
  * @dataProvider dataProvider
  */
 public function testGetUsername($tokenData)
 {
     $this->assertSame('username', $tokenData->getUsername());
 }