Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

feat: reenable account password change

thecodrr77130022c65a
diff --git a/apps/web/__e2e__/user.test.js b/apps/web/__e2e__/user.test.js
index c686b7030..f373e2f13 100644
--- a/apps/web/__e2e__/user.test.js
+++ b/apps/web/__e2e__/user.test.js
@@ -1,7 +1,6 @@
const { Page, test, expect } = require("@playwright/test");
-const { getTestId, isTestAll, loginUser } = require("./utils");
+const { getTestId, isTestAll, loginUser, USER } = require("./utils");
const { isAbsent, isPresent } = require("./utils/conditions");
-const path = require("path");
/**
* @type {Page}
@@ -36,3 +35,55 @@ test("logout user", async () => {
expect(await isAbsent(getTestId("navitem-sync"))).toBe(true);
});
+
+test.only("login user and change password repeatedly", async ({
+ page,
+ browserName,
+}) => {
+ test.setTimeout(0);
+ test.skip(browserName !== "chromium", "Cannot run in parallel.");
+
+ let currentPassword = "";
+ let newPassword = USER.password;
+ let email = USER.email;
+
+ for (let i = 0; i < 10; i++) {
+ await test.step(
+ `login user using password ${currentPassword} (${i})`,
+ async () => {
+ await loginUser({
+ email,
+ password: currentPassword,
+ });
+
+ await page.waitForSelector(getTestId("sync-status-success"));
+
+ await page.click(getTestId("navitem-settings"));
+
+ await page.click(getTestId("settings-change-password"));
+
+ await page.waitForSelector(getTestId("dialog-yes"));
+
+ await page.fill(getTestId("dialog-password"), currentPassword);
+
+ await page.fill(getTestId("dialog-new-password"), newPassword);
+
+ await page.click(getTestId("dialog-yes"));
+
+ expect(await isAbsent(getTestId("dialog-yes"), 60 * 1000)).toBe(true);
+
+ await page.click(getTestId("settings-logout"));
+
+ await page.waitForSelector(getTestId("dialog-yes"));
+
+ await page.click(getTestId("dialog-yes"));
+
+ expect(await isAbsent(getTestId("navitem-sync"))).toBe(true);
+
+ const cPassword = currentPassword;
+ currentPassword = newPassword;
+ newPassword = cPassword;
+ }
+ );
+ }
+});
diff --git a/apps/web/__e2e__/utils/conditions.js b/apps/web/__e2e__/utils/conditions.js
index 3036abda5..e60fed2ca 100644
--- a/apps/web/__e2e__/utils/conditions.js
+++ b/apps/web/__e2e__/utils/conditions.js
@@ -14,9 +14,9 @@ async function isPresent(selector) {
}
}
-async function isAbsent(selector) {
+async function isAbsent(selector, timeout = 10000) {
try {
- await page.waitForSelector(selector, { state: "detached", timeout: 10000 });
+ await page.waitForSelector(selector, { state: "detached", timeout });
return true;
} catch (e) {
console.log(e);
diff --git a/apps/web/__e2e__/utils/index.js b/apps/web/__e2e__/utils/index.js
index f16546a18..09b7d3c7a 100644
--- a/apps/web/__e2e__/utils/index.js
+++ b/apps/web/__e2e__/utils/index.js
@@ -98,6 +98,7 @@ function isTestAll() {
}
module.exports = {
+ USER,
NOTE,
NOTEBOOK,
PASSWORD,
diff --git a/apps/web/src/common/dialogcontroller.js b/apps/web/src/common/dialogcontroller.js
index ef3550d9b..56b6f5e6a 100644
--- a/apps/web/src/common/dialogcontroller.js
+++ b/apps/web/src/common/dialogcontroller.js
@@ -10,7 +10,7 @@ import { store as editorStore } from "../stores/editor-store";
import { store as noteStore } from "../stores/note-store";
import { db } from "./db";
import { showToast } from "../utils/toast";
-import { Flex, Text } from "rebass";
+import { Box, Flex, Text } from "rebass";
import * as Icon from "../components/icons";
import Config from "../utils/config";
import Dialogs from "../components/dialogs";
@@ -366,8 +366,23 @@ function getDialogData(type) {
case "change_account_password":
return {
title: "Change account password",
- subtitle:
- "All your data will be re-encrypted and synced with the new password.",
+ subtitle: (
+ <>
+ All your data will be re-encrypted and synced with the new password.
+ <Box mt={1} p={1} bg="errorBg" color="error">
+ <Text as="p" my={0}>
+ It is recommended that you <b>log out from all other devices</b>{" "}
+ before continuing.
+ </Text>
+ <Text as="p" my={0} mt={1}>
+ If this process is interrupted, there is a high chance of data
+ corruption so{" "}
+ <b>please do NOT shut down your device or close your browser</b>{" "}
+ until this process completes.
+ </Text>
+ </Box>
+ </>
+ ),
positiveButtonText: "Change password",
};
case "verify_account":
diff --git a/apps/web/src/components/dialogs/password-dialog.js b/apps/web/src/components/dialogs/password-dialog.js
index 32c89c903..dce3691df 100644
--- a/apps/web/src/components/dialogs/password-dialog.js
+++ b/apps/web/src/components/dialogs/password-dialog.js
@@ -74,6 +74,7 @@ function PasswordDialog(props) {
{isChangePasswordDialog ? (
<Field
required
+ data-test-id="dialog-new-password"
label="New password"
type="password"
autoComplete="new-password"
diff --git a/apps/web/src/components/status-bar/index.js b/apps/web/src/components/status-bar/index.js
index eb50ad1e4..871cf9f0e 100644
--- a/apps/web/src/components/status-bar/index.js
+++ b/apps/web/src/components/status-bar/index.js
@@ -197,7 +197,7 @@ function SyncStatus() {
return (
<>
<Checkmark size={12} color="success" />
- <Text variant="subBody" ml={1}>
+ <Text data-test-id="sync-status-success" variant="subBody" ml={1}>
Sync completed
</Text>
</>
diff --git a/apps/web/src/views/settings.js b/apps/web/src/views/settings.js
index dbbf418a3..1298f172b 100644
--- a/apps/web/src/views/settings.js
+++ b/apps/web/src/views/settings.js
@@ -220,13 +220,14 @@ function Settings(props) {
tip="In case you lose your password, you can recover your data using your recovery key."
/>
</Button>
- {/* <Button
+ <Button
variant="list"
+ data-test-id="settings-change-password"
onClick={async () => {
const result = await showPasswordDialog(
"change_account_password",
(data) => {
- return db.user.resetPassword(
+ return db.user.changePassword(
data.oldPassword,
data.newPassword
);
@@ -241,7 +242,7 @@ function Settings(props) {
text="Change account password"
tip="Set a new password for your account"
/>
- </Button> */}
+ </Button>
<Button variant="list" onClick={() => sync(true, true)}>
<Tip
text="Having problems with syncing?"