Advertisement
Guest User

Nwww

a guest
May 10th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.14 KB | None | 0 0
  1.     public function login(Request $request)
  2.     {
  3.         $request->validate([
  4.             'username' => 'required|string|exists:register_db.tbl_account,account_gid',
  5.             'password' => 'required|min:6'
  6.         ]);
  7.  
  8.         //es gadaamowme namdvilad swor users abrunebs tua ra
  9.         $user = Tbl_account::where('account_gid', $request->username)->first(); //find in database
  10.         if (!$user instanceOf Tbl_account) { //check if user is instance of user
  11.             return redirect()->back()->withErrors(['Username is incorrect or invalid!', 'Error']); //invalid username
  12.         }
  13.         //so found user with this username
  14.         //then check password
  15.         $encryptedPassword = substr(md5($request->password), 8, 16);
  16.         if ($encryptedPassword !== $user->account_pw) {
  17.             return redirect()->back()->withErrors(['Password is incorrect or invalid!', 'Error']);//valid username invalid password
  18.         }
  19.         // If login succesful, then redirect to their intended location
  20.         Auth::login($user); // shen es amimushave romel usersac poulebs rom daaloginos
  21.         return redirect()->intended(route('home'));
  22.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement