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

fix: using a few openIds for user #344

Merged
merged 2 commits into from
Dec 22, 2021
Merged
Changes from 1 commit
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
15 changes: 11 additions & 4 deletions registry/server/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,17 @@ export default (app: Express, settingsService: SettingsService, config: any): Re
identifiers = [identifiers];
}

let user: any;
let user: User | null = null;
for (let id of identifiers) {
user = await getEntityWithCreds('openid', id, null);
if (user) {
const entity = await getEntityWithCreds('openid', id, null);
if (!entity) {
continue;
}

user = entity;

// can be case when user exists in a few openIds, so we try find admin's role
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// can be case when user exists in a few openIds, so we try find admin's role
// we may have case when user exists for a few identifiers, so we try find the most permissive role

if (entity.role === AuthRoles.admin) {
break;
}
}
Expand All @@ -157,7 +164,7 @@ export default (app: Express, settingsService: SettingsService, config: any): Re
return done(null, false, { message: `Can\'t find presented identifiers "${identifiers.toString()}" in auth entities list` });
}
if (uidClaimName && claims[uidClaimName]) {
user.identifier = claims[uidClaimName];
user.identifier = claims[uidClaimName] as string;
}

return done(null, user);
Expand Down