Webiny\Component\Security\User\AbstractUser::isTokenValid PHP Method

isTokenValid() public method

This method compares the $tokenData against the current user and returns true if users are identical, otherwise false is returned.
public isTokenValid ( TokenData $tokenData ) : boolean
$tokenData Webiny\Component\Security\Token\TokenData
return boolean
    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;
    }