Oauth BeforeLogin hook redirects to `Already Logged In`

default discord avatar
adam-mrozik
10 months ago
1 1

Hey!

I am not that sure if this is a bug on the side of plugin code or payload, but maybe you will have some hints.

In the plugin code, after successful oAuth I setToken from useAuth hook and then I use useNavigate to navigate to admin page.

What I get is the screen below:
image

clicking Back to Dashboard works okay, so I am logged in and whole process was successful. However, for some reason the initial redirect kind of recognizes that I am logged in, but still implies that I am trying to do that again.

If you have an idea if this might me my plugin-specific behaviour, or some Payload feature clashing with the hook, I would be very keen to get any type of feedback!

  • discord user avatar
    DanRibbens
    Payload Team
    7 months ago

    Were you able to figure out what was going on in your plugin? I don't think it is a Payload specific issue.

    What you might be up against is that the user object isn't being updated in Payload. There isn't method on the auth provider to do this. I think what typically would happen is that you have a full redirect or page load to update the user coming from the 3rd party auth provider.

    I hope that helps!

    1 reply
  • default discord avatar
    adam-mrozik
    7 months ago

    @DanRibbens , partially - i just workaround it by reloading the page after successful login , which seems to work ok enough.

Open the post
Continue the discussion in GitHub
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.