29 lines
538 B
PHP
29 lines
538 B
PHP
<?php
|
|
|
|
require_once APPPATH . 'libraries/JWT.php';
|
|
|
|
use \Firebase\JWT\JWT;
|
|
|
|
class Authorization
|
|
{
|
|
|
|
public static function validateToken($token)
|
|
{
|
|
$CI =& get_instance();
|
|
$key = $CI->config->item('jwt_key');
|
|
$algorithm = $CI->config->item('jwt_algorithm');
|
|
return JWT::decode($token, $key, array($algorithm));
|
|
}
|
|
|
|
public static function generateToken($data)
|
|
{
|
|
$CI =& get_instance();
|
|
$key = $CI->config->item('jwt_key');
|
|
return JWT::encode($data, $key);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|