@@ -58,7 +58,7 @@ export class SessionsRouter extends ClassesRouter {
5858 } ;
5959 }
6060
61- handleUpdateToRevocableSession ( req ) {
61+ async handleUpdateToRevocableSession ( req ) {
6262 const config = req . config ;
6363 const user = req . auth . user ;
6464 // Issue #2720
@@ -74,22 +74,34 @@ export class SessionsRouter extends ClassesRouter {
7474 installationId : req . auth . installationId ,
7575 } ) ;
7676
77- return createSession ( )
78- . then ( ( ) => {
79- // delete the session token, use the db to skip beforeSave
80- return config . database . update (
81- '_User' ,
82- {
83- objectId : user . id ,
84- } ,
85- {
86- sessionToken : { __op : 'Delete' } ,
87- }
88- ) ;
89- } )
90- . then ( ( ) => {
91- return Promise . resolve ( { response : sessionData } ) ;
92- } ) ;
77+ await createSession ( ) ;
78+ // delete the session token, use the db to skip beforeSave
79+ await config . database . update (
80+ '_User' ,
81+ { objectId : user . id } ,
82+ { sessionToken : { __op : 'Delete' } }
83+ ) ;
84+ // Re-fetch the session with the caller's auth context so that
85+ // protectedFields filtering applies correctly
86+ const userAuth = new Auth . Auth ( {
87+ config,
88+ isMaster : false ,
89+ user : Parse . Object . fromJSON ( { className : '_User' , objectId : user . id } ) ,
90+ installationId : req . auth . installationId ,
91+ } ) ;
92+ const response = await rest . find (
93+ config ,
94+ userAuth ,
95+ '_Session' ,
96+ { sessionToken : sessionData . sessionToken } ,
97+ { } ,
98+ req . info . clientSDK ,
99+ req . info . context
100+ ) ;
101+ if ( ! response . results || response . results . length === 0 ) {
102+ throw new Parse . Error ( Parse . Error . INTERNAL_SERVER_ERROR , 'Failed to load upgraded session.' ) ;
103+ }
104+ return { response : response . results [ 0 ] } ;
93105 }
94106
95107 mountRoutes ( ) {
0 commit comments