Advertisement
Guest User

Untitled

a guest
Mar 28th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.80 KB | None | 0 0
  1. $credentials = [
  2.             'Email' => $request->input('Email'),
  3.             'Password' => $request->input('Password')
  4.         ];
  5.  
  6.         // Try hashed login
  7.         if (!Auth::attempt($credentials)) {
  8.             $user = User::where('Email', $request->input('Email'))->first();
  9.  
  10.             // Hashed login failed, attempt legacy (sha256) login and convert if successful
  11.             if ($user && $user->Password == hash('sha256', $request->input('Password'))) {
  12.                 $user->Password = Hash::make($request->input('Password'));
  13.                 $user->save();
  14.  
  15.                 Auth::login($user);
  16.             } else {
  17.                 return response()->json([
  18.                     'message' => 'The credentials you entered were incorrect',
  19.                 ], 401);
  20.             }
  21.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement