public function getTokenForUser(User $user, int $validForSeconds = null, array $additionalData = []): string
    {
        $tokenData = [
            'user_id' => $user->id,
            'generated' => time(),
            'validForSeconds' => $validForSeconds,
            'additionalData' => $additionalData,
        ];
        $tokenDataString = serialize($tokenData);
        $encrypted = Security::encrypt($tokenDataString, Configure::read('Security.cryptKey'));

        return base64_encode($encrypted);
    }