File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed
src/components/authentication Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -231,10 +231,11 @@ export class AuthenticationService {
231
231
}
232
232
233
233
async asUser < R > (
234
- userId : ID < 'User' > ,
234
+ user : ID < 'User' > | Session ,
235
235
fn : ( session : Session ) => Promise < R > ,
236
236
) : Promise < R > {
237
- const session = await this . sessionForUser ( userId ) ;
237
+ const session =
238
+ typeof user === 'string' ? await this . sessionForUser ( user ) : user ;
238
239
return await this . sessionHost . withSession ( session , ( ) => fn ( session ) ) ;
239
240
}
240
241
Original file line number Diff line number Diff line change @@ -115,16 +115,16 @@ export class SessionResolver {
115
115
async impersonator (
116
116
@Parent ( ) { session } : SessionOutput ,
117
117
) : Promise < User | null > {
118
- if ( session . anonymous || ! session . impersonator ) {
118
+ const { impersonator } = session ;
119
+ if ( session . anonymous || ! impersonator ) {
119
120
return null ;
120
121
}
121
122
// Edge case: Load the impersonator, as the impersonator, rather than the impersonatee.
122
123
// They should still be able to see their own props from this field.
123
124
// Otherwise, it could be that the impersonatee can't see the impersonator's roles,
124
125
// and now the UI can't stop impersonating because it doesn't know the impersonator's roles.
125
- return await this . users . readOne (
126
- session . impersonator . userId ,
127
- session . impersonator , // instead of `session`
126
+ return await this . authentication . asUser ( impersonator , ( _ ) =>
127
+ this . users . readOne ( impersonator . userId , _ ) ,
128
128
) ;
129
129
}
130
130
You can’t perform that action at this time.
0 commit comments