mirror of
https://github.com/flextype/flextype.git
synced 2025-08-07 05:36:54 +02:00
feat(tokens): rename tokens helpers
This commit is contained in:
@@ -126,7 +126,7 @@ class Api
|
||||
return $this->getStatusCodeMessage(401);
|
||||
}
|
||||
|
||||
if (! tokenHashValidate($data['access_token'], $tokenData['hashed_access_token'])) {
|
||||
if (! validateTokenHash($data['access_token'], $tokenData['hashed_access_token'])) {
|
||||
return $this->getStatusCodeMessage(401);
|
||||
}
|
||||
}
|
||||
|
@@ -2,15 +2,15 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
if (! function_exists('token')) {
|
||||
if (! function_exists('generateToken')) {
|
||||
/**
|
||||
* Token.
|
||||
* Generate token.
|
||||
*
|
||||
* @param int $length Token string length.
|
||||
*
|
||||
* @return strings Token string.
|
||||
*/
|
||||
function token(int $length = 16): string
|
||||
function generateToken(int $length = 16): string
|
||||
{
|
||||
return bin2hex(random_bytes($length));
|
||||
}
|
||||
@@ -18,28 +18,28 @@ if (! function_exists('token')) {
|
||||
|
||||
if (! function_exists('tokenHash')) {
|
||||
/**
|
||||
* Token hash.
|
||||
* Generate token hash.
|
||||
*
|
||||
* @param int $length Token string length.
|
||||
*
|
||||
* @return string Token string.
|
||||
*/
|
||||
function tokenHash(int $length = 16): string
|
||||
function generateTokenHash(int $length = 16): string
|
||||
{
|
||||
return password_hash(token($length), PASSWORD_BCRYPT);
|
||||
return password_hash(generateToken($length), PASSWORD_BCRYPT);
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('tokenHashValidate')) {
|
||||
if (! function_exists('validateTokenHash')) {
|
||||
/**
|
||||
* Token hash validate.
|
||||
* Validate token hash.
|
||||
*
|
||||
* @param string $token Token string length.
|
||||
* @param string $tokenHashed Token string length.
|
||||
*
|
||||
* @return bool Token string.
|
||||
*/
|
||||
function tokenHashValidate(string $token, string $tokenHashed): bool
|
||||
function validateTokenHash(string $token, string $tokenHashed): bool
|
||||
{
|
||||
return password_verify($token, $tokenHashed);
|
||||
}
|
||||
|
Reference in New Issue
Block a user