bernabe9 / redux-react-session

:key: Simple Session API storage for Redux and React
https://bernabe9.github.io/redux-react-session/
147 stars 41 forks source link

Token validation on initSessionService #13

Closed kascote closed 6 years ago

kascote commented 7 years ago

When the page reload, initSessionService reload the token from the configured storage. But I need to validate the token. May be have some user defined promise to use on refreshFromLocalStorage before dispatch the getUserSessionX action.

Or there is another way to do it ?

ps: I'm not using SSR

bernabe9 commented 7 years ago

Do you want something like this?

const validateSession = (session) => {
  ... // code to validate the session token
  // returns a boolean (true if is valid or false otherwise)
}

sessionService.initSessionService(store, { validateSession });

If the session doesn't pass the validation then the session will be destroyed.

kascote commented 7 years ago

yeah!... if the function could be a promise better!

I imagine that checked will be false while try to validate and true after done, and authenticated will be true or false depending of the response.. make sense ?

bernabe9 commented 7 years ago

Understood! It looks like a great feature! Thanks for come up with this, I'll definitely work on it.

alduro commented 6 years ago

Any news on this ? I'm facing this issue as well. Thanks !

bernabe9 commented 6 years ago

@alduro was just added in version v2.4.0