Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function login(Request $request)
- {
- $request->validate([
- 'username' => 'required|string|exists:register_db.tbl_account,account_gid',
- 'password' => 'required|min:6'
- ]);
- //es gadaamowme namdvilad swor users abrunebs tua ra
- $user = Tbl_account::where('account_gid', $request->username)->first(); //find in database
- if (!$user instanceOf Tbl_account) { //check if user is instance of user
- return redirect()->back()->withErrors(['Username is incorrect or invalid!', 'Error']); //invalid username
- }
- //so found user with this username
- //then check password
- $encryptedPassword = substr(md5($request->password), 8, 16);
- if ($encryptedPassword !== $user->account_pw) {
- return redirect()->back()->withErrors(['Password is incorrect or invalid!', 'Error']);//valid username invalid password
- }
- // If login succesful, then redirect to their intended location
- Auth::login($user); // shen es amimushave romel usersac poulebs rom daaloginos
- return redirect()->intended(route('home'));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement