File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -2050,5 +2050,27 @@ describe('Parse.User testing', () => {
2050
2050
Parse . Cloud . _removeHook ( 'Triggers' , 'afterSave' , '_User' ) ;
2051
2051
done ( ) ;
2052
2052
} ) ;
2053
- } )
2053
+ } ) ;
2054
+
2055
+ it ( 'changes to a user should update the cache' , ( done ) => {
2056
+ Parse . Cloud . define ( 'testUpdatedUser' , ( req , res ) => {
2057
+ expect ( req . user . get ( 'han' ) ) . toEqual ( 'solo' ) ;
2058
+ res . success ( { } ) ;
2059
+ } ) ;
2060
+ let user = new Parse . User ( ) ;
2061
+ user . setUsername ( 'harrison' ) ;
2062
+ user . setPassword ( 'ford' ) ;
2063
+ user . signUp ( ) . then ( ( ) => {
2064
+ user . set ( 'han' , 'solo' ) ;
2065
+ return user . save ( ) ;
2066
+ } ) . then ( ( ) => {
2067
+ return Parse . Cloud . run ( 'testUpdatedUser' ) ;
2068
+ } ) . then ( ( ) => {
2069
+ done ( ) ;
2070
+ } , ( e ) => {
2071
+ fail ( 'Should not have failed.' ) ;
2072
+ done ( ) ;
2073
+ } ) ;
2074
+
2075
+ } ) ;
2054
2076
} ) ;
Original file line number Diff line number Diff line change @@ -341,6 +341,11 @@ RestWrite.prototype.transformUser = function() {
341
341
} ) ;
342
342
}
343
343
344
+ // If we're updating a _User object, clear the user cache for the session
345
+ if ( this . query && this . auth . user && this . auth . user . getSessionToken ( ) ) {
346
+ cache . users . remove ( this . auth . user . getSessionToken ( ) ) ;
347
+ }
348
+
344
349
return promise . then ( ( ) => {
345
350
// Transform the password
346
351
if ( ! this . data . password ) {
You can’t perform that action at this time.
0 commit comments