/**
* Stores user data into an array, encrypts it and returns the encrypted string.
*
* @param AbstractUser $user Instance of AbstractUser class that holds the pre-filled object from user provider.
*
* @return string
*/
public function encryptUserData(AbstractUser $user)
{
// data (we use short syntax to reduce the size of the cookie or session)
$data = ['u' => $user->getUsername(), 'vu' => $this->tokenRememberMe ? time() + 86400 * 30 : time() + 86400, 'ap' => $user->getAuthProviderName(), 'up' => $user->getUserProviderName()];
// build and add token to $data
$token = $this->getCrypt()->encrypt($this->jsonEncode($data), $this->getEncryptionKey());
$token = urlencode(rtrim($token, '='));
return $token;
}