This commit is contained in:
tokumeikoi 2021-02-19 01:15:37 +09:00
parent da8bff5609
commit b0ddf7d45f
3 changed files with 12 additions and 5 deletions

View File

@ -131,7 +131,8 @@ class AuthController extends Controller
} }
$data = [ $data = [
'token' => $user->token 'token' => $user->token,
'auth_data' => base64_encode("{$user->email}:{$user->password}")
]; ];
$request->session()->put('email', $user->email); $request->session()->put('email', $user->email);
$request->session()->put('id', $user->id); $request->session()->put('id', $user->id);
@ -202,7 +203,10 @@ class AuthController extends Controller
public function getQuickLoginUrl(Request $request) public function getQuickLoginUrl(Request $request)
{ {
$user = User::where('token', $request->input('token'))->first(); $authData = explode(':', base64_decode($request->input('auth_data')));
$user = User::where('email', $authData[0])
->where('password', $authData[1])
->first();
if (!$user) { if (!$user) {
abort(500, '令牌有误'); abort(500, '令牌有误');
} }

View File

@ -15,8 +15,11 @@ class User
*/ */
public function handle($request, Closure $next) public function handle($request, Closure $next)
{ {
if ($request->input('access_token')) { if ($request->input('auth_data')) {
$user = \App\Models\User::where('token', $request->input('access_token'))->first(); $authData = explode(':', base64_decode($request->input('auth_data')));
$user = \App\Models\User::where('password', $authData[1])
->where('email', $authData[0])
->first();
if ($user) { if ($user) {
$request->session()->put('email', $user->email); $request->session()->put('email', $user->email);
$request->session()->put('id', $user->id); $request->session()->put('id', $user->id);

View File

@ -236,5 +236,5 @@ return [
| The only modification by laravel config | The only modification by laravel config
| |
*/ */
'version' => '1.5.0' 'version' => '1.5.1'
]; ];