diff --git a/apps/desktop/src/locales/en/messages.json b/apps/desktop/src/locales/en/messages.json index 8c82556168..f3a9fd5d4a 100644 --- a/apps/desktop/src/locales/en/messages.json +++ b/apps/desktop/src/locales/en/messages.json @@ -2312,10 +2312,10 @@ "important": { "message": "Important:" }, - "logoutReasonAccessTokenUnableToBeDecrypted": { + "accessTokenUnableToBeDecrypted": { "message": "You have been logged out because your access token could not be decrypted. Please log in again to resolve this issue." }, - "logoutReasonRefreshTokenSecureStorageRetrievalFailure": { + "refreshTokenSecureStorageRetrievalFailure": { "message": "You have been logged out because your refresh token could not be retrieved. Please log in again to resolve this issue." }, "masterPasswordHint": { diff --git a/libs/common/src/auth/enums/logout-reason.enum.ts b/libs/common/src/auth/enums/logout-reason.enum.ts index 485be26be1..6bcd68a107 100644 --- a/libs/common/src/auth/enums/logout-reason.enum.ts +++ b/libs/common/src/auth/enums/logout-reason.enum.ts @@ -1,4 +1,3 @@ -export enum LogoutReason { - ACCESS_TOKEN_DECRYPTION_FAILED = "logoutReasonAccessTokenUnableToBeDecrypted", - REFRESH_TOKEN_SECURE_STORAGE_RETRIEVAL_FAILED = "logoutReasonRefreshTokenSecureStorageRetrievalFailure", -} +export type LogoutReason = + | "accessTokenUnableToBeDecrypted" + | "refreshTokenSecureStorageRetrievalFailure"; diff --git a/libs/common/src/auth/services/token.service.spec.ts b/libs/common/src/auth/services/token.service.spec.ts index 74b95d3967..f2baec8352 100644 --- a/libs/common/src/auth/services/token.service.spec.ts +++ b/libs/common/src/auth/services/token.service.spec.ts @@ -13,7 +13,6 @@ import { StorageOptions } from "../../platform/models/domain/storage-options"; import { SymmetricCryptoKey } from "../../platform/models/domain/symmetric-crypto-key"; import { CsprngArray } from "../../types/csprng"; import { UserId } from "../../types/guid"; -import { LogoutReason } from "../enums/logout-reason.enum"; import { ACCOUNT_ACTIVE_ACCOUNT_ID } from "./account.service"; import { AccessTokenKey, DecodedAccessToken, TokenService } from "./token.service"; @@ -536,7 +535,7 @@ describe("TokenService", () => { // assert that we logged the user out expect(messagingService.send).toHaveBeenCalledWith("logout", { userId: userIdFromAccessToken, - reason: LogoutReason.ACCESS_TOKEN_DECRYPTION_FAILED, + reason: "accessTokenUnableToBeDecrypted", }); }); @@ -571,7 +570,7 @@ describe("TokenService", () => { // assert that we logged the user out expect(messagingService.send).toHaveBeenCalledWith("logout", { userId: userIdFromAccessToken, - reason: LogoutReason.ACCESS_TOKEN_DECRYPTION_FAILED, + reason: "accessTokenUnableToBeDecrypted", }); }); }); @@ -1428,7 +1427,7 @@ describe("TokenService", () => { // assert that we logged the user out expect(messagingService.send).toHaveBeenCalledWith("logout", { userId: userIdFromAccessToken, - reason: LogoutReason.ACCESS_TOKEN_DECRYPTION_FAILED, + reason: "accessTokenUnableToBeDecrypted", }); }); }); @@ -1691,7 +1690,7 @@ describe("TokenService", () => { expect(messagingService.send).toHaveBeenCalledWith("logout", { userId: userIdFromAccessToken, - reason: LogoutReason.REFRESH_TOKEN_SECURE_STORAGE_RETRIEVAL_FAILED, + reason: "refreshTokenSecureStorageRetrievalFailure", }); }); }); diff --git a/libs/common/src/auth/services/token.service.ts b/libs/common/src/auth/services/token.service.ts index 2bc2d69715..d7399387ee 100644 --- a/libs/common/src/auth/services/token.service.ts +++ b/libs/common/src/auth/services/token.service.ts @@ -21,7 +21,6 @@ import { } from "../../platform/state"; import { UserId } from "../../types/guid"; import { TokenService as TokenServiceAbstraction } from "../abstractions/token.service"; -import { LogoutReason } from "../enums/logout-reason.enum"; import { ACCOUNT_ACTIVE_ACCOUNT_ID } from "./account.service"; import { @@ -413,7 +412,7 @@ export class TokenService implements TokenServiceAbstraction { ); this.messageSender.send("logout", { userId, - reason: LogoutReason.ACCESS_TOKEN_DECRYPTION_FAILED, + reason: "accessTokenUnableToBeDecrypted", }); return null; } @@ -435,7 +434,7 @@ export class TokenService implements TokenServiceAbstraction { ); this.messageSender.send("logout", { userId, - reason: LogoutReason.ACCESS_TOKEN_DECRYPTION_FAILED, + reason: "accessTokenUnableToBeDecrypted", }); return null; } @@ -459,7 +458,7 @@ export class TokenService implements TokenServiceAbstraction { this.logService.error(`Failed to decrypt access token`, error); this.messageSender.send("logout", { userId, - reason: LogoutReason.ACCESS_TOKEN_DECRYPTION_FAILED, + reason: "accessTokenUnableToBeDecrypted", }); return null; } @@ -594,7 +593,7 @@ export class TokenService implements TokenServiceAbstraction { // logout reason if we do so. this.messageSender.send("logout", { userId, - reason: LogoutReason.REFRESH_TOKEN_SECURE_STORAGE_RETRIEVAL_FAILED, + reason: "refreshTokenSecureStorageRetrievalFailure", }); } }