Skip to content

Commit fa4fd26

Browse files
authored
Only enable impersonation if logged in (#2894)
Situation is: caller calls session query with impersonation while not logged in. Previously we threw an error that the impersonation was unauthorized. This prevented the caller from ever establishing a session to login with. Now we will just ignore their impersonation input if they are not logged in. This allows a session to be established and login to be preformed. After that point any operations will continue to error out if they are not authorized.
1 parent a010d59 commit fa4fd26

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/components/authentication/authentication.service.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,16 @@ export class AuthenticationService {
117117
);
118118
}
119119

120-
impersonatee = impersonatee
121-
? {
122-
id: impersonatee?.id,
123-
roles: [
124-
...(impersonatee.roles ?? []),
125-
...(result.impersonateeRoles ?? []),
126-
],
127-
}
128-
: undefined;
120+
impersonatee =
121+
impersonatee && result.userId
122+
? {
123+
id: impersonatee?.id,
124+
roles: [
125+
...(impersonatee.roles ?? []),
126+
...(result.impersonateeRoles ?? []),
127+
],
128+
}
129+
: undefined;
129130

130131
const requesterSession: Session = {
131132
token,

0 commit comments

Comments
 (0)