Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/access-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ function AccessContext(context) {
var token = this.accessToken || {};

if (token.userId) {
this.addPrincipal(Principal.USER, token.userId);
var userPrincipalType =
(this.accessToken && this.accessToken.principalType) || Principal.USER;
Copy link
Member

Choose a reason for hiding this comment

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

I think this can be shortened by using token instead of accessToken?

Also please use const instead of var in new code - see http://loopback.io/doc/en/contrib/style-guide.html#variable-declarations

const userPrincipalType = token.principalType || Principal.USER;

Copy link
Author

Choose a reason for hiding this comment

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

I'll complete the patch soon.

this.addPrincipal(userPrincipalType, token.userId);
Copy link
Member

Choose a reason for hiding this comment

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

@akki-ng

This change looks very reasonable to me 👍 and I am ok with landing it as an incremental improvement.

However, I need you to add a test that fails on the current master, passes with your fix in place - this will verify your fix and prevent regressions in the future.

Copy link
Author

Choose a reason for hiding this comment

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

@bajtos Please follow on #3823

}
if (token.appId) {
this.addPrincipal(Principal.APPLICATION, token.appId);
Expand Down