feat: Add scopes to /login endpoint (no-changelog) (#7718)

Github issue / Community forum post (link here to close automatically):
This commit is contained in:
Val
2023-11-16 11:11:55 +00:00
committed by GitHub
parent ebee1a5908
commit d39bb2540f
9 changed files with 158 additions and 15 deletions

View File

@@ -113,7 +113,10 @@ export class UserService {
return user;
}
async toPublic(user: User, options?: { withInviteUrl?: boolean; posthog?: PostHogClient }) {
async toPublic(
user: User,
options?: { withInviteUrl?: boolean; posthog?: PostHogClient; withScopes?: boolean },
) {
const { password, updatedAt, apiKey, authIdentities, ...rest } = user;
const ldapIdentity = authIdentities?.find((i) => i.providerType === 'ldap');
@@ -124,6 +127,10 @@ export class UserService {
hasRecoveryCodesLeft: !!user.mfaRecoveryCodes?.length,
};
if (options?.withScopes) {
publicUser.globalScopes = user.globalScopes;
}
if (options?.withInviteUrl && publicUser.isPending) {
publicUser = this.addInviteUrl(publicUser, user.id);
}