Routing too quickly?
# support-questions-legacy
c
Routing too quickly?
Copy code
getRedirectionURL: async (context) => {
    if (context.action === 'SUCCESS') {
      if (context.redirectToPath !== undefined) {
        return context.redirectToPath;
      }
      if (localStorage.getItem('lang') === 'en-US') {
        toast.success('Welcome back!', {
          position: toast.POSITION.BOTTOM_RIGHT,
        });
        return '/home';
      } else if (localStorage.getItem('lang') === 'zh') {
        toast.success('欒迎!', {
          position: toast.POSITION.BOTTOM_RIGHT,
        });
        return '/zh/home';
      }
    }
    return undefined;
  },
}
I am using the above code to redirect the user to /home upon logging in
When the user logs in I also want to notify the user with a toast
The problem with the above function is that it works for Google login but not emailpassword login. When I say that, what I mean is when I use Google login, everything works fine. But when I use emailpassword, the toast get automatically dismissed.
I was managed to work around that by adding a timeout to the toast.success function. But I was wondering... why does it do that? Does Google login and emailpassword login have different redirection functions? They do both get into "getRedirectionURL" though (I tested it)
p
hi
I'll check this out in more detail tomorrow but it should be the same.
no full page navigation occurs, right?
c
Not sure what you mean?
Upon logging in, since I am using nextjs, I have it redirected to /home without refreshing the page
Copy code
windowHandler: (oI) => {
      return {
        ...oI,
        location: {
          ...oI.location,
          setHref: (href) => {
            Router.push(href);
          },
        },
      };
    },
By doing that in frontendConfig
the toast package that I am using is this
p
well I was curious about how you handle redirection and if the whole page reloads when you get redirected after logging in.
but the you answered it anyway πŸ™‚
everything should be the same between thirdparty and email password success redirections
if you have a repro I'm happy to check it out or I'll look into it a bit more tomorrow
c
Please let me know once you have looked into it πŸ™‚
p
As far as I can see they are the same, do you have a repo (or any other reproduction of the issue) I could look at?
c
I dont have one that I can share right now, I will try to figure out the issue
2 Views