Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8221679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:01:01+00:00 2026-06-07T14:01:01+00:00

I need to display an error message on failed login attempts that says whether

  • 0

I need to display an error message on failed login attempts that says whether the user was inactive, the password was incorrect, or the user was not found. I’m authenticating against an API so I made a custom authentication backend. At the moment, to prove to the client login is working, I have it raising exceptions called UserNotFoundError, InactiveUserError, and InvalidPasswordError.

I’m fairly sure that’s not the right way to go about it, and if I want to use Django’s auth views I have no way to catch those exceptions anyway.

I assume I will need to create my own auth views. But, is there a better way?

(I know it’s not as secure to give a reason for a failed login, but I have to.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T14:01:02+00:00Added an answer on June 7, 2026 at 2:01 pm

    This is totally untested, and not guaranteed to work, but you could try something along these lines. The only caveat with this solution is that your backend must be the last authentication backend used (or the only one used).

    The contrib.auth.views.authenticate method takes an argument for authentication_form, meaning that you should be able to override it with your own form that extends contrib.auth.forms.AuthenticationForm. That form is what calls your backend’s authenticate() method. So, in your backend you could return some custom object which contains both the user instance as well as a “failed” status and a “failed reason” for why authentication failed.

    If your custom object has a failed status, you can throw a ValidationError with the exception, at which point the login view will not do any further processing of the user.

    Also make sure you override form.get_user() so that it returns the actual User instance, and not your custom object.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following view that i need to display an error message when
I need to display error message on model in rails, my coding on model
I need to display an error message on rejecting a drop in my application.
I need to display a character symbol (Not alphanumeric, or on the keyword) textField.text
I want to be able to send a friendly error message to my user
In my app i want to display an error message if the network connection
I have implemented my MVVM error message as a message dialog that subscribes to
I am using QLabel widgets to display error messages to the user in the
I want to spawn another process to display an error message asynchronously while the
i'm currently working a list of data that i need to display in a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.