def EmailLoginVerify(request): if request.method == 'POST': if 'token' in request.POST: try: submitted_token = int(request.POST['token']) except ValueError: return HttpResponse('Invalid token format', status=400) if submitted_token == request.session.get('login_token'): email = request.session.get('email') try: target = MyUser.objects.get(email=email) print('user is', target.username, 'and password is', target.password) #export: #>>>>>>>user is maziar and password is pbkdf2_sha256$720000$CY5sjiqAL1yScKzGhzYBp9$2tUx8ScBbbuZlj+u0YfMxwTIRfz5Vfmv+58piWCAjKM= except MyUser.DoesNotExist: return HttpResponse('User Not Found', status=404) user = authenticate(request, username=target.username, password=target.password) print(user) #export: #>>>>> None if user is not None: login(request, user) return HttpResponse('good') else: return HttpResponse('Authentication failed', status=401) else: return HttpResponse('Invalid token', status=403) else: return HttpResponse('Token not provided', status=400) else: return render(request, 'login_verify.html') in the end it return 'Authrntication Failed' this code get an email from the user if a user with that email exists it send a code to the email and if user enter the correct code it should authenticate the user and log it in but it return 'Authentication Failed' enter image description here Continue reading...