0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-20 21:32:31 -05:00

refactor(core): rename some file names and methods (#6321)

* refactor(core): rename some files name and methods

rename some files name and methods, fix some comments

* chore: update comments

update comments

* chore: update comments

update comments

* chore: polish the words

polish the words
This commit is contained in:
simeng-li 2024-07-25 11:40:12 +08:00 committed by GitHub
parent d7b6987b48
commit 29e9bfce03
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 19 additions and 17 deletions

View file

@ -14,11 +14,11 @@ import {
getNewUserProfileFromVerificationRecord, getNewUserProfileFromVerificationRecord,
identifyUserByVerificationRecord, identifyUserByVerificationRecord,
} from './helpers.js'; } from './helpers.js';
import { MfaValidator } from './libraries/mfa-validator.js';
import { ProfileValidator } from './libraries/profile-validator.js';
import { ProvisionLibrary } from './libraries/provision-library.js';
import { SignInExperienceValidator } from './libraries/sign-in-experience-validator.js';
import { toUserSocialIdentityData } from './utils.js'; import { toUserSocialIdentityData } from './utils.js';
import { MfaValidator } from './validators/mfa-validator.js';
import { ProfileValidator } from './validators/profile-validator.js';
import { ProvisionLibrary } from './validators/provision-library.js';
import { SignInExperienceValidator } from './validators/sign-in-experience-validator.js';
import { import {
buildVerificationRecord, buildVerificationRecord,
verificationRecordDataGuard, verificationRecordDataGuard,
@ -283,7 +283,7 @@ export default class ExperienceInteraction {
// TODO: missing profile fields validation // TODO: missing profile fields validation
if (enterpriseSsoIdentity) { if (enterpriseSsoIdentity) {
await this.provisionLibrary.provisionNewSsoIdentity(user.id, enterpriseSsoIdentity); await this.provisionLibrary.addSsoIdentityToUser(user.id, enterpriseSsoIdentity);
} }
const { provider } = this.tenant; const { provider } = this.tenant;
@ -361,7 +361,7 @@ export default class ExperienceInteraction {
const newProfile = await getNewUserProfileFromVerificationRecord(verificationRecord); const newProfile = await getNewUserProfileFromVerificationRecord(verificationRecord);
await this.profileValidator.guardProfileUniquenessAcrossUsers(newProfile); await this.profileValidator.guardProfileUniquenessAcrossUsers(newProfile);
const user = await this.provisionLibrary.provisionNewUser(newProfile); const user = await this.provisionLibrary.createUser(newProfile);
this.userId = user.id; this.userId = user.id;
} }

View file

@ -43,10 +43,10 @@ export class ProvisionLibrary {
/** /**
* Insert a new user into the Logto database using the provided profile. * Insert a new user into the Logto database using the provided profile.
* *
* - Provision the organization for the new user based on the profile * - Provision all JIT organizations for the user if necessary.
* - OSS only, new user provisioning * - Assign the first user to the admin role and the default tenant organization membership. [OSS only]
*/ */
async provisionNewUser(profile: InteractionProfile) { async createUser(profile: InteractionProfile) {
const { const {
libraries: { libraries: {
users: { generateUserId, insertUser }, users: { generateUserId, insertUser },
@ -89,7 +89,7 @@ export class ProvisionLibrary {
return user; return user;
} }
async provisionNewSsoIdentity( async addSsoIdentityToUser(
userId: string, userId: string,
enterpriseSsoIdentity: Required<InteractionProfile>['enterpriseSsoIdentity'] enterpriseSsoIdentity: Required<InteractionProfile>['enterpriseSsoIdentity']
) { ) {

View file

@ -13,10 +13,10 @@ import type Libraries from '#src/tenants/Libraries.js';
import type Queries from '#src/tenants/Queries.js'; import type Queries from '#src/tenants/Queries.js';
import assertThat from '#src/utils/assert-that.js'; import assertThat from '#src/utils/assert-that.js';
import { PasswordValidator } from '../libraries/password-validator.js';
import { ProfileValidator } from '../libraries/profile-validator.js';
import { SignInExperienceValidator } from '../libraries/sign-in-experience-validator.js';
import { interactionIdentifierToUserProfile } from '../utils.js'; import { interactionIdentifierToUserProfile } from '../utils.js';
import { PasswordValidator } from '../validators/password-validator.js';
import { ProfileValidator } from '../validators/profile-validator.js';
import { SignInExperienceValidator } from '../validators/sign-in-experience-validator.js';
import { type VerificationRecord } from './verification-record.js'; import { type VerificationRecord } from './verification-record.js';

View file

@ -1,13 +1,15 @@
/** /**
* @fileoverview * @fileoverview
* *
* Since `Map` in TS does not support key value type mapping,
* we have to manually define a `setValue` method to ensure correct key will be set
* This class is used to store and manage all the verification records. * This class is used to store and manage all the verification records.
* *
* Extends the Map class and adds a `setValue` method to ensure the key value type mapping. * Since `Map` in TS does not support key - value type mapping,
* we have to manually define a `setValue` method to ensure correct key will be set.
*
* - Extends the Map class and add a `setValue` method to ensure the key value type mapping.
* - Override the `get` method to return the correct value type.
* - Override the `set` method to throw an error to prevent using it directly.
*/ */
import { type VerificationType } from '@logto/schemas'; import { type VerificationType } from '@logto/schemas';
import { type VerificationRecord, type VerificationRecordMap } from './index.js'; import { type VerificationRecord, type VerificationRecordMap } from './index.js';