Allow only username and password field

I have a use-case where I am required to only use the username(not company email address). When the redirection happens, it expects it to be only username. How do I modify the universal-login page to achieve this?

Hi @ggautam-rev,

Thanks for reaching out to the Auth0 Community!

Unfortunately, it’s not possible to force the login page to require only the username. By default, when logging in with a database connection with the Requires Username feature enabled, the login page allows the user to provide either an email address or username to log in. This cannot be modified to require only the username. See below:

image

As a workaround, you could ask the user for their username before redirecting them to the login page and passing it in the login_hint query parameter of the login URL. Doing so will prefill the username/email field with the username.

For example:

https://{yourDomain}/authorize?
    response_type=code&
    client_id={yourClientId}&
    redirect_uri={https://yourApp/callback}&
    scope={scope}&
    audience={apiAudience}&
    state={state}&
    login_hint={USERNAME}

I hope this helps!

Please let me know if you have any questions.

Thanks,
Rueben

Hi Rueben, Thanks for the reply. I was thinking somewhat similar where I would capture the username and then write some custom code to perform the redirect. However, I could not figure out how I would get the value of the state parameter in the above query. Can you please help?

Hi @ggautam-rev,

Thank you for your reply.

The state parameter is a unique and non-guessable value associated with each authentication request. If you are using one of ourAuth0 SDK’s, then you should be able to call the appropriate login method with the login_hint query parameter, and it will automatically generate the state parameter for you.

In case you would like to test the login functionality and don’t require a specific state value, you can pass a random string such as state=xyzABC123 in your state parameter.

For more information about the state parameter, I recommend checking out our documentation on State Parameters.

Please let me if there’s anything else I can do to help.

Thanks,
Rueben

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.