feat: redirect to /signup if user not logged in

This commit is contained in:
thecodrr
2021-08-02 13:25:29 +05:00
parent 430f8a9d83
commit 9f8e93bc2e
2 changed files with 7 additions and 1 deletions

View File

@@ -38,6 +38,8 @@ function initializeDatabase() {
loadDefaultNotes(db);
} catch (e) {}
}
return db;
});
}

View File

@@ -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 () => {