travel/service/app/user/controller/IndexController.php

46 lines
1023 B
PHP
Raw Normal View History

2024-06-24 11:24:06 +08:00
<?php
namespace app\user\controller;
use Firebase\JWT\JWT;
use Webman\Http\Request;
class IndexController extends base
{
public function index(Request $request)
{
$uid = $request->user->id;
}
public function login(Request $request) {
$time = time();
$data = [
'id'=> 1,
'username'=> 'Tom'
];
$payload = array(
// "iss" => "http://127.0.0.1:8000", // issuer
// "aud" => "http://example.com", // audience
"iat" => $time, // token 的创建时间
"nbf" => $time, // token 的生效时间
"exp" => $time+3600*24, // token 的过期时间
"data"=> $data // 携带数据
);
$keyId = "keyId";
$token = JWT::encode($payload, config('app.jwt_key'), 'HS256', $keyId);
return $this->success($token);
}
public function forget(Request $request) {
}
public function sms(Request $request) {
}
}