Repository navigation
feat(embedded): add signup support for email and phone identifer - #1123
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
| return identifiers.ifEmpty { null } | ||
| } | ||
|
|
||
| private val SIGNUP_IDENTIFIER_TYPES: List<Pair<String, IdentifierType>> = listOf( |
There was a problem hiding this comment.
The design doc lists IdentifierType(Email | Phone | Username) for signup, but the mapper only reads email and phone_number.Is username signup out of scope?
There was a problem hiding this comment.
Yes. User name support is not added at the moment and will be added in the alter phase
| } | ||
|
|
||
| @Test | ||
| public fun `authorize continuation ignores signup identifiers the SDK does not model`(): Unit = runTest { |
There was a problem hiding this comment.
ignores signup identifiers the SDK does not model uses username as its example, but the SDK does model USERNAME. Please use a made-up key (for example foo) and add a separate test for username.
There was a problem hiding this comment.
This is added with the idea that we only support email | phone for the current release. I will remove username from the identifier type to avoid confusion
| private fun Map<*, *>.toSignupIdentifiers(): List<SignupIdentifier>? { | ||
| val identifiers = SIGNUP_IDENTIFIER_TYPES.mapNotNull { (key, type) -> | ||
| if (!containsKey(key)) return@mapNotNull null | ||
| val required = (this[key] as? Map<*, *>)?.get(REQUIRED_KEY) as? Boolean ?: return null |
There was a problem hiding this comment.
If any identifier is missing required, return null drops the entire Signup action, so the user loses the signup option completely. is it intended here?
There was a problem hiding this comment.
Fixed to drop only the malformed types
|
|
||
| // 1. Start the flow. When the connection allows sign-ups, the next actions include NextAction.Signup. | ||
| try { | ||
| embedded.authorize("Username-Password-Authentication").await() |
There was a problem hiding this comment.
This is a passwordless email/phone OTP signup, but the sample connection is Username-Password-Authentication. Please use the connection type this flow actually needs, or add a line explaining which connection setup is required.
There was a problem hiding this comment.
This is passwordless for DB connection. this is correct
| } catch (e: EmbeddedAuthException) { | ||
| when (val error = e.error) { | ||
| is EmbeddedAuthError.InsufficientAuthorization -> { | ||
| if (error.reason == EmbeddedAuthError.InsufficientAuthorization.Reason.INVALID_IDENTIFIER_OR_CODE) { |
There was a problem hiding this comment.
The example only checks INVALID_IDENTIFIER_OR_CODE. A wrong code can also come back as INVALID_CODE, so please handle both, as authorize.md does.
There was a problem hiding this comment.
Added the check for INVALID_CODE too
| assertThat(error.code, `is`("no_active_session")) | ||
| } | ||
|
|
||
| // ── signup / confirmSignup ────────────────────────────────────────────────── |
There was a problem hiding this comment.
All the new tests use await(). Please add at least one start(callback) test for confirmSignup, covering success and failure. The callback path in AdvancingRequest is a separate code path.
There was a problem hiding this comment.
Intentionally skipped callback one. await() internally uses the callback APIs . Its just duplicating tests with no actual benefit
Changes
Adds embedded signup to the
/e/authorizeflow: a new user creates a passwordless account by verifying an email address or phone number with a one-time code.Public API added
EmbeddedAuthClient.signup(): Request<Void?, EmbeddedAuthException>starts signup (action:signup:v1). It always continues with the identify step.EmbeddedAuthClient.confirmSignup(): Request<Credentials, EmbeddedAuthException>creates the account (action:signup:confirm:v1). It is terminal: it exchanges the code and returnsCredentials, or continues with MFA if the tenant requires it.EmbeddedCapability.SIGNUPandEmbeddedCapability.CONFIRM_SIGNUPare added toDEFAULT_CAPABILITIES.NextAction.Signup(identifiers: List<SignupIdentifier>)andNextAction.ConfirmSignup.SignupIdentifier(type: IdentifierType, required: Boolean)is read from the OASidentifiersobject (email,phone_number). Identifier keys the SDK doesn't model are ignored. ASignupaction is dropped ifidentifiersis missing or empty, or if an entry has norequiredflag.Errors. No new error types. Signup errors map to existing ones:
Testing
This change adds unit test coverage
This change adds integration test coverage
This change has been tested on the latest version of the platform/language or why not
Checklist
I have read the Auth0 general contribution guidelines
I have read the Auth0 Code of Conduct
All existing and new tests complete without errors