aws-amplify / aws-amplify/amplify-android
[Auth] Reported username depends on AuthFlow used
- Dominant language
- Java
- Stars
- 287
- Forks
- 132
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 45
Description
### Before opening, please confirm:
- [x] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-android/issues?q=is%3Aissue+) and [discussions](https://github.com/aws-amplify/amplify-android/discussions).
### Language and Async Model
Not applicable
### Amplify Categories
Authentication
### Gradle script dependencies
```kotlin
// Put output below this line
```
### Environment information
```
# Put output below this line
```
### Please include any relevant guides or documentation you're referencing
_No response_
### Describe the bug
If you sign in to a user using an email address (or phone number) as the sign in attribute when using the USER_AUTH flow then when you call `Amplify.Auth.getCurrentUser().username` the value returned will be the attribute to used to sign in. With all other flows the value returned is the actual username.
### Reproduction steps (if applicable)
1. User a userpool with email and/or phonenumber as a sign in attribute. Have USER_AUTH and USER_SRP_AUTH both enabled in the app client.
2. Use an email address (or phone number) to sign in with a created user via the USER_AUTH flow.
3. Call `getCurrentUser()` and observe the `username`.
4. Sign out
5. Sign in to _the same user_ using USER_SRP_AUTH.
6. Call `getCurrentUser()` and observe the `username`.
Expected: The username is the same in both cases since it's the same user.
Actual: In USER_AUTH the username is reported as the email address, in USER_SRP_AUTH it's the username (which may be a UUID if no username was supplied at sign up).
### Code Snippet
```kotlin
// Put your code below this line.
```
### Log output
```
// Put your logs below this line
```
### Configuration File
_No response_
### GraphQL Schema
```graphql
// Put your schema below this line
```
### Additional information and screenshots
_No response_
Contributor guide
Research direction
Start at Amplify.Auth.getCurrentUser() and trace how the USER_AUTH and USER_SRP_AUTH flows populate its username. Reproduce the sign-in sequence from the issue, then verify that both flows report the same username for the same user and add regression coverage for the discrepancy.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, aws, java
- Domain
- authentication, mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100