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

Pass current loopback user id into credentials functions #2

Conversation

alexkolson
Copy link
Contributor

This would greatly aid me in a current use case I have where Im storing the
actual credentials in redis and I look them up by user id. Or rather, I would
like to be able to look them up by user id but in order to do that I need to have
access to the current user id in the credentials functions.

This would greatly aid me in a current use case I have where Im storing the
actual credentials in redis and I look them up by user id. Or rather, I would
like to be able to look them up by user id but in order to do that I need to have
access to the current user id in the credentials functions.
@alexkolson
Copy link
Contributor Author

Any thoughts @benkroeger?

Copy link
Owner

@benkroeger benkroeger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these look like breaking changes. did you inspect the credentials object? if it is the credentials instance from loopback model (loopback-component-passport) then it should have a userId property (created from the credentials belongsTo User relation

@benkroeger
Copy link
Owner

also, is this maybe something that should better be done somewhere on the auth-provider level? If we're going for a breaking change, we might as well do it right?!

@alexkolson
Copy link
Contributor Author

Agreed about that an auth provider is maybe the better place for this.

As far as the credentials object goes, I thought I tried to grab userId and it wasn't there but I will try again. 😄

@alexkolson
Copy link
Contributor Author

@benkroeger

Ok so further inspection reveals that you can pretty much put whatever you want in the credentials and it is up to each individual auth scheme what exactly is in there.

So now I am thinking that maybe we don't need to introduce such a breaking change here in this package and instead i can use makeVerifyFunction() to plant a dummy credentials object that just has userId in it.

@alexkolson alexkolson closed this Nov 2, 2017
@alexkolson alexkolson deleted the pass-user-id-to-credentials-functions branch November 2, 2017 14:22
@alexkolson
Copy link
Contributor Author

Hmm...this has to take place in a request context in order to have userId and I keep forgetting that.

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

Successfully merging this pull request may close these issues.

None yet

2 participants