def post(self, request): email = request.POST.get('email') password = request.POST.get('password') if not Customer.objects.filter(email=email).exists(): messages.error(request, 'Email Does Not Exists') return render(request, 'login.html') else: customerObj = Customer.getCustomerByEmail(email=email) if self.passMatching(customerObj, password): request.session['customer'] = Customer.objects.filter( email=customerObj.email).values()[0] print(request.session.get('customer')['email']) return redirect('index') else: messages.error(request, 'Email and password does not match.') return render(request, 'login.html')
def post(self, request): #we submit the login form in which two fields are there email and password and after submit Login Post method is called and from this post method we fetch the value from the submitte section email = request.POST.get('email') #password send by the user password = request.POST.get('password') #check if customer exist or not customer = Customer.getCustomerByEmail(email) error_message = None if customer: #check customer temp = check_password(password, customer.password) if temp: return redirect('homepage') else: error_message = 'Wrong email or password' else: error_message = 'Wrong email or password' return render(request, 'login.html', {'error': error_message})