oidc-react icon indicating copy to clipboard operation
oidc-react copied to clipboard

Redirect to original URL after signin (deep linking)

Open elliotgonzalez-lk opened this issue 3 years ago • 2 comments

Hello! I am migrating from a now deprecated oidc client library to this one, and everything has gone smoothly. However, I cannot figure out how to redirect the user to the original URL after signin. I apologize if I am missing something terribly obvious, but I cannot figure this out.

Logged out user pastes http://localhost:3000/blog/1 into the browser URL bar -> They are redirected to the IDP signin page -> Enter username and password -> authenticated -> redirected to the / route instead of http://localhost:3000/blog/1

  • I see the state param key appended to the URL during the callback.
  • The state key on userData is always undefined. Any attempt to update this value does not work due to it being readonly.
  • Trying to run window.history.replaceState() in the onSignin callback does nothing.

Does the library do anything with that state param? Is there any way to implement deep linking? Would you be able to point me to any examples of this working? I would greatly appreciate it. Thanks.

elliotgonzalez-lk avatar Aug 19 '22 15:08 elliotgonzalez-lk

Never used it myself, but I was looking to see if support for this functionality was provided too. I think it's a case of DIY using the onBeforeSignin and onSignin hooks. https://github.com/bjerkio/oidc-react/blob/main/docs/interfaces/authcontextinterface.authproviderprops.md#onbeforesignin

horizondave avatar Sep 13 '22 16:09 horizondave

@elliotgonzalez-lk any luck with this issue?

laurakutovaja avatar Sep 28 '22 12:09 laurakutovaja

Seems that @laurakutovaja fixed this! Maybe this issue should be closed?

forforfos avatar Oct 19 '22 09:10 forforfos

fixed by #910

braaar avatar Oct 20 '22 12:10 braaar

When will https://github.com/bjerkio/oidc-react/pull/910 be released? I need this fix

AlexanderKositsyn avatar Oct 21 '22 14:10 AlexanderKositsyn