You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Malio/app/Services/Auth/JwtToken.php

38 lines
729 B
PHTML

9 years ago
<?php
namespace App\Services\Auth;
use App\Utils;
use App\Services\Jwt;
class JwtToken extends Base
{
public function login($uid, $time)
{
$expireTime = time() + $time;
$ary = [
'uid' => $uid,
'expire_time' => $expireTime
9 years ago
];
$decode = Jwt::encode($ary);
Utils\Cookie::set([
//"uid" => $uid,
'token' => $decode
9 years ago
], $expireTime);
}
public function logout()
{
Utils\Cookie::set([
//"uid" => $uid,
'token' => ''
8 years ago
], time() - 3600);
9 years ago
}
public function getUser()
{
$token = Utils\Cookie::get('token');
$tokenInfo = Jwt::decodeArray($token);
}
}