# From the Universal Login page, is it possible to redirect a user with a specific domain to an old non-Auth0 login page?

**URL:** <https://community.auth0.com/t/from-the-universal-login-page-is-it-possible-to-redirect-a-user-with-a-specific-domain-to-an-old-non-auth0-login-page/55908>\
**Category:** Get Help\
**Tags:** login\
**Created:** [January 8, 2021, 4:20pm UTC](https://community.auth0.com/t/from-the-universal-login-page-is-it-possible-to-redirect-a-user-with-a-specific-domain-to-an-old-non-auth0-login-page/55908 "2021-01-08T16:20:18Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![declan](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/declan/32/26837_2.png) [@declan](https://community.auth0.com/u/declan)\
**Post date:** [January 8, 2021, 4:20pm UTC](https://community.auth0.com/t/from-the-universal-login-page-is-it-possible-to-redirect-a-user-with-a-specific-domain-to-an-old-non-auth0-login-page/55908/1 "2021-01-08T16:20:18Z")

</div>

Hi,

I am investigating the use of various flows using Auth0. I am wondering if the question in my topic title is possible?

For example, can I redirect [joe@acme.com](mailto:joe@acme.com) back to the old non-Auth0 login page - while allowing [pete@example.com](mailto:pete@example.com) to login using the Universal login page? This would greatly facilitate a staged migration.

Kind regards,  
Declan

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [January 8, 2021, 7:38pm UTC](https://community.auth0.com/t/from-the-universal-login-page-is-it-possible-to-redirect-a-user-with-a-specific-domain-to-an-old-non-auth0-login-page/55908/3 "2021-01-08T19:38:53Z")

</div>

Hi @declan,

Welcome to the Community!

It would probably be easier to do this from your application than from the hosted login page. We support realm discovery, but it wont point the user away from Auth0.

---

<div class="post-metadata">

**Author:** ![declan](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/declan/32/26837_2.png) [@declan](https://community.auth0.com/u/declan)\
**Post date:** [January 11, 2021, 5:31pm UTC](https://community.auth0.com/t/from-the-universal-login-page-is-it-possible-to-redirect-a-user-with-a-specific-domain-to-an-old-non-auth0-login-page/55908/4 "2021-01-11T17:31:03Z")

</div>

Thanks for the quick reply @dan.woda. Much appreciated!

The problem with doing this from my application is that it would put the decision making in my application. Whereas it is more desirable to use the Universal Login page - and related Auth0 connections - as the source of auth decision making (as much as possible, of course).

I have taken a look at some other docs and forum posts. How about this solution…

- Have a Auth0 **Database** connection, elect to “Use my own database” under the Custom Database settings, then add a **Login** script with something like the following pseudocode:

And then in an Auth0 rule do something like…

```
  if (user.reject_login_attempt) {
        context.redirect = {
          url: "https://legacy_auth_server/old_login_page"
        };
        return callback(null, null, context); // It may make sense to pass user as the 2nd arg here instead of null
    } else {
      return callback(null, user, context);
    }

```

Resources:

- The redirect idea in the context was noted here [UnauthorizedError not returning error](https://community.auth0.com/t/unauthorizederror-not-returning-error/21375)
- Here are the related docs on redirecting from within a rule [https://auth0.com/docs/rules/redirect-users?\_ga=2.13958007.1716788289.1610359780-530603537.1604326164](https://auth0.com/docs/rules/redirect-users?_ga=2.13958007.1716788289.1610359780-530603537.1604326164)

@dan.woda Does that seem reasonable? Are there some pitfalls with this approach? I notice that the user still appears in the list of users in Auth0 - is it possible to prevent this?

Kind regards,  
Declan

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [January 11, 2021, 6:06pm UTC](https://community.auth0.com/t/from-the-universal-login-page-is-it-possible-to-redirect-a-user-with-a-specific-domain-to-an-old-non-auth0-login-page/55908/5 "2021-01-11T18:06:06Z")

</div>

That seems like quite a workaround. You are effectively logging the user in before they provide credentials. Also, redirect rules are meant to redirect away from the rule and then return back to the rules flow after the redirect action is completed.

Where are you seeing this recommended?

---

<div class="post-metadata">

**Author:** ![declan](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/declan/32/26837_2.png) [@declan](https://community.auth0.com/u/declan)\
**Post date:** [January 11, 2021, 6:48pm UTC](https://community.auth0.com/t/from-the-universal-login-page-is-it-possible-to-redirect-a-user-with-a-specific-domain-to-an-old-non-auth0-login-page/55908/6 "2021-01-11T18:48:21Z")

</div>

Thanks @dan.woda.

You have part-answered my implied question which is, ‘ **Does this mean that the user is effectively logged in** ’?

From your reply, my understanding is now that the user **is effectively logged in**.

When I tested the approach, I did not see any “successful login” in the Auth0 logs so that suggested that the user wasn’t successfully logged in. I _think_ that was the case - even if I passed `user` as a second argument to `callback(null, null, context)` - though I would need to double-check that. The fact that they appeared in the users list made me think that this is indeed effectively a login - and you have now confirmed that.

As regards where I saw this recommended, I wouldn’t go as far as to say that it was recommended for a legacy login page use case - I just saw ’ keep a **white-list of users** and deny access based on email’ at [Auth0 Rules](https://auth0.com/docs/rules) and decided to investigate what ‘deny’ exactly meant. Now, I know the answer.

Regarding the technique, I saw it here - [Redirecting on login failure - #6 by konrad.sopala](https://community.auth0.com/t/redirecting-on-login-failure/50951/6) - where the forum posted initially stated:

> I want to redirect the user to another url if the login attempt is failed.

and

> In case of login failure, it shows “Wrong email or password” in the Auth0 login dialogue itself. Instead of showing this message, I want to redirect the user to our custom page if login fails

(The redirect URL desired by the forum poster is not an alternative legacy login page of course.)

Ideally, from my use case’s perspective, the best solution would be if there is another type of connection in Auth0 - and using this connection type (let’s call it a _Simple Redirect Connection_) you could redirect based on a JS script or configuration. That would allow the user to be redirected to a legacy login page if they fitted certain criteria - similar to the “login” script in the custom database connection (but it would get rid of the password field as soon as the criteria were met). I guess nothing like this exists?

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [January 11, 2021, 7:31pm UTC](https://community.auth0.com/t/from-the-universal-login-page-is-it-possible-to-redirect-a-user-with-a-specific-domain-to-an-old-non-auth0-login-page/55908/7 "2021-01-11T19:31:22Z")

</div>

> [@declan](#):
>
> From your reply, my understanding is now that the user **is effectively logged in**.

I made this statement a bit casually. It is not that the user is logging in, but rather that they are being authenticated without providing credentials. This is why you see a user profile, but not a successful login (they never complete the login).

[Here is a visualization of the login flow.](https://cdn.auth0.com/blog/auth0-raises-100m-to-fuel-the-growth/inside-the-auth0-engine-high-res.jpg) Your user starts the “optional redirect” but never resumes and completes the login.

> [@declan](#):
>
> Ideally, from my use case’s perspective, the best solution would be if there is another type of connection in Auth0 - and using this connection type (let’s call it a _Simple Redirect Connection_ )

This isn’t quite a connection. Your legacy login page is not an identity provider passing a token or profile back to Auth0, then Auth0 issuing a token. It is simply redirecting to a separate login page. That is if I understand everything correctly.

You could probably do what you originally intended by [creating your own UI.](https://auth0.com/docs/universal-login/universal-login-page-customization#custom-user-interface)

Using a Custom Database to bypass authentication, then redirecting from a rule without resuming does not seem like a viable solution for this. It may work, but you are going to be creating user profiles every time you do this. It is quite a workaround.

---

<div class="post-metadata">

**Author:** ![declan](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/declan/32/26837_2.png) [@declan](https://community.auth0.com/u/declan)\
**Post date:** [January 12, 2021, 8:47pm UTC](https://community.auth0.com/t/from-the-universal-login-page-is-it-possible-to-redirect-a-user-with-a-specific-domain-to-an-old-non-auth0-login-page/55908/8 "2021-01-12T20:47:11Z")

</div>

Thanks again, Dan, your feedback is great.

> [@dan.woda](#):
>
> It is not that the user is logging in, but rather that they are being authenticated without providing credentials. This is why you see a user profile, but not a successful login (they never complete the login).

Makes perfect sense, thanks.

> [@](#):
>
> This isn’t quite a connection. Your legacy login page is not an identity provider passing a token or profile back to Auth0, then Auth0 issuing a token. It is simply redirecting to a separate login page. That is if I understand everything correctly.

You are correct in your rephrasing of what I was asking for here. And you are correct in saying that it ‘isn’t quite a connection’.

> [@](#):
>
> You could probably do what you originally intended by [creating your own UI.](https://auth0.com/docs/universal-login/universal-login-page-customization#custom-user-interface)

👍 I’ll consider looking into this.

> [@](#):
>
> Using a Custom Database to bypass authentication, then redirecting from a rule without resuming does not seem like a viable solution for this. It may work, but you are going to be creating user profiles every time you do this. It is quite a workaround.

Completely agree with you. Putting this esoteric solution up for discussion has helped me understand what is possible and what isn’t, as well as what is appropriate and what isn’t. Thanks again.

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [January 13, 2021, 8:55pm UTC](https://community.auth0.com/t/from-the-universal-login-page-is-it-possible-to-redirect-a-user-with-a-specific-domain-to-an-old-non-auth0-login-page/55908/9 "2021-01-13T20:55:55Z")

</div>

Glad I was able to provide some level of clarity. Let us know if you run into any issues or have other questions.

Thanks!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [January 28, 2021, 8:55pm UTC](https://community.auth0.com/t/from-the-universal-login-page-is-it-possible-to-redirect-a-user-with-a-specific-domain-to-an-old-non-auth0-login-page/55908/10 "2021-01-28T20:55:57Z")

</div>

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