1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-07 05:36:54 +02:00

feat(tokens): update tokens helpers and rest api

This commit is contained in:
Awilum
2021-09-22 13:52:39 +03:00
parent 94b0984e18
commit 91e22739bf
2 changed files with 9 additions and 9 deletions

View File

@@ -126,7 +126,7 @@ class Api
return $this->getStatusCodeMessage(401);
}
if (! validateTokenHash($data['access_token'], $tokenData['hashed_access_token'])) {
if (! verifyTokenHash($data['access_token'], $tokenData['hashed_access_token'])) {
return $this->getStatusCodeMessage(401);
}
}

View File

@@ -16,30 +16,30 @@ if (! function_exists('generateToken')) {
}
}
if (! function_exists('tokenHash')) {
if (! function_exists('generateTokenHash')) {
/**
* Generate token hash.
*
* @param int $length Token string length.
* @return strings Token string.
*
* @return string Token string.
* @return string Token string hashed.
*/
function generateTokenHash(int $length = 16): string
function generateTokenHash(string $token): string
{
return password_hash(generateToken($length), PASSWORD_BCRYPT);
return password_hash($token, PASSWORD_BCRYPT);
}
}
if (! function_exists('validateTokenHash')) {
if (! function_exists('verifyTokenHash')) {
/**
* Validate token hash.
* Verify token hash.
*
* @param string $token Token.
* @param string $tokenHashed Token hash.
*
* @return bool Token string.
*/
function validateTokenHash(string $token, string $tokenHashed): bool
function verifyTokenHash(string $token, string $tokenHashed): bool
{
return password_verify($token, $tokenHashed);
}