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.
38 lines
723 B
PHTML
38 lines
723 B
PHTML
|
10 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
|
||
|
|
];
|
||
|
|
$decode = Jwt::encode($ary);
|
||
|
|
Utils\Cookie::set([
|
||
|
|
//"uid" => $uid,
|
||
|
|
"token" => $decode
|
||
|
|
], $expireTime);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function logout()
|
||
|
|
{
|
||
|
|
Utils\Cookie::set([
|
||
|
|
//"uid" => $uid,
|
||
|
|
"token" => ""
|
||
|
|
], time()-3600);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function getUser()
|
||
|
|
{
|
||
|
|
$token = Utils\Cookie::get('token');
|
||
|
|
$tokenInfo = Jwt::decodeArray($token);
|
||
|
|
}
|
||
|
|
}
|