This commit is contained in:
root 2019-12-25 15:16:30 +08:00
parent 3096b28076
commit fe2f9c44a1
2 changed files with 20 additions and 0 deletions

View File

@ -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');
}
}

View File

@ -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');
});