Skip to content
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

Client side auth should subscribe to user updates so that app.get('user') is fresh #195

Closed
beevelop opened this Issue May 3, 2016 · 6 comments

Comments

Projects
None yet
3 participants
@beevelop
Copy link
Contributor

beevelop commented May 3, 2016

Using the Socket.io adapter, it would be great to automatically subscribe to the user model's changes to reflect those change for app.get('user').

// Assuming events are filtered appropriately
app.service('users').on('patched', function(user) {
  app.set('user', user);
});

@daffl daffl added the ready label May 18, 2016

@daffl daffl self-assigned this May 18, 2016

@ekryski

This comment has been minimized.

Copy link
Member

ekryski commented May 21, 2016

@beevelop I haven't tried this but is it not already possible? Are you thinking server side or client side or both? With feathers-rx this is made a lot easier.

I guess what I'm looking for is:

  • Can you not do this?
  • What is the use case?

🍻

@ekryski ekryski added Discussion and removed ready labels May 21, 2016

@daffl

This comment has been minimized.

Copy link
Member

daffl commented May 22, 2016

I was briefly looking into this. I think it is a good idea but the client side authentication currently does not know about the user endpoint so it can't hook into the service events.

@ekryski

This comment has been minimized.

Copy link
Member

ekryski commented May 22, 2016

@daffl Can it not assume it's /users or can we get people to provide an endpoint?

@beevelop

This comment has been minimized.

Copy link
Contributor Author

beevelop commented May 24, 2016

@ekryski This feature would be client-side only and is definitely possible. I use this implementation already, but I think it might be more intuitive to get the latest (patched) user data when calling app.get('user') by default or by specifying this behavior explicitly when registering feathers-authentication in the frontend.

@daffl: Wouldn't a configuration option to specify the user endpoint not meet this problem? You could simply default to /users.

@ekryski ekryski added this to the 1.0 milestone Aug 9, 2016

@ekryski ekryski changed the title Subscribe to user updates Client side auth should subscribe to user updates so that app.get('user') is fresh Aug 9, 2016

@ekryski

This comment has been minimized.

Copy link
Member

ekryski commented Aug 9, 2016

I agree. The one thing we'll have to consider is potentially passing a user service, not just an endpoint so that you can potentially be getting user updates from a completely separate backend service, not necessarily the same one as you are authenticating with.

@daffl daffl modified the milestones: 0.8, 1.0 Sep 2, 2016

@ekryski

This comment has been minimized.

Copy link
Member

ekryski commented Oct 26, 2016

This is going to be left up to the developer because we can't assume that every app will have a user. Therefore:

  • we don't want to add more configuration options to enable such functionality on the client at this point.
  • and we don't want to be registering socket listeners unnecessarily.

@ekryski ekryski closed this Oct 26, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.