Skip to content

fix(auth): fetch device metadata from credential store for remember and forgetDevice #2601

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 9 commits into from
Oct 11, 2023

Conversation

tjleing
Copy link
Contributor

@tjleing tjleing commented Oct 3, 2023

fixes #2585.

  • PR title and description conform to Pull Request guidelines.

Issue #, if available:

Description of changes:
If Cognito returns null newDeviceMetadata uses our previously-existing metadata if we have it. That goes directly into the AuthN state, so reading it immediately after a signIn will return null.

After digging into it for a while, I discovered that Swift does things differently than we currently do -- Swift line vs Android line. This essentially copies Swift's method of doing things. Note that this might mean we could be able to remove deviceMetadata from AuthenticationState.SignedIn since I believe we don't actually use it anymore.

For review: do we prefer runBlocking or GlobalScope.launch (or GlobalScope.async)? I'm seeing more GlobalScope.launch in the code that's already here so I went with that.

How did you test these changes?
(Please add a line here how the changes were tested)
Sample app

Documentation update required?

  • No
  • Yes (Please include a PR link for the documentation update)

General Checklist

  • Added Unit Tests
  • Added Integration Tests
  • Security oriented best practices and standards are followed (e.g. using input sanitization, principle of least privilege, etc)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@tjleing tjleing requested a review from a team as a code owner October 3, 2023 18:46
@codecov-commenter
Copy link

codecov-commenter commented Oct 3, 2023

Codecov Report

Merging #2601 (f536d63) into main (7cc9826) will increase coverage by 0.00%.
The diff coverage is 50.00%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

@@           Coverage Diff           @@
##             main    #2601   +/-   ##
=======================================
  Coverage   41.71%   41.72%           
=======================================
  Files         900      900           
  Lines       28788    28791    +3     
  Branches     4082     4082           
=======================================
+ Hits        12009    12013    +4     
- Misses      15459    15461    +2     
+ Partials     1320     1317    -3     

@tjleing tjleing changed the title fix(auth): in some cases Cognito sign in doesn't re-return the device metadata fix(auth): retain device metadata in authn state Oct 4, 2023
@tjleing tjleing changed the title fix(auth): retain device metadata in authn state fix(auth): fetch device metadata from credential store for remember and forgetDevice Oct 4, 2023
@tjleing tjleing requested a review from gpanshu October 9, 2023 22:34
@tjleing tjleing enabled auto-merge (squash) October 10, 2023 20:01
@tjleing tjleing merged commit 45d19c1 into main Oct 11, 2023
@tjleing tjleing deleted the remember-device-metadata-fix branch October 11, 2023 14:39
gpanshu pushed a commit that referenced this pull request Oct 23, 2023
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.

Auth rememberDevice — InvalidParameterException, value null at 'deviceKey'
4 participants