Skip to content

Commit

Permalink
web: fix app asking password on auto backups with encryption off
Browse files Browse the repository at this point in the history
  • Loading branch information
thecodrr committed May 16, 2024
1 parent 9be52a6 commit e5795bc
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
11 changes: 9 additions & 2 deletions apps/web/src/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,19 @@ export async function introduceFeatures() {

export const DEFAULT_CONTEXT = { colors: [], tags: [], notebook: {} };

export async function createBackup(rescueMode = false) {
export async function createBackup(
options: {
rescueMode?: boolean;
noVerify?: boolean;
} = {}
) {
const { rescueMode, noVerify } = options;
const { isLoggedIn } = useUserStore.getState();
const { encryptBackups, toggleEncryptBackups } = useSettingStore.getState();
if (!isLoggedIn && encryptBackups) toggleEncryptBackups();

const verified = rescueMode || encryptBackups || (await verifyAccount());
const verified =
rescueMode || encryptBackups || noVerify || (await verifyAccount());
if (!verified) {
showToast("error", "Could not create a backup: user verification failed.");
return false;
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/common/notices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ function isIgnored(key: keyof typeof NoticesData) {
let openedToast: { hide: () => void } | null = null;
async function saveBackup() {
if (IS_DESKTOP_APP) {
await createBackup();
await createBackup({ noVerify: true });
} else if (isUserPremium() && !IS_TESTING) {
if (openedToast !== null) return;
openedToast = showToast(
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/announcements/body.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ function CalltoAction({ action, variant, sx, dismissAnnouncement }) {
break;
}
case "backup": {
await createBackup(true);
await createBackup();
break;
}
default: {
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/views/recovery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ function BackupData(props: BaseRecoveryComponentProps<"backup">) {
"Please wait while we create a backup file for you to download."
}}
onSubmit={async () => {
await createBackup(true);
await createBackup({ rescueMode: true });
navigate("new");
}}
>
Expand Down

0 comments on commit e5795bc

Please sign in to comment.