Skip to content

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

feat: redirect to /signup if user not logged in

thecodrr9f8e93bc2edb
diff --git a/apps/web/src/common/db.js b/apps/web/src/common/db.js
index 2966b9eab..303ae530a 100644
--- a/apps/web/src/common/db.js
+++ b/apps/web/src/common/db.js
@@ -38,6 +38,8 @@ function initializeDatabase() {
loadDefaultNotes(db);
} catch (e) {}
}
+
+ return db;
});
}
diff --git a/apps/web/src/index.js b/apps/web/src/index.js
index 9a8b2503f..7cfdaa1d2 100644
--- a/apps/web/src/index.js
+++ b/apps/web/src/index.js
@@ -11,7 +11,11 @@ if (process.env.NODE_ENV === "production") {
console.log = () => {};
}
-initializeDatabase().then(() => {
+initializeDatabase().then(async (db) => {
+ const isLoggedIn = !!(await db.user.getUser());
+ if (!isLoggedIn && !window.location.pathname.startsWith("/signup"))
+ window.location.replace("/signup");
+
import("react-dom").then(({ render }) => {
import("./App").then(({ default: App }) => {
render(<App />, document.getElementById("root"), async () => {