Skip to content

Commit

Permalink
Merge branch 'feature/PB-34091_Fix-the-import-account-kit-button-afte…
Browse files Browse the repository at this point in the history
…r-the-webview-refreshing' into 'develop'

PB-34091 - Fix the import account kit button after the webview refreshing

See merge request passbolt/desktop/passbolt-windows!150
  • Loading branch information
scadra committed Jul 23, 2024
2 parents 57575ef + 976ca54 commit 92f3830
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
3 changes: 2 additions & 1 deletion passbolt/Models/Messaging/AllowedTopics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> topics = new List<string>() { 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<string> topics = new List<string>() { 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<string> requestIds = new List<string>();
private static Dictionary<string, string> pendingRequests = new Dictionary<string, string>();

Expand Down
11 changes: 11 additions & 0 deletions passbolt/Models/Messaging/Webviews/BackgroundTopic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit 92f3830

Please sign in to comment.