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

feat(auth): config option for keeping data within redux when logging out #125

Closed
prescottprue opened this Issue May 8, 2017 · 4 comments

Comments

Projects
None yet
2 participants
@prescottprue
Owner

prescottprue commented May 8, 2017

Do you want to request a feature or report a bug?
feature

What is the current behavior?
Every time a user logs out, all data is removed from redux

What is the expected behavior?
Providing the following config will preserve a list of todos when logging out:

NOTE Actual API may be different:

reactReduxFirebase(
fbConfig,
{
  preserveOnLogout: ['todos']
}
)

@TheGhoul21

This comment has been minimized.

Show comment
Hide comment
@TheGhoul21

TheGhoul21 Jun 22, 2017

what about resources that have been loaded and are linked somehow to the status of the user?
let's say you have a list of resources visible from an anon user. BAM! loaded. They're in the store. Then, you login, and BAM more resources are loaded, because you have visibility on them. Then you signout, You should restore the status of the store to a pre-login state I guess. And should the status be specific about the resource paths?
I should make an example maybe:

  1. on page load you see a list of free courses ( courses: dataToJs('courses') let's say)
  2. after you sign-in you see the previous list of courses, with more due to the fact you're signed-in
  3. you logout: you should be able to see the state you were in BEFORE signin in

This should be the correct approach IMHO, what do you think?

TheGhoul21 commented Jun 22, 2017

what about resources that have been loaded and are linked somehow to the status of the user?
let's say you have a list of resources visible from an anon user. BAM! loaded. They're in the store. Then, you login, and BAM more resources are loaded, because you have visibility on them. Then you signout, You should restore the status of the store to a pre-login state I guess. And should the status be specific about the resource paths?
I should make an example maybe:

  1. on page load you see a list of free courses ( courses: dataToJs('courses') let's say)
  2. after you sign-in you see the previous list of courses, with more due to the fact you're signed-in
  3. you logout: you should be able to see the state you were in BEFORE signin in

This should be the correct approach IMHO, what do you think?

@prescottprue

This comment has been minimized.

Show comment
Hide comment
@prescottprue

prescottprue Jun 26, 2017

Owner

@TheGhoul21 That is the plan with the above mentioned API. In your case, you would preserve the list of data that was loaded as an anonymous user.

Even if you queries are at the same path, with different results if you are logged in or out, you could use storeAs, to keep that data in a different place in redux. Then you use the place that you have stored the query done when anonymous in your preserveOnLogout.

Owner

prescottprue commented Jun 26, 2017

@TheGhoul21 That is the plan with the above mentioned API. In your case, you would preserve the list of data that was loaded as an anonymous user.

Even if you queries are at the same path, with different results if you are logged in or out, you could use storeAs, to keep that data in a different place in redux. Then you use the place that you have stored the query done when anonymous in your preserveOnLogout.

prescottprue added a commit that referenced this issue Jun 27, 2017

Tests are no longer skipped from linting.
* - support for keeping data on logout #125

@prescottprue prescottprue added this to the v2.0.0 milestone Jun 30, 2017

@prescottprue prescottprue referenced this issue Jul 3, 2017

Merged

Version v2.0.0 Beta #182

6 of 6 tasks complete

prescottprue added a commit that referenced this issue Jul 4, 2017

Version v2.0.0 Beta (#182)
### Features
* [X] Keeping data on logout - #125
* [X] Listeners now kept on state (follows byId/allIds pattern [from redux docs](http://redux.js.org/docs/recipes/reducers/UpdatingNormalizedData.html))
* [X] `ordered` reducer added for managing ordered state (`SET_ORDERED` no longer used)
* [X] `populate` works for profile (needed to remove share population logic)
* [X] Presence capability added to show currently logged in users and track user sessions (`presence` in config)
* [X]  Firebase is no longer a dependency (build size, native compatibility, bundling for boilerplates, etc.) - #173, #131, #107


### Fixes/Enhancements
* Drop support for passing Firebase instance
* Auto profile population removed (profile population will require using populate)
* `isLoaded` and `isEmpty` logic simplified
* Tests passing with new syntax (including reducers)
* Drop support and deprecation warning for `profileDecorator` (use `profileFactory`)
* Drop support and deprecation warning for `distpatchOnUnsetListener` (use `distpatchOnUnsetListener`, note incorrect spelling)
* Tests no longer skipped from linting
* Tons of other code simplifications
@prescottprue

This comment has been minimized.

Show comment
Hide comment
@prescottprue

prescottprue Jul 4, 2017

Owner

v2.0.0-beta was released and it includes this feature.

More documentation will be coming soon.

Owner

prescottprue commented Jul 4, 2017

v2.0.0-beta was released and it includes this feature.

More documentation will be coming soon.

@prescottprue

This comment has been minimized.

Show comment
Hide comment
@prescottprue

prescottprue Oct 24, 2017

Owner

v2.0.0-beta.12 added support for passing an object to preserve other parts of state.

Owner

prescottprue commented Oct 24, 2017

v2.0.0-beta.12 added support for passing an object to preserve other parts of state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment