Skip to content

Commit 563ce3f

Browse files
authored
Merge pull request #149 from android/minor_bug_fixes
Renamed registration functions to be more accurate and fixed string typo in registration
2 parents 9e4b062 + 755679a commit 563ce3f

File tree

4 files changed

+26
-24
lines changed

4 files changed

+26
-24
lines changed

Shrine/app/src/main/java/com/authentication/shrine/CredentialManagerUtils.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,15 @@ class CredentialManagerUtils @Inject constructor(
4949
) {
5050

5151
/**
52-
* Retrieves a passkey from the credential manager.
52+
* Retrieves a passkey or password from the credential manager.
5353
*
54-
* @param creationResult The result of the passkey creation operation.
54+
* @param publicKeyCredentialRequestOptions The public key credential request options.
5555
* @param context The activity context from the Composable, to be used in Credential Manager APIs
56-
* @return The [GetCredentialResponse] object containing the passkey, or null if an error occurred.
56+
* @return The [GetCredentialResponse] object containing the passkey or password, or null if an
57+
* error occurred.
5758
*/
58-
suspend fun getPasskey(
59-
creationResult: JSONObject,
59+
suspend fun getPasskeyOrPassword(
60+
publicKeyCredentialRequestOptions: JSONObject,
6061
context: Context,
6162
): GenericCredentialManagerResponse {
6263
val passkeysEligibility = PasskeysEligibility.isPasskeySupported(context)
@@ -69,7 +70,7 @@ class CredentialManagerUtils @Inject constructor(
6970
val credentialRequest = GetCredentialRequest(
7071
listOf(
7172
GetPublicKeyCredentialOption(
72-
creationResult.toString(),
73+
publicKeyCredentialRequestOptions.toString(),
7374
null,
7475
),
7576
GetPasswordOption(),

Shrine/app/src/main/java/com/authentication/shrine/ui/AuthenticationScreen.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,14 @@ fun AuthenticationScreen(
8484
)
8585
}
8686

87-
val onSignInWithPasskeysRequest = {
87+
val onSignInRequest = {
8888
viewModel.signInWithPasskeysRequest(
8989
onSuccess = { flag ->
9090
createRestoreKey()
9191
navigateToHome(flag)
9292
},
9393
getPasskey = { jsonObject ->
94-
credentialManagerUtils.getPasskey(
94+
credentialManagerUtils.getPasskeyOrPassword(
9595
context = context,
9696
creationResult = jsonObject,
9797
)
@@ -112,7 +112,7 @@ fun AuthenticationScreen(
112112
}
113113

114114
AuthenticationScreen(
115-
onSignInWithPasskeysRequest = onSignInWithPasskeysRequest,
115+
onSignInRequest = onSignInRequest,
116116
navigateToRegister = navigateToRegister,
117117
showErrorDialog = errorDialogViewModel::showErrorDialog,
118118
uiState = uiState,
@@ -126,14 +126,14 @@ fun AuthenticationScreen(
126126
* This screen allows the user to authenticate using a username and password, or through passkeys.
127127
*
128128
* @param modifier Modifier to be applied to the composable.
129-
* @param onSignInWithPasskeysRequest Callback to initiate the sign-in with passkeys request.
129+
* @param onSignInRequest Callback to initiate the sign-in with passkeys or password request.
130130
* @param showErrorDialog Method that resets the UI state of the Error Dialog
131131
* @param navigateToRegister Callback to navigate to the registration screen.
132132
* @param uiState The current UI state of the authentication screen.
133133
*/
134134
@Composable
135135
fun AuthenticationScreen(
136-
onSignInWithPasskeysRequest: () -> Unit,
136+
onSignInRequest: () -> Unit,
137137
navigateToRegister: () -> Unit,
138138
showErrorDialog: () -> Unit,
139139
uiState: AuthenticationUiState,
@@ -159,7 +159,7 @@ fun AuthenticationScreen(
159159

160160
// Sign In Button
161161
ShrineButton(
162-
onClick = onSignInWithPasskeysRequest,
162+
onClick = onSignInRequest,
163163
buttonText = stringResource(id = R.string.sign_in),
164164
isButtonEnabled = !uiState.isLoading,
165165
)
@@ -209,7 +209,7 @@ fun AuthenticationScreen(
209209
fun AuthenticationScreenPreview() {
210210
ShrineTheme {
211211
AuthenticationScreen(
212-
onSignInWithPasskeysRequest = { },
212+
onSignInRequest = { },
213213
navigateToRegister = { },
214214
showErrorDialog = { },
215215
uiState = AuthenticationUiState(),

Shrine/app/src/main/java/com/authentication/shrine/ui/RegisterScreen.kt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ import com.authentication.shrine.ui.viewmodel.RegistrationViewModel
8080
fun RegisterScreen(
8181
navigateToHome: (isSignInThroughPasskeys: Boolean) -> Unit,
8282
onLearnMoreClicked: () -> Unit,
83-
onOtherWaysToSignInClicked: () -> Unit,
83+
onOtherWaysToSignUpClicked: () -> Unit,
8484
onBackClicked: () -> Unit,
8585
viewModel: RegistrationViewModel,
8686
modifier: Modifier = Modifier,
@@ -124,7 +124,7 @@ fun RegisterScreen(
124124
fullName = fullName,
125125
onFullNameChanged = { fullName = it },
126126
onLearnMoreClicked = onLearnMoreClicked,
127-
onOtherWaysToSignInClicked = onOtherWaysToSignInClicked,
127+
onOtherWaysToSignUpClicked = onOtherWaysToSignUpClicked,
128128
onBackClicked = onBackClicked,
129129
email = email,
130130
onEmailChanged = { email = it },
@@ -151,7 +151,7 @@ fun RegisterScreen(
151151
fullName: String,
152152
onFullNameChanged: (String) -> Unit,
153153
onLearnMoreClicked: () -> Unit,
154-
onOtherWaysToSignInClicked: () -> Unit,
154+
onOtherWaysToSignUpClicked: () -> Unit,
155155
onBackClicked: () -> Unit,
156156
email: String,
157157
onEmailChanged: (String) -> Unit,
@@ -187,7 +187,7 @@ fun RegisterScreen(
187187
fullName = fullName,
188188
onFullNameChanged = onFullNameChanged,
189189
onLearnMoreClicked = onLearnMoreClicked,
190-
onOtherWaysToSignInClicked = onOtherWaysToSignInClicked,
190+
onOtherWaysToSignUpClicked = onOtherWaysToSignUpClicked,
191191
email = email,
192192
onEmailChanged = onEmailChanged,
193193
onPasskeyRegister = onPasskeyRegister,
@@ -224,7 +224,7 @@ private fun RegisterScreenInputSection(
224224
fullName: String,
225225
onFullNameChanged: (String) -> Unit,
226226
onLearnMoreClicked: () -> Unit,
227-
onOtherWaysToSignInClicked: () -> Unit,
227+
onOtherWaysToSignUpClicked: () -> Unit,
228228
email: String,
229229
onEmailChanged: (String) -> Unit,
230230
onPasskeyRegister: (String) -> Unit,
@@ -282,7 +282,7 @@ private fun RegisterScreenInputSection(
282282
modifier = Modifier.padding(top = dimensionResource(R.dimen.dimen_standard)),
283283
)
284284

285-
PasskeyInformationTab(onLearnMoreClicked, onOtherWaysToSignInClicked)
285+
PasskeyInformationTab(onLearnMoreClicked, onOtherWaysToSignUpClicked)
286286

287287
ShrineButton(
288288
onClick = { onPasskeyRegister(email) },
@@ -297,13 +297,13 @@ private fun RegisterScreenInputSection(
297297
* Composable for the Passkeys Information Tab UI Element
298298
*
299299
* @param onLearnMoreClicked lambda for more information, navigates to an informational screen
300-
* @param onOtherWaysToSignInClicked lambda for other sign in methods, navigates to
300+
* @param onOtherWaysToSignUpClicked lambda for other sign in methods, navigates to
301301
* @OtherOptionsSignInScreen
302302
* */
303303
@Composable
304304
private fun PasskeyInformationTab(
305305
onLearnMoreClicked: () -> Unit,
306-
onOtherWaysToSignInClicked: () -> Unit,
306+
onOtherWaysToSignUpClicked: () -> Unit,
307307
) {
308308
Column(
309309
modifier = Modifier
@@ -328,8 +328,8 @@ private fun PasskeyInformationTab(
328328
)
329329
ShrineClickableText(
330330
text = "",
331-
clickableText = stringResource(R.string.other_ways_to_sign_in),
332-
onTextClick = onOtherWaysToSignInClicked,
331+
clickableText = stringResource(R.string.other_ways_to_sign_up),
332+
onTextClick = onOtherWaysToSignUpClicked,
333333
textStyle = TextStyle(color = Color(0xFF006B5F)),
334334
)
335335
}
@@ -353,7 +353,7 @@ fun RegisterScreenPreview() {
353353
RegisterScreen(
354354
onPasskeyRegister = { _ -> },
355355
onLearnMoreClicked = { },
356-
onOtherWaysToSignInClicked = { },
356+
onOtherWaysToSignUpClicked = { },
357357
onBackClicked = { },
358358
uiState = RegisterUiState(),
359359
fullName = "",

Shrine/app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
<string name="error">Error</string>
6969
<string name="nav_host_route">Nav Host Route</string>
7070
<string name="other_ways_to_sign_in">Other ways to sign in</string>
71+
<string name="other_ways_to_sign_up">Other ways to sign up</string>
7172
<string name="enter_valid_username">Enter valid username</string>
7273
<string name="asset_statements">[{
7374
\"include\": \"https://project-sesame-426206.appspot.com/.well-known/assetlinks.json\"

0 commit comments

Comments
 (0)