This is my fbv:
def loginView(request):
if request.method == 'POST':
form = LoginForm(request.POST)
if form.is_valid():
cd = form.cleaned_data
user = authenticate(request,
email=cd['email'],
password=cd['password'])
if user is not None:
login(request, user)
if user.is_authenticated and user.is_client:
return redirect('clients:detail') # Go to client dashboard
elif user.is_authenticated and user.is_account_manager:
return redirect('accountmanagers:detail') #Go to account manager dashboard
else:
return HttpResponse('Invalid login')
else:
# Invalid email or password. Handle as you wish
form = LoginForm()
return render(request, 'registration/login.html', {'form': form})
if request.method == 'POST':
form = LoginForm(request.POST)
if form.is_valid():
cd = form.cleaned_data
user = authenticate(request,
email=cd['email'],
password=cd['password'])
if user is not None:
login(request, user)
if user.is_authenticated and user.is_client:
return redirect('clients:detail') # Go to client dashboard
elif user.is_authenticated and user.is_account_manager:
return redirect('accountmanagers:detail') #Go to account manager dashboard
else:
return HttpResponse('Invalid login')
else:
# Invalid email or password. Handle as you wish
form = LoginForm()
return render(request, 'registration/login.html', {'form': form})
I would appreciate any help.
-- You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ea6c54f2-ecc0-407d-a296-e168d509a299n%40googlegroups.com.
No comments:
Post a Comment