9
9
* @flow
10
10
*/
11
11
12
- import AnonymousUtils from './AnonymousUtils' ;
13
12
import CoreManager from './CoreManager' ;
14
13
import isRevocableSession from './isRevocableSession' ;
15
14
import ParseError from './ParseError' ;
@@ -337,8 +336,7 @@ class ParseUser extends ParseObject {
337
336
* @param { string } username
338
337
*/
339
338
setUsername(username: string) {
340
- // Strip anonymity, even we do not support anonymous user in js SDK, we may
341
- // encounter anonymous user created by android/iOS in cloud code.
339
+ // Strip anonymity
342
340
const authData = this . get ( 'authData' ) ;
343
341
if ( authData && typeof authData === 'object' && authData . hasOwnProperty ( 'anonymous' ) ) {
344
342
// We need to set anonymous to null instead of deleting it in order to remove it from Parse.
@@ -960,13 +958,7 @@ const DefaultController = {
960
958
return Storage . removeItemAsync ( path ) ;
961
959
} ,
962
960
963
- async setCurrentUser(user) {
964
- const currentUser = await this . currentUserAsync ( ) ;
965
- if ( currentUser && ! user . equals ( currentUser ) && AnonymousUtils . isLinked ( currentUser ) ) {
966
- await currentUser . destroy ( {
967
- sessionToken : currentUser . getSessionToken ( ) ,
968
- } ) ;
969
- }
961
+ setCurrentUser(user) {
970
962
currentUserCache = user ;
971
963
user . _cleanupAuthData ( ) ;
972
964
user . _synchronizeAllAuthData ( ) ;
@@ -1134,7 +1126,7 @@ const DefaultController = {
1134
1126
} ) ;
1135
1127
} ,
1136
1128
1137
- logOut ( options : RequestOptions ) : Promise < ParseUser > {
1129
+ async logOut ( options : RequestOptions ) : Promise < ParseUser > {
1138
1130
const RESTController = CoreManager . getRESTController ( ) ;
1139
1131
if ( options . sessionToken ) {
1140
1132
return RESTController . request ( 'POST' , 'logout' , { } , options) ;
@@ -1143,18 +1135,11 @@ const DefaultController = {
1143
1135
const path = Storage . generatePath ( CURRENT_USER_KEY ) ;
1144
1136
let promise = Storage . removeItemAsync ( path ) ;
1145
1137
if ( currentUser !== null ) {
1146
- const isAnonymous = AnonymousUtils . isLinked ( currentUser ) ;
1147
1138
const currentSession = currentUser . getSessionToken ( ) ;
1148
1139
if ( currentSession && isRevocableSession ( currentSession ) ) {
1149
- promise = promise
1150
- . then ( ( ) => {
1151
- if ( isAnonymous ) {
1152
- return currentUser . destroy ( { sessionToken : currentSession } ) ;
1153
- }
1154
- } )
1155
- . then ( ( ) => {
1156
- return RESTController . request ( 'POST' , 'logout' , { } , { sessionToken : currentSession } ) ;
1157
- } ) ;
1140
+ promise = promise . then ( ( ) => {
1141
+ return RESTController . request ( 'POST' , 'logout' , { } , { sessionToken : currentSession } ) ;
1142
+ } ) ;
1158
1143
}
1159
1144
currentUser . _logOutWithAll ( ) ;
1160
1145
currentUser . _finishFetch ( { sessionToken : undefined } ) ;
0 commit comments