-
Notifications
You must be signed in to change notification settings - Fork 3
Add updates to client trust #435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
source/ui/src/main/java/com/clerk/ui/signin/clienttrust/SignInClientTrustView.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| package com.clerk.ui.signin.clienttrust | ||
|
|
||
| import androidx.compose.foundation.layout.padding | ||
| import androidx.compose.material3.Text | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.res.stringResource | ||
| import androidx.compose.ui.text.style.TextAlign | ||
| import androidx.compose.ui.tooling.preview.PreviewLightDark | ||
| import com.clerk.api.network.model.factor.Factor | ||
| import com.clerk.api.ui.ClerkTheme | ||
| import com.clerk.ui.R | ||
| import com.clerk.ui.auth.PreviewAuthStateProvider | ||
| import com.clerk.ui.core.common.StrategyKeys | ||
| import com.clerk.ui.core.dimens.dp16 | ||
| import com.clerk.ui.signin.code.SignInFactorCodeView | ||
| import com.clerk.ui.signin.help.SignInGetHelpView | ||
| import com.clerk.ui.theme.ClerkMaterialTheme | ||
| import com.clerk.ui.theme.ClerkThemeOverrideProvider | ||
|
|
||
| /** | ||
| * A composable that displays the client trust verification view. | ||
| * | ||
| * This view is shown when the user is signing in from a new or untrusted device and needs to | ||
| * complete an additional verification step. It displays a warning message explaining why | ||
| * verification is needed, followed by the code input for verification. | ||
| * | ||
| * Based on the `strategy` of the provided [factor], this composable will delegate rendering to | ||
| * [SignInFactorCodeView] for phone code or email code verification, or [SignInGetHelpView] for | ||
| * unsupported strategies. | ||
| * | ||
| * @param factor The factor to be verified for client trust. | ||
| * @param modifier The [Modifier] to be applied to the view. | ||
| * @param clerkTheme Optional theme override for customization. | ||
| * @param onAuthComplete Callback invoked when authentication is complete. | ||
| */ | ||
| @Composable | ||
| fun SignInClientTrustView( | ||
| factor: Factor, | ||
| modifier: Modifier = Modifier, | ||
| clerkTheme: ClerkTheme? = null, | ||
| onAuthComplete: () -> Unit, | ||
| ) { | ||
| ClerkThemeOverrideProvider(clerkTheme) { | ||
| when (factor.strategy) { | ||
| StrategyKeys.PHONE_CODE, | ||
| StrategyKeys.EMAIL_CODE -> | ||
| SignInFactorCodeView( | ||
| factor = factor, | ||
| isSecondFactor = true, | ||
| isClientTrust = true, | ||
| modifier = modifier, | ||
| onAuthComplete = onAuthComplete, | ||
| ) | ||
| else -> SignInGetHelpView(modifier = modifier) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * A composable that displays a warning message for client trust verification. | ||
| * | ||
| * This message informs the user that they are signing in from a new device and explains why | ||
| * additional verification is being requested. | ||
| */ | ||
| @Composable | ||
| internal fun ClientTrustWarningMessage(modifier: Modifier = Modifier) { | ||
| Text( | ||
| text = stringResource(R.string.signing_in_from_new_device), | ||
| color = ClerkMaterialTheme.colors.warning, | ||
| style = ClerkMaterialTheme.typography.bodySmall, | ||
| textAlign = TextAlign.Center, | ||
| modifier = modifier.padding(bottom = dp16), | ||
| ) | ||
| } | ||
|
|
||
| @PreviewLightDark | ||
| @Composable | ||
| private fun Preview() { | ||
| PreviewAuthStateProvider { | ||
| SignInClientTrustView( | ||
| factor = Factor(StrategyKeys.EMAIL_CODE, safeIdentifier = "[email protected]"), | ||
| onAuthComplete = {}, | ||
| ) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
Add tests for the new NEEDS_CLIENT_TRUST status.
The enum addition looks correct, but no tests were included in this review. Please add tests to verify:
🤖 Prompt for AI Agents