-
Notifications
You must be signed in to change notification settings - Fork 241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failing to redirect to protected route #85
Comments
@williamgranli what do you mean in the examples authData is a string? In the README and examples, authData (the result of applying |
I see... thanks for the help @mjrussell . I managed to solve the login part (so far so good at least) Right now I'm getting into an infinite redirect loop between the route I'm at and /login whenever I logout however. |
If you can post snippets of your versions of react-router-redux (if using), react router, and redux-auth-wrapper as well as route setup, HOCs and store config I might be able to help see something. Originally I got an email about this issue that said you were using react-boilerplate (seems you've either deleted or edited the original text). Did you look at #40 ? |
@mjrussell: I edited the original issue. A lot of code incoming. I'm guessing you're quite familiar with the type of setup since most of it is copied from #40 . /app/routes.js:
/app/containers/HomePage/index.js
/app/containers/components/Loginpage/index.js
/app/containers/LogoutForm/index.js
Whatever is in the User component is copied from your example (actions, selector and reducer). Let me know if there's anything else you need. Thanks!! |
@mjrussell this solved the redirect loop for me: In LoginPage/index:
So, for some reason the logout sets the user object to {} which didn't trigger the evaluations in above methods... Not sure if I did something wrong which made that happen. |
Glad its working for you. You can use an auth wrapper to protect Login also. In your case, you are essentially rewriting the auth wrapper for login. See the loading example for an example of how to do this. Regarding the user object to |
This is how my actions and reducer look:
Gotta say this lib is really neat now that I'm getting the hang of it! Going to try the loading example you mentioned soon hopefully as well! Just managed to fix the bug with the sagas as well... was related to the webpack settings for react-boilerplate! |
Here's that code right there -
|
Ah, makes sense. You do it in both the basic and localStorage examples too, think I just copied it from there. Is that intended? |
Its up to you how you want to set up your user reducer. The example is trying to be as simple as possible to explain the concepts. The wrapper by default has the predicate (to check if authenticated) see if the user object has data or if it is empty/null. But that can be easily overridden if you have a different structure. |
@williamgranli can this be closed now? |
Yeah! Thanks for your help. |
I'm getting this error for some reason... In all the examples authData is a string.
warning.js:36 Warning: Failed prop type: Invalid prop
authData
of typestring
supplied toUserIsAuthenticated(Connect(Foo))
, expectedobject
.in UserIsAuthenticated(Connect(Foo)) (created by Connect(UserIsAuthenticated(Connect(Foo))))
in Connect(UserIsAuthenticated(Connect(Foo))) (created by RouterContext)
in div (created by App)
in App (created by RouterContext)
in RouterContext (created by Router)
in ScrollBehaviorContainer (created by Router)
in Router
in IntlProvider (created by LanguageProvider)
in LanguageProvider (created by Connect(LanguageProvider))
in Connect(LanguageProvider)
in Provider
The text was updated successfully, but these errors were encountered: