logto-io / logto

🧑‍🚀 The better identity infrastructure for developers and the open-source alternative to Auth0.
https://logto.io
Mozilla Public License 2.0
8.15k stars 395 forks source link

feat(core,schemas): implement the register flow #6237

Closed simeng-li closed 1 month ago

simeng-li commented 1 month ago

Summary

This PR includes the following updates:

  1. Define a new abstract class IdentifierVerificationRecord, extending the root VerificationRecord abstract class. This class defines an extra identifyUser method. All the verification records used to identify a user are considered an IdentifierVerificationRecord. An identifyUser method must be implemented properly.

  2. Defines the interaction profile type and guard.

  3. Implement the toUserProfile methods in the VerificationCode, SocialVerification, and SsoVerirification classes. This method will be used to convert the verified verification record to a new user profile, for new user registration and profile fulfillment use.

  4. Implement a ProfileValidator class. This library class will be used to guard and validate new users and newly added profile fields. Including guardProfileUniquenessAcrossUsers and upcoming guardUserExistingProfiles.

  5. Update the createNewUser method in the ExperienceInteraction. Implement the new user creation flow. Retrieve the new user identifier profile from the given verification record, and create a new user in DB.

Testing

The integration test will be placed into a separate PR to avoid a large PR size.

Checklist

github-actions[bot] commented 1 month ago

COMPARE TO master

Total Size Diff :warning: :chart_with_upwards_trend: +10.42 KB

Diff by File |Name|Diff| |---|---| |packages/core/src/routes/experience/classes/experience-interaction.ts|:chart_with_upwards_trend: +1.67 KB| |packages/core/src/routes/experience/classes/utils.ts|:chart_with_upwards_trend: +1.5 KB| |packages/core/src/routes/experience/classes/validators/profile-validator.ts|:chart_with_upwards_trend: +2.17 KB| |packages/core/src/routes/experience/classes/verifications/code-verification.ts|:chart_with_upwards_trend: +196 Bytes| |packages/core/src/routes/experience/classes/verifications/enterprise-sso-verification.ts|:chart_with_upwards_trend: +1.48 KB| |packages/core/src/routes/experience/classes/verifications/password-verification.ts|:chart_with_upwards_trend: +74 Bytes| |packages/core/src/routes/experience/classes/verifications/social-verification.ts|:chart_with_upwards_trend: +1.53 KB| |packages/core/src/routes/experience/classes/verifications/verification-record.ts|:chart_with_upwards_trend: +590 Bytes| |packages/core/src/routes/experience/index.ts|:chart_with_upwards_trend: +15 Bytes| |packages/core/src/routes/experience/types.ts|:chart_with_upwards_trend: +1.21 KB|
simeng-li commented 1 month ago

Overall LGTM, the description is confusing, it should be extending the root VerificationRecord?

Correct, fixed.