/**
  * Returns serialized token.
  *
  * @param AuthToken $token
  * @return string
  */
 public function serializeToken(AuthToken $token)
 {
     $payload = $this->encrypter->encrypt(array('id' => $token->getAuthIdentifier(), 'key' => $token->getPublicKey(), 'userAgent' => $token->getUserAgent()));
     $payload = str_replace(array('+', '/', '\\r', '\\n', '='), array('-', '_'), $payload);
     return $payload;
 }
 /**
  * Retrive user from auth token.
  *
  * @param AuthToken $token
  * @return UserInterface|null
  */
 public function user(AuthToken $token)
 {
     return $this->users->retrieveByID($token->getAuthIdentifier());
 }