diff --git a/passbolt/Models/Messaging/AllowedTopics.cs b/passbolt/Models/Messaging/AllowedTopics.cs index 9ef1023..0907c86 100644 --- a/passbolt/Models/Messaging/AllowedTopics.cs +++ b/passbolt/Models/Messaging/AllowedTopics.cs @@ -33,13 +33,14 @@ public class AllowedTopics public const string BACKGROUND_SET_THEME = "passbolt.background.set-theme"; public const string BACKGROUND_SET_SECURITY_TOKEN = "passbolt.background.set-security-token"; public const string BACKGROUND_SET_LOCALE = "passbolt.background.set-locale"; + public const string BACKGROUND_AUTHENTICATION_ERROR = "passbolt.background.authentication-error"; public const string RENDERED_READY = "passbolt.rendered.is-ready"; public const string RENDERED_STARTED = "passbolt.rendered.started"; public const string BACKGROUND_GET_COOKIE = "passbolt.background.get-cookie"; public const string BACKGROUND_ROTATE_KEY = "passbolt.background.rotate-private-key"; public const string RENDERED_RELOAD = "passbolt.tab.reload"; - private static List topics = new List() { BACKGROUND_READY, ERROR, BACKGROUND_DOWNLOAD_FILE, BACKGROUND_STORE_PASSPHRASE, BACKGROUND_SET_THEME, BACKGROUND_SET_SECURITY_TOKEN, BACKGROUND_SET_LOCALE, RENDERED_READY, BACKGROUND_AFTER_LOGOUT, BACKGROUND_GET_COOKIE, BACKGROUND_ROTATE_KEY, RENDERED_RELOAD, RENDERED_STARTED }; + private static List topics = new List() { BACKGROUND_READY, ERROR, BACKGROUND_DOWNLOAD_FILE, BACKGROUND_STORE_PASSPHRASE, BACKGROUND_SET_THEME, BACKGROUND_SET_SECURITY_TOKEN, BACKGROUND_SET_LOCALE, RENDERED_READY, BACKGROUND_AFTER_LOGOUT, BACKGROUND_GET_COOKIE, BACKGROUND_ROTATE_KEY, BACKGROUND_AUTHENTICATION_ERROR, RENDERED_RELOAD, RENDERED_STARTED }; private static List requestIds = new List(); private static Dictionary pendingRequests = new Dictionary(); diff --git a/passbolt/Models/Messaging/Webviews/BackgroundTopic.cs b/passbolt/Models/Messaging/Webviews/BackgroundTopic.cs index f0a73a8..7c0c9f8 100644 --- a/passbolt/Models/Messaging/Webviews/BackgroundTopic.cs +++ b/passbolt/Models/Messaging/Webviews/BackgroundTopic.cs @@ -125,6 +125,17 @@ public async override void ProceedMessage(IPC ipc) await localFolderService.CreateBackgroundIndex(this.currentIndexBackground, "background-auth", metaData.domain); background.Source = new Uri(UriBuilderHelper.BuildHostUri(backgroundUrl, "/index-auth.html")); break; + case AllowedTopics.BACKGROUND_AUTHENTICATION_ERROR: + //This case can happen when a certificate and/or the API cannot be reached. In this case we cancel the account saving and redirect background to import + if(currentIndexRendered == "index-import.html" && currentIndexBackground == "index-auth.html") + { + await this.credentialLockerService.Remove("account-metadata"); + await this.credentialLockerService.Remove("account-secret"); + await localFolderService.RemoveFile("Background", "index-auth.html"); + await localFolderService.CreateBackgroundIndex(this.currentIndexBackground, "background-import"); + background.Source = new Uri(UriBuilderHelper.BuildHostUri(BackgroundNavigationService.Instance.trustedUrl, "/Background/index-import.html")); + } + break; case AllowedTopics.BACKGROUND_DOWNLOAD_FILE: var downloadService = new DownloadService(); await downloadService.Download(ipc); diff --git a/passbolt/Webviews/Background/src/controllers/desktopAuthenticateController.js b/passbolt/Webviews/Background/src/controllers/desktopAuthenticateController.js index ddf5652..73f98ed 100644 --- a/passbolt/Webviews/Background/src/controllers/desktopAuthenticateController.js +++ b/passbolt/Webviews/Background/src/controllers/desktopAuthenticateController.js @@ -13,7 +13,7 @@ */ import {Config} from "passbolt-browser-extension/src/all/background_page/model/config"; -import {REQUIRE_MFA, USER_LOGGED_IN} from "../enumerations/appEventEnumeration"; +import {BACKGROUND_AUTHENTICATION_ERROR, REQUIRE_MFA, USER_LOGGED_IN} from "../enumerations/appEventEnumeration"; import LoginUserService from "../services/loginUserService"; import OrganizationSettingsModel from "passbolt-browser-extension/src/all/background_page/model/organizationSettings/organizationSettingsModel"; @@ -47,6 +47,7 @@ class DesktopAuthenticateController { } catch (error) { console.error(error); this.worker.port.emit(this.requestId, 'ERROR', error); + this.worker.port.emit(BACKGROUND_AUTHENTICATION_ERROR); } } diff --git a/passbolt/Webviews/Background/src/enumerations/appEventEnumeration.js b/passbolt/Webviews/Background/src/enumerations/appEventEnumeration.js index deda830..f713554 100644 --- a/passbolt/Webviews/Background/src/enumerations/appEventEnumeration.js +++ b/passbolt/Webviews/Background/src/enumerations/appEventEnumeration.js @@ -15,6 +15,7 @@ export const USER_LOGGED_IN = "passbolt.auth.after-login"; export const USER_LOGGED_OUT = "passbolt.auth.logout"; export const BACKGROUND_READY = "passbolt.background.is-ready"; +export const BACKGROUND_AUTHENTICATION_ERROR = "passbolt.background.authentication-error"; export const BACKGROUND_IMPORT = "passbolt.background.import"; export const ERROR = "passbolt.error"; export const LOCALSTORAGE_UPDATE = "passbolt.background.localstorage-update";