Tuesday, April 23, 2019

authenticate() only authenticate superuser

I am using authenticate function to authenticate user on login this is working properly but only allow superuser to login.

def Login_View(request):
    if request.method == "POST":
        username = request.POST['username']
        password = request.POST['pwd']
        user =authenticate(request,username=username, password=password)
        if user is not None:
            if user.is_active:
                login(request, user)
                name = User.objects.get(username=request.user)
                request.session['username'] = username
                return redirect('/dashboard/',{'name':name.username})
                # return render(request,'dashboard_app/index.html',{'name':name.username})
            else:
                 return render(request, 'login_app/index.html', {'error_message': 'Your account has been disabled'})
        else:
            return render(request, 'login_app/index.html', {'error_message': 'Invalid login'})
    return render(request, 'login_app/index.html')
kindly aolve my issue asap

--
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/af4b7e96-eb62-4d56-988e-7eb4140f0a77%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment