Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. // UserController.php
  2. public function signin(Request $request) {
  3.  
  4. $credentials = $request->only('email', 'password');
  5. $email = $request->input('email');
  6.  
  7. // Check if login attempts above 3
  8. // Here I need to get the 'login_attempts' value
  9. $loginAttempts = AppUser::where('email', $email)->value('login_attempts');
  10. if($loginAttempts >= 3){
  11. // Response: To many attempts
  12. }
  13.  
  14. try{
  15. // Some JWT Auth validation
  16. }
  17. } catch (JWTException $e) {
  18. // Increase failed login counter
  19. // $attemptedUser-> <--- Here i need to increase the 'login_attempts' for the user with the email of the login request
  20. $attemptedUser->save();
  21. }
  22. // Some more validation and response
  23. }
  24.  
  25. //Here you get the 'login_attempts' value
  26.  
  27. $loginAttempts = AppUser::where('email', $email)->select('login_attempts')->first();
  28.  
  29. $loginAttempts->login_attempts += 1;
  30. $loginAttempts->save();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement