Skip to content

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

fix: improve account recovery UX

thecodrre8190df3e520
diff --git a/apps/web/src/common/index.js b/apps/web/src/common/index.js
index f9f87297b..c6a497c34 100644
--- a/apps/web/src/common/index.js
+++ b/apps/web/src/common/index.js
@@ -13,18 +13,18 @@ import { hashNavigate } from "../navigation";
export const db = new Database(StorageInterface, EventSource);
-db.host({
- API_HOST: "https://api.notesnook.com",
- AUTH_HOST: "https://auth.streetwriters.co",
- SSE_HOST: "https://events.streetwriters.co",
-});
-
// db.host({
-// API_HOST: "http://localhost:5264",
-// AUTH_HOST: "http://localhost:8264",
-// SSE_HOST: "http://localhost:7264",
+// API_HOST: "https://api.notesnook.com",
+// AUTH_HOST: "https://auth.streetwriters.co",
+// SSE_HOST: "https://events.streetwriters.co",
// });
+db.host({
+ API_HOST: "http://localhost:5264",
+ AUTH_HOST: "http://localhost:8264",
+ SSE_HOST: "http://localhost:7264",
+});
+
// db.host({
// API_HOST: "http://192.168.10.8:5264",
// AUTH_HOST: "http://192.168.10.8:8264",
diff --git a/apps/web/src/stores/user-store.js b/apps/web/src/stores/user-store.js
index 5447523c7..f933dbc12 100644
--- a/apps/web/src/stores/user-store.js
+++ b/apps/web/src/stores/user-store.js
@@ -53,7 +53,7 @@ class UserStore extends BaseStore {
if (navigator.credentials.requireUserMediation)
await navigator.credentials.requireUserMediation();
}
- if (!reason) {
+ if (!!reason) {
await showAccountLoggedOutNotice(reason);
}
});
diff --git a/apps/web/src/views/recovery.js b/apps/web/src/views/recovery.js
index 8c44ae135..4885fcd5c 100644
--- a/apps/web/src/views/recovery.js
+++ b/apps/web/src/views/recovery.js
@@ -18,13 +18,13 @@ function AccountRecovery(props) {
const [loading, setLoading] = useState({ isLoading: false });
const doWorkWithLoading = useCallback(
- async (message, workCallback, onError) => {
+ async (message, workCallback, error, onError) => {
try {
setLoading({ isLoading: true, message });
await workCallback();
} catch (e) {
console.error(e);
- showToast("error", e.message);
+ showToast("error", `${error} Error: ${e.message}`);
if (onError) onError(e);
} finally {
setLoading({ isLoading: false });
@@ -56,6 +56,7 @@ function AccountRecovery(props) {
);
await db.user.fetchUser(false);
},
+ "Could not authorize user.",
() => {
navigate("/");
}
@@ -93,7 +94,7 @@ function AccountRecovery(props) {
) : step === 3 ? (
<Button
variant="secondary"
- onClick={() => (window.location.href = "/")}
+ onClick={() => (window.location.href = "/#/login")}
>
Return to Notesnook
</Button>
@@ -115,9 +116,10 @@ function AccountRecovery(props) {
const user = await db.user.getUser();
await db.context.write(`_uk_@${user.email}@_k`, key);
await db.sync(true, true);
- }
+ setStep((s) => ++s);
+ },
+ "Invalid recovery key."
);
- setStep((s) => ++s);
}
var newPassword = formData.get("new_password");
if (newPassword) {
@@ -125,9 +127,11 @@ function AccountRecovery(props) {
"Resetting account password. Please wait...",
async () => {
if (await db.user.resetPassword(newPassword)) {
+ await db.user.logout(true);
setStep((s) => ++s);
}
- }
+ },
+ "Invalid password."
);
}
}}
diff --git a/apps/web/yarn.lock b/apps/web/yarn.lock
index 811aba8c5..5c9b649d4 100644
--- a/apps/web/yarn.lock
+++ b/apps/web/yarn.lock
@@ -8999,9 +8999,21 @@ normalize-url@^3.0.0, normalize-url@^3.0.1:
resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-3.3.0.tgz#b2e1c4dc4f7c6d57743df733a4f5978d18650559"
integrity sha512-U+JJi7duF1o+u2pynbp2zXDW2/PADgC30f0GsHZtRh+HOcXHnw137TrNlyxxRvWW5fjKd3bcLHPxofWuCjaeZg==
+notes-core@../notes-core:
+ version "5.3.2"
+ dependencies:
+ fast-sort "^2.0.1"
+ fuzzysearch "^1.0.3"
+ jshashes "^1.0.8"
+ no-internet "^1.5.2"
+ qclone "^1.0.4"
+ quill-delta-to-html "^0.12.0"
+ quill-delta-to-markdown "https://github.com/streetwriters/quill-delta-to-markdown"
+ transfun "^1.0.2"
+
"notes-core@git+ssh://[email protected]:streetwriters/notesnook-core.git":
- version "5.3.0"
- resolved "git+ssh://[email protected]:streetwriters/notesnook-core.git#ced3399c34976bd6021b9d66488162b6482a0156"
+ version "5.3.2"
+ resolved "git+ssh://[email protected]:streetwriters/notesnook-core.git#82a11c95721d15824c3e350298c5b3f13ddd38a0"
dependencies:
fast-sort "^2.0.1"
fuzzysearch "^1.0.3"