Guest User

Untitled

a guest
Aug 9th, 2018
1,024
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. user = authenticate(username, password)
  2.  
  3. username = self.cleaned_data.get('username')
  4. password = self.cleaned_data.get('password')
  5.  
  6. # check if user exists
  7. try:
  8. user = User.objects.get(username=username)
  9. except User.DoesNotExist:
  10. user = None
  11.  
  12. #check if user is_active
  13. if user.is_active:
  14. user_active = true
  15. else
  16. user_active = false
  17.  
  18. #check the password
  19.  
  20. if user_active:
  21. password_match = user.check_password(password):
  22. else:
  23. password_match = false
  24.  
  25. if password_match:
  26. msg = "Login Successful"
  27. else:
  28. msg = "Login Failed"
Add Comment
Please, Sign In to add comment