Skip to content

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

feat: remove login, signup & forgot password dialogs

thecodrr2087928e2fa6
diff --git a/apps/web/src/common/dialogcontroller.js b/apps/web/src/common/dialogcontroller.js
index bbbb68907..1109b670e 100644
--- a/apps/web/src/common/dialogcontroller.js
+++ b/apps/web/src/common/dialogcontroller.js
@@ -330,12 +330,6 @@ async function exportToPDF(content) {
});
}
-export function showForgotPasswordDialog() {
- return showDialog((Dialogs, perform) => (
- <Dialogs.ForgotPasswordDialog onClose={() => perform()} />
- ));
-}
-
export function showLoadingDialog(dialogData) {
const { title, message, subtitle, action } = dialogData;
return showDialog((Dialogs, perform) => (
@@ -349,27 +343,6 @@ export function showLoadingDialog(dialogData) {
));
}
-export const showLogInDialog = (
- title,
- description,
- positiveText,
- email,
- skipInit,
- force
-) => {
- return showDialog((Dialogs, perform) => (
- <Dialogs.LoginDialog
- title={title}
- description={description}
- positiveText={positiveText}
- skipInit={skipInit}
- force={force}
- email={email}
- onClose={(res) => perform(res)}
- />
- ));
-};
-
export function showMoveNoteDialog(noteIds) {
return showDialog((Dialogs, perform) => (
<Dialogs.MoveDialog
@@ -479,17 +452,6 @@ export function showRecoveryKeyDialog() {
));
}
-export function showSignUpDialog() {
- return showDialog((Dialogs, perform) => (
- <Dialogs.SignUpDialog
- onClose={async (res) => {
- perform(res);
- if (res === true) await showRecoveryKeyDialog();
- }}
- />
- ));
-}
-
export function showCreateTopicDialog() {
return showDialog((Dialogs, perform) => (
<Dialogs.ItemDialog
diff --git a/apps/web/src/components/dialogs/forgotpassworddialog.js b/apps/web/src/components/dialogs/forgotpassworddialog.js
deleted file mode 100644
index 7a8888eb0..000000000
--- a/apps/web/src/components/dialogs/forgotpassworddialog.js
+++ /dev/null
@@ -1,74 +0,0 @@
-import React, { useState } from "react";
-import { Text, Box } from "rebass";
-import Dialog from "./dialog";
-import Field from "../field";
-import { db } from "../../common/db";
-import { showToast } from "../../utils/toast";
-
-const requiredValues = ["email"];
-function ForgotPasswordDialog(props) {
- const { onClose } = props;
- const [error, setError] = useState();
- const [isLoading, setIsLoading] = useState(false);
-
- return (
- <Dialog
- isOpen={true}
- title={"Recover your account"}
- description={
- "Forgot your password? No worries, we can help you recover your account."
- }
- onClose={onClose}
- scrollable
- negativeButton={{ text: "Cancel", onClick: onClose }}
- positiveButton={{
- props: {
- form: "signupForm",
- type: "submit",
- },
- text: "Continue",
- disabled: isLoading,
- loading: isLoading,
- }}
- >
- <Box
- id="signupForm"
- as="form"
- onSubmit={(e) => {
- e.preventDefault();
- const data = requiredValues.reduce((prev, curr) => {
- prev[curr] = e.target[curr].value;
- return prev;
- }, {});
-
- setError();
- setIsLoading(true);
- db.user
- .recoverAccount(data.email.toLowerCase())
- .then(() => {
- showToast(
- "success",
- "Recovery email sent. Please check your inbox."
- );
- onClose();
- })
- .catch((e) => setError(e.message))
- .finally(() => setIsLoading(false));
- }}
- >
- <Field
- autoFocus
- required
- id="email"
- type="email"
- label="Email"
- name="email"
- autoComplete="email"
- helpText="We will email you a recovery link that you can use to recover your account."
- />
- {error && <Text variant="error">{error}</Text>}
- </Box>
- </Dialog>
- );
-}
-export default ForgotPasswordDialog;
diff --git a/apps/web/src/components/dialogs/logindialog.js b/apps/web/src/components/dialogs/logindialog.js
deleted file mode 100644
index 64a1925e5..000000000
--- a/apps/web/src/components/dialogs/logindialog.js
+++ /dev/null
@@ -1,129 +0,0 @@
-import React, { useEffect, useState } from "react";
-import { Flex, Button, Text } from "rebass";
-import * as Icon from "../icons";
-import Dialog from "./dialog";
-import { useStore } from "../../stores/user-store";
-import Field from "../field";
-import { showForgotPasswordDialog } from "../../common/dialog-controller";
-import { hashNavigate } from "../../navigation";
-import useHashLocation from "../../utils/use-hash-location";
-
-const requiredValues = ["email", "password"];
-function LoginDialog(props) {
- const { onClose, title, description, positiveText, email, skipInit, force } =
- props;
- const [error, setError] = useState();
- const [, queryParams] = useHashLocation();
- const isLoggingIn = useStore((store) => store.isLoggingIn);
- const login = useStore((store) => store.login);
- const isLoggedIn = useStore((store) => store.isLoggedIn);
-
- useEffect(() => {
- if (isLoggedIn && !force) {
- onClose();
- if (queryParams.redirect) hashNavigate(queryParams.redirect);
- }
- }, [isLoggedIn, queryParams, force, onClose]);
-
- return (
- <Dialog
- isOpen={true}
- title={title || "Sign in to your account"}
- description={
- <Flex alignItems="center">
- <Text as="span" fontSize="body" color="gray">
- {description ? (
- description
- ) : (
- <>
- Don't have an account?{" "}
- <Button
- variant="anchor"
- sx={{ textAlign: "left" }}
- fontSize="body"
- onClick={() => hashNavigate("/signup")}
- >
- Create an account here.
- </Button>
- </>
- )}
- </Text>
- </Flex>
- }
- icon={Icon.Login}
- onClose={() => onClose(false)}
- scrollable
- negativeButton={{
- text: "Cancel",
- disabled: isLoggingIn,
- onClick: onClose,
- }}
- positiveButton={{
- props: {
- form: "loginForm",
- type: "submit",
- },
- text: positiveText || "Sign in",
- loading: isLoggingIn,
- disabled: isLoggingIn,
- }}
- >
- <Flex
- id="loginForm"
- as="form"
- onSubmit={(e) => {
- e.preventDefault();
- const form = new FormData(e.target);
- const data = requiredValues.reduce((prev, curr) => {
- prev[curr] = form.get(curr);
- return prev;
- }, {});
- setError();
-
- if (email) data.email = email;
-
- login(data, skipInit)
- .then(async () => {
- onClose(true);
- if (queryParams.redirect) {
- hashNavigate(queryParams.redirect);
- }
- })
- .catch((e) => setError(e.message));
- }}
- flexDirection="column"
- >
- <Field
- required
- id="email"
- label="Email"
- name="email"
- defaultValue={email}
- disabled={!!email}
- autoComplete="email"
- />
- <Field
- required
- id="password"
- label="Password"
- name="password"
- type="password"
- autoComplete="current-password"
- sx={{ mt: 1 }}
- />
- <Button
- type="button"
- variant="anchor"
- fontSize="body"
- sx={{ alignSelf: "flex-start" }}
- mt={1}
- onClick={showForgotPasswordDialog}
- >
- Forgot password?
- </Button>
- {error && <Text variant="error">{error}</Text>}
- </Flex>
- </Dialog>
- );
-}
-export default LoginDialog;
diff --git a/apps/web/src/components/dialogs/signupdialog.js b/apps/web/src/components/dialogs/signupdialog.js
deleted file mode 100644
index c415e492e..000000000
--- a/apps/web/src/components/dialogs/signupdialog.js
+++ /dev/null
@@ -1,109 +0,0 @@
-import React, { useState } from "react";
-import { Text, Box, Button, Flex } from "rebass";
-import * as Icon from "../icons";
-import Dialog from "./dialog";
-import { useStore } from "../../stores/user-store";
-import { showLogInDialog } from "../../common/dialog-controller";
-import Field from "../field";
-
-const requiredValues = ["email", "password"];
-function SignUpDialog(props) {
- const { onClose } = props;
- const [error, setError] = useState();
- const [passwordError, setPasswordError] = useState();
- const isSigningIn = useStore((store) => store.isSigningIn);
- const signup = useStore((store) => store.signup);
-
- return (
- <Dialog
- isOpen={true}
- title={"Create a new Account"}
- description={
- <Flex alignItems="center">
- <Text fontSize="body" textAlign="center" color="gray" mr="3px">
- Already have an account?
- </Text>
- <Button variant="anchor" fontSize="body" onClick={showLogInDialog}>
- Sign in here.
- </Button>
- </Flex>
- }
- icon={Icon.Signup}
- onClose={onClose}
- scrollable
- negativeButton={{ text: "Cancel", onClick: onClose }}
- positiveButton={{
- props: {
- form: "signupForm",
- type: "submit",
- },
- text: "Create account",
- loading: isSigningIn,
- disabled: isSigningIn,
- }}
- >
- <Box
- id="signupForm"
- as="form"
- onSubmit={(e) => {
- e.preventDefault();
- if (passwordError) {
- setError("Please resolve all errors before continuing.");
- return;
- }
-
- const data = requiredValues.reduce((prev, curr) => {
- prev[curr] = e.target[curr].value;
- return prev;
- }, {});
-
- setError();
-
- signup(data)
- .then(async () => {
- onClose(true);
- })
- .catch((e) => setError(e.message));
- }}
- >
- <Field
- autoFocus
- required
- id="email"
- type="email"
- label="Email"
- name="email"
- autoComplete="email"
- />
- <Field
- required
- id="password"
- label="Password"
- name="password"
- type="password"
- autoComplete="new-password"
- validatePassword
- onError={setPasswordError}
- sx={{ mt: 1 }}
- />
- <Text variant="body" fontSize="body" mt={2}>
- By signing up on Notesnook you agree to our{" "}
- <Text as="a" color="primary" href="https://notesnook.com/tos">
- terms of service
- </Text>{" "}
- &amp;{" "}
- <Text as="a" color="primary" href="https://notesnook.com/privacy">
- privacy policy
- </Text>
- .
- </Text>
- {error && typeof error === "string" && (
- <Text variant="error" fontSize="body" mt={2}>
- {error}
- </Text>
- )}
- </Box>
- </Dialog>
- );
-}
-export default SignUpDialog;
diff --git a/apps/web/src/navigation/hash-routes.js b/apps/web/src/navigation/hash-routes.js
index 9da82ec62..859a03f9e 100644
--- a/apps/web/src/navigation/hash-routes.js
+++ b/apps/web/src/navigation/hash-routes.js
@@ -11,8 +11,6 @@ import {
showEditNotebookDialog,
} from "../common/dialog-controller";
import { closeOpenedDialog } from "../common/dialog-controller";
-import { showLogInDialog } from "../common/dialog-controller";
-import { showSignUpDialog } from "../common/dialog-controller";
import RouteContainer from "../components/route-container";
import DiffViewer from "../components/diff-viewer";
import Unlock from "../components/unlock";
@@ -99,9 +97,6 @@ const hashroutes = {
closeOpenedDialog();
return <DiffViewer noteId={noteId} />;
},
- "/signup": () => {
- showSignUpDialog();
- },
"/vault/changePassword": () => {
Vault.changeVaultPassword();
},
@@ -110,9 +105,6 @@ const hashroutes = {
appStore.setIsVaultCreated(res);
});
},
- "/login": () => {
- showLogInDialog();
- },
"/buy": () => {
showBuyDialog();
},