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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user