Files
spacestation/common/helpers/authorization_helper.php
T
2025-11-29 10:40:00 +08:00

24 lines
660 B
PHP

<?php
defined('BASEPATH') or exit('No direct script access allowed');
require_once COMMPATH . 'libraries/JWT.php';
use \Firebase\JWT\JWT;
if (!function_exists('validateToken')) {
function validateToken($token, $item = 'jwt_key')
{
$CI =& get_instance();
$key = $CI->config->item($item);
$algorithm = $CI->config->item('jwt_algorithm');
return JWT::decode($token, $key, array($algorithm));
}
}
if (!function_exists('generateToken')) {
function generateToken($data, $item = 'jwt_key')
{
$CI =& get_instance();
$key = $CI->config->item($item);
return JWT::encode($data, $key);
}
}