def loginclient(request): template = loader.get_template('front/login.html') args = {} args['page'] = 'Login' if request.method == 'POST': form = LoginClientForm(request.POST) if form.is_valid(): # form.save() # mcb=MyCustomBackend() # if mcb.authenticateadmin(form.cleaned_data.get('username'),form.cleaned_data.get('password')): # print(str(form.cleaned_data.get('email'))) # print(str(form.cleaned_data.get('password'))) user = authenticate(username=form.cleaned_data.get('username'), password=form.cleaned_data.get('password')) if user: next_page = request.GET.get('next', '/') login(request, user) return HttpResponseRedirect(next_page) else: messages.error(request, 'Username and password do not match.') return redirect('fr_login') else: form = LoginClientForm() args['form'] = form return HttpResponse(template.render(args, request))
def needloginclient(request): args = {} if request.method == 'POST': form = LoginClientForm(request.POST) if form.is_valid(): user = authenticate(username=form.cleaned_data.get('username'), password=form.cleaned_data.get('password')) next_page = request.GET.get('next', '/') if user: login(request, user) else: messages.error(request, 'Username and password do not match.') return HttpResponseRedirect(next_page) return HttpResponse(template.render(args, request))