parse-community / Parse-SDK-Android

The Android SDK for Parse Platform
https://parseplatform.org/
Other
1.88k stars 735 forks source link

fix: failed signup attempt with anonymous ParseUser leaves it in inconsistent state #1136

Closed shlusiak closed 2 years ago

shlusiak commented 2 years ago

Issue Description

The key "authData" contains a Map of authentication related data. Because unfortunately estimatedData is a shallow copy of state, the object pointed to by state["authData"] and estimatedData["authData"] is the same object. Modifying the data in this map directly prevents us from being able to call revert() to revert the data back to the server state.

This is impotant e.g. when trying to revert the user after converting it from anonymous to registered fails, where anonymity has been stripped and there is no way to get it back.

Related issue: #401

Approach

This would just create another (shallow) copy of "authData", which in this case would be fine, because we are only modifying the first layer. By replacing the value of the map with a new map we ensure that the values in state and estimatedData are different and that revert() works.

parse-github-assistant[bot] commented 2 years ago

Thanks for opening this pull request!

azlekov commented 2 years ago

@shlusiak can you check please the failing test

com.parse.ParseUserTest > testSaveAsyncWithLazyAndCurrentUser FAILED
1579
    java.lang.AssertionError at ParseUserTest.java:962
shlusiak commented 2 years ago

@L3K0V I think I fixed the failing test. Let's see if it passes now.

codecov[bot] commented 2 years ago

Codecov Report

Merging #1136 (4bc9067) into master (1844b3e) will decrease coverage by 0.01%. The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #1136      +/-   ##
============================================
- Coverage     65.31%   65.30%   -0.02%     
+ Complexity     2219     2218       -1     
============================================
  Files           122      122              
  Lines          9961     9961              
  Branches       1338     1338              
============================================
- Hits           6506     6505       -1     
  Misses         2943     2943              
- Partials        512      513       +1     
Impacted Files Coverage Δ
parse/src/main/java/com/parse/ParseUser.java 82.42% <100.00%> (-0.21%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 301c29b...4bc9067. Read the comment docs.

azlekov commented 2 years ago

@mtrezza LGTM

parseplatformorg commented 2 years ago

🎉 This change has been released in version 2.0.5