fix: edge cases

This commit is contained in:
loks0n
2023-10-09 14:49:07 +01:00
parent e94631f730
commit c4e82e4191
3 changed files with 14 additions and 7 deletions
+5 -2
View File
@@ -1107,7 +1107,7 @@ App::post('/v1/users/:userId/tokens')
throw new Exception(Exception::USER_NOT_FOUND);
}
$loginSecret = Auth::tokenGenerator();
$secret = Auth::tokenGenerator();
$expire = DateTime::formatTz(DateTime::addSeconds(new \DateTime(), Auth::TOKEN_EXPIRATION_CONFIRM));
$token = new Document([
@@ -1115,13 +1115,16 @@ App::post('/v1/users/:userId/tokens')
'userId' => $user->getId(),
'userInternalId' => $user->getInternalId(),
'type' => Auth::TOKEN_TYPE_UNIVERSAL,
'secret' => Auth::hash($loginSecret), // One way hash encryption to protect DB leak
'secret' => Auth::hash($secret), // One way hash encryption to protect DB leak
'expire' => $expire,
'userAgent' => 'UNKNOWN',
'ip' => 'UNKNOWN',
]);
$token = $dbForProject->createDocument('tokens', $token);
$dbForProject->deleteCachedDocument('users', $user->getId());
$token->setAttribute('secret', $secret);
$events
->setParam('userId', $user->getId())