Skip to content

Commit 94edb70

Browse files
committed
use flat username, check if only attribute
1 parent 7738fcb commit 94edb70

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

app/src/main/java/com/azuresamples/msalnativeauthandroidkotlinsampleapp/SignUpAttributesFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class SignUpAttributesFragment : Fragment() {
5959
val username = binding.usernameText.text.toString()
6060

6161
val attributes = UserAttributes.Builder()
62-
.customAttribute("username", username)
62+
.flatUsername(username)
6363
.build()
6464

6565
val actionResult = currentState.submitAttributes(attributes)

app/src/main/java/com/azuresamples/msalnativeauthandroidkotlinsampleapp/SignUpCodeFragment.kt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,16 @@ class SignUpCodeFragment : Fragment() {
7070
)
7171
}
7272
is SignUpResult.AttributesRequired -> {
73-
navigateToAttributes(
74-
nextState = actionResult.nextState
75-
)
73+
// Custom implementation for Flat Username / Alias
74+
if (actionResult.requiredAttributes.size == 1 &&
75+
actionResult.requiredAttributes.any { it.name == "flatusername" }
76+
) {
77+
navigateToAttributes(
78+
nextState = actionResult.nextState
79+
)
80+
} else {
81+
displayDialog(getString(R.string.unexpected_sdk_result_title), actionResult.toString())
82+
}
7683
}
7784
is SignUpResult.PasswordRequired -> {
7885
displayDialog(getString(R.string.unexpected_sdk_result_title), actionResult.toString())

0 commit comments

Comments
 (0)