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

Logging in with a custom auth strategy results in undefined user in connection in channels.ts #3475

Open
jordandenison opened this issue Apr 26, 2024 · 1 comment

Comments

@jordandenison
Copy link

Steps to reproduce

Steps to reproduce can be found in the index.ts at this repo/branch:

https://github.com/jordandenison/feathers-local/tree/service-authentication-issues

Expected behavior

On login event in channels.ts, connection object should have the user data returned from the custom service

Actual behavior

Connection object user is undefined

System configuration

Module versions (especially the part that's not working):

NodeJS version: 20.9

Operating System: alpine

@hungrymike
Copy link

There are definitely some breaking changes from v4 -> v5 regarding this, we've been dealing with something similar - since we also have custom auth on most of our projects. When you set "entity": null in the config, the connection will have null: undefined, doesn't matter if you return user or entity.

There is a quick fix for it, on app.on('login') event you'll have access to the auth result so you can add it to the connection manually, ex connection.user = authenticationResult.authentication.payload.user; That would be line 7 in your channels.ts.

Hope that helps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants