okta / samples-js-react

React Auth SDK sample
Other
175 stars 260 forks source link

Redirecting from login #41

Closed mbychkowski closed 6 years ago

mbychkowski commented 6 years ago

I have recreated this example for a React application on the okta docs.

Example Repo: https://github.com/mbychkowski/okta-example

When I am logged out and access the protected link I get directed to the login form and then redirected to the protected page. This works as I expect it to.

However, when I am logged out and try to access the login link I get directed again to the login form, but fail to redirect me to the protected page root page. Instead I receive this in the URL "http://localhost:3000/implicit/[object%20Object]". I have verified that I am logged in, however just not redirected after authentication.

Any ideas why this might be happening? Is there a solution?

bdemers commented 6 years ago

Hey @mbychkowski,

Have you tried the examples in this repository? Take a look at the custom-login example if you want to host the login page, or if you want the standard OAuth redirect take a look at okta-hosted-login

cc: @robertjd

mbychkowski commented 6 years ago

@bdemers thanks for the response. The custom-login helped.

One reason, I was following the example I linked earlier, was that it allowed for me to create a custom form, where as this example uses the Okta Sign-in Widget.

slathamKG commented 6 years ago

@mbychkowski - I'm having the exact same issue. What exactly was your solution?

mbychkowski commented 6 years ago

@slkg

I ended up following this EXAMPLE to create a custom form without the Okta Sign-in Widget.

slathamKG commented 6 years ago

Thanks Mike. My solution was as follows (I'm still not quite sure why it worked, but it did):

I had a login button rendered thusly: <button className="btn btn-primary" onClick={this.props.auth.login}>Login</button>. Changing it to a regular link to /login did the trick.