Skip to content

Commit

Permalink
fix: user role assign (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
nnorbert authored Jun 18, 2024
1 parent 4499d54 commit 4186c62
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions packages/core/src/libraries/ogcio-user.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { consoleLog } from '@logto/cli/lib/utils.js';
import phrases from '@logto/phrases';
import {
type CreateUsersRole,
type Role,
Expand Down Expand Up @@ -152,25 +153,22 @@ export const manageDefaultUserRole = async (
return;
}

assertThat(Boolean(user.primaryEmail), 'user.email_not_exist');

if (user.primaryEmail === null) {
consoleLog.error(phrases.en.errors.user.email_not_exist);
return;
}

const domain = getDomainFromEmail(user.primaryEmail);

assertThat(Boolean(domain), 'user.invalid_email');

if (domain === undefined) {
consoleLog.error(phrases.en.errors.user.invalid_email);
return;
}

const userRole = await getUserRoleByDomain(domain, getRoles);

assertThat(Boolean(userRole), 'role.default_role_missing');

if (userRole === undefined) {
consoleLog.error(phrases.en.errors.role.default_role_missing);
return;
}

Expand Down

0 comments on commit 4186c62

Please sign in to comment.