mirror of
https://github.com/v2board/v2board.git
synced 2025-01-10 16:19:10 +08:00
update
This commit is contained in:
parent
bd35c782f0
commit
a8a6c6382e
@ -136,17 +136,11 @@ class AuthController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
// 准备废弃
|
||||
public function token2Login(Request $request)
|
||||
{
|
||||
if ($request->input('token')) {
|
||||
$user = User::where('token', $request->input('token'))->first();
|
||||
if (!$user) {
|
||||
return header('Location:' . config('v2board.app_url'));
|
||||
}
|
||||
$code = Helper::guid();
|
||||
$key = 'token2Login_' . $code;
|
||||
Cache::put($key, $user->id, 600);
|
||||
$redirect = '/#/login?verify=' . $code . '&redirect=' . ($request->input('redirect') ? $request->input('redirect') : 'dashboard');
|
||||
$redirect = '/#/login?verify=' . $request->input('token') . '&redirect=' . ($request->input('redirect') ? $request->input('redirect') : 'dashboard');
|
||||
if (config('v2board.app_url')) {
|
||||
$location = config('v2board.app_url') . $redirect;
|
||||
} else {
|
||||
@ -156,7 +150,7 @@ class AuthController extends Controller
|
||||
}
|
||||
|
||||
if ($request->input('verify')) {
|
||||
$key = 'token2Login_' . $request->input('verify');
|
||||
$key = CacheKey::get('TEMP_TOKEN', $request->input('verify'));
|
||||
$userId = Cache::get($key);
|
||||
if (!$userId) {
|
||||
abort(500, '令牌有误');
|
||||
@ -180,6 +174,21 @@ class AuthController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function getTempToken(Request $request)
|
||||
{
|
||||
$user = User::where('token', $request->input('token'))->first();
|
||||
if (!$user) {
|
||||
abort(500, '用户不存在');
|
||||
}
|
||||
|
||||
$code = Helper::guid();
|
||||
$key = CacheKey::get('TEMP_TOKEN', $code);
|
||||
Cache::put($key, $user->id, 60);
|
||||
return response([
|
||||
'data' => $code
|
||||
]);
|
||||
}
|
||||
|
||||
public function check(Request $request)
|
||||
{
|
||||
$data = [
|
||||
|
@ -10,14 +10,13 @@ class PassportRoute
|
||||
$router->group([
|
||||
'prefix' => 'passport'
|
||||
], function ($router) {
|
||||
// TODO: 1.1.1 abolish
|
||||
$router->post('/login', 'Passport\\AuthController@login');
|
||||
// Auth
|
||||
$router->post('/auth/register', 'Passport\\AuthController@register');
|
||||
$router->post('/auth/login', 'Passport\\AuthController@login');
|
||||
$router->get ('/auth/token2Login', 'Passport\\AuthController@token2Login');
|
||||
$router->get ('/auth/check', 'Passport\\AuthController@check');
|
||||
$router->post('/auth/forget', 'Passport\\AuthController@forget');
|
||||
$router->post('/auth/getTempToken', 'Passport\\AuthController@getTempToken');
|
||||
// Comm
|
||||
$router->get ('/comm/config', 'Passport\\CommController@config');
|
||||
$router->post('/comm/sendEmailVerify', 'Passport\\CommController@sendEmailVerify');
|
||||
|
@ -10,7 +10,8 @@ class CacheKey
|
||||
'SERVER_V2RAY_ONLINE_USER' => '节点在线用户',
|
||||
'SERVER_V2RAY_LAST_CHECK_AT' => '节点最后检查时间',
|
||||
'SERVER_TROJAN_ONLINE_USER' => 'trojan节点在线用户',
|
||||
'SERVER_TROJAN_LAST_CHECK_AT' => 'trojan节点最后检查时间'
|
||||
'SERVER_TROJAN_LAST_CHECK_AT' => 'trojan节点最后检查时间',
|
||||
'TEMP_TOKEN' => '临时令牌'
|
||||
];
|
||||
|
||||
public static function get(string $key, $uniqueValue)
|
||||
|
Loading…
Reference in New Issue
Block a user