Skip to content

Better username evaluation in get_user_obj#278

Open
wazy wants to merge 2 commits intoNabuCasa:masterfrom
wazy:detect_username_in_get_user_obj
Open

Better username evaluation in get_user_obj#278
wazy wants to merge 2 commits intoNabuCasa:masterfrom
wazy:detect_username_in_get_user_obj

Conversation

@wazy
Copy link
Copy Markdown

@wazy wazy commented Aug 2, 2024

If Cognito was instantiated with an access token and without a username then get_user will return a user without a username property:

c = Cognito(user_pool, client_id, access_token)
u = c.get_user()
print(u.username) # prints None

This PR allows get_user_obj to check if username is not set and if so try to set it to self.username or the username from the metadata dictionary if it exists.

Order of preference for what username should be:

  1. passed in username
  2. self.username
  3. username from the metadata

@wazy
Copy link
Copy Markdown
Author

wazy commented Aug 2, 2024

@ludeeus @pvizeli This is a bug I believe and this change should address it. Should I start opening issues to link to in PRs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant