-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix access-token invalidation for missing relation #3227
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
Conversation
Fix the code invalidating access tokens on user email/password changes to correctly handle the case when the relation "AccessToken belongs to (subclassed) user" is not configured.
|
👍 |
raymondfeng
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
superkhau
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nit about the comment/assertion, otherwise LGTM.
| .then(u => { | ||
| u.email = 'updated@example.com'; | ||
| return u.save(); | ||
| // the test passes when save() does not throw any error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should use two arg style: http://loopback.io//doc/en/contrib/style-guide.html#asserting-a-rejected-promise
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You wrote the style guide entry though so you would know better. ;) What I'm suggesting is we should have something that catches and calls expect.fail() instead of the comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I'm suggesting is we should have something that catches and calls expect.fail() instead of the comment.
By calling expect.fail, the test would hide the original error and report an unhelpful failure.
Note that we are asserting a resolved promise here, not a rejected promise as is described in the style guide link you pasted.
I suppose I could rewrite this test as follows, would you find it easier to read?
.then(u => {
u.email = 'updated@example.com';
return u.save();
})
.then(u => {
// the test passes when save() does not throw any error
});There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit better, but not worth the effort. LGTM. ;)
|
Good work on addressing this, @bajtos! As far as this PR goes, I've tested this branch in my sample repo and another Loopback project of mine, in both cases the app is no longer crashing and the issue raised is resolved. I'm going to add some more discussions though to the original ticket as I want to clarify a few points on best practices. |
|
@ebarault @raymondfeng @superkhau thank you for the review! @greaterweb thank you for verifying my fix in your codebase. Let's get it landed to address the immediate problem and then continue the discussion in the original issue. |
|
Released in |
It's not your patch that break the relation, it's the application that did not correctly configure this relation. Your patch was just not prepared to handle such misconfiguration, which I fixed here. |
Description
Fix the code invalidating access tokens on user email/password changes to correctly handle the case when the relation "AccessToken belongs to (subclassed) user" is not configured.
cc @ebarault @greaterweb
Related issues
Checklist
guide