Skip to content

Commit

Permalink
fix: Fixes error on logout
Browse files Browse the repository at this point in the history
  • Loading branch information
voduguwa committed Mar 15, 2023
1 parent 29b9150 commit ca1307b
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions apps/user-office-backend/src/auth/OAuthAuthorization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export abstract class OAuthAuthorization extends UserAuthorization {
}
}

async logout(uosToken: AuthJwtPayload): Promise<void | Rejection> {
async logout(uosToken: AuthJwtPayload): Promise<string | Rejection> {
const oidcSub = uosToken.user.oidcSub;

if (!oidcSub) {
Expand All @@ -73,7 +73,7 @@ export abstract class OAuthAuthorization extends UserAuthorization {

await OpenIdClient.logout(user.oauthAccessToken);

return;
return 'logged out';
} catch (error) {
return rejection('Error ocurred while logging out', {
error: (error as Error)?.message,
Expand Down
4 changes: 2 additions & 2 deletions apps/user-office-backend/src/auth/StfcUserAuthorization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,13 @@ export class StfcUserAuthorization extends UserAuthorization {
return dummyUser;
}

async logout(uosToken: AuthJwtPayload): Promise<void | Rejection> {
async logout(uosToken: AuthJwtPayload): Promise<string | Rejection> {
try {
const token = uosToken.externalToken;
if (token) {
this.uowsTokenCache.remove(token);

await client.logout(token).catch(() => {
return await client.logout(token).catch(() => {
logger.logWarn('Failed to log out user', { token });

return rejection('Failed to log out user', { token });
Expand Down
2 changes: 1 addition & 1 deletion apps/user-office-backend/src/auth/UserAuthorization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export abstract class UserAuthorization {
redirectUri: string
): Promise<User | null>;

abstract logout(token: AuthJwtPayload): Promise<void | Rejection>;
abstract logout(token: AuthJwtPayload): Promise<string | Rejection>;

abstract isExternalTokenValid(externalToken: string): Promise<boolean>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export class UserAuthorizationMock extends UserAuthorization {
async isInternalUser(userId: number, currentRole: Role): Promise<boolean> {
return true;
}
async logout(token: AuthJwtPayload): Promise<void> {
return;
async logout(token: AuthJwtPayload): Promise<string> {
return 'logged out';
}
async isExternalTokenValid(externalToken: string): Promise<boolean> {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,7 @@
}

const refinedResult = this.client['logoutAsync'](argsObj).then((result: any) => {
return result[0];
return "successfully logged out";
}).catch((result: any) => {
const response = result?.response;
const exceptionMessage = response?.data?.match("<faultstring>(.*)</faultstring>")[1];
Expand Down
2 changes: 1 addition & 1 deletion apps/user-office-backend/src/mutations/UserMutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ export default class UserMutations {
}
}

async logout(token: string): Promise<void | Rejection> {
async logout(token: string): Promise<string | Rejection> {
try {
const decodedToken = verifyToken<AuthJwtPayload>(token);

Expand Down

0 comments on commit ca1307b

Please sign in to comment.