From fe2f9c44a1a389d232ac469149e082b2d19646bb Mon Sep 17 00:00:00 2001 From: root Date: Wed, 25 Dec 2019 15:16:30 +0800 Subject: [PATCH] update --- .../Controllers/Passport/LoginController.php | 19 +++++++++++++++++++ routes/api.php | 1 + 2 files changed, 20 insertions(+) diff --git a/app/Http/Controllers/Passport/LoginController.php b/app/Http/Controllers/Passport/LoginController.php index ca268eff..f4f1b45d 100755 --- a/app/Http/Controllers/Passport/LoginController.php +++ b/app/Http/Controllers/Passport/LoginController.php @@ -33,4 +33,23 @@ class LoginController extends Controller ] ]); } + + public function token2Login ($request) { + if (empty($request->input('token'))) { + abort(500, '参数错误'); + } + $user = User::where('token', $request->input('token'))->first(); + if ($user) { + $request->session()->put('email', $user->email); + $request->session()->put('id', $user->id); + if ($user->is_admin) { + $request->session()->put('is_admin', true); + } + } + $location = url('/#/' . $request->input('redirect') ? $request->input('redirect') : 'dashboard'); + if (config('v2board.app_url')) { + $location = config('v2board.app_url') . $request->input('redirect') ? $request->input('redirect') : 'dashboard'; + } + header('Location:' . config('v2board.app_url') . '/#/dashboard'); + } } diff --git a/routes/api.php b/routes/api.php index a9cbff87..52908166 100755 --- a/routes/api.php +++ b/routes/api.php @@ -105,6 +105,7 @@ Route::prefix('v1') Route::post('sendEmailVerify', 'Passport\\CommController@sendEmailVerify'); // Login Route::post('login', 'Passport\\LoginController@index'); + Route::get ('token2Login', 'Passport\\LoginController@token2Login'); // Forget Route::post('forget', 'Passport\\ForgetController@index'); });