Skip to content

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

feat: re-add login redirect

thecodrr1c079f3fa557
diff --git a/apps/web/src/components/dialogs/logindialog.js b/apps/web/src/components/dialogs/logindialog.js
index df2d95e8d..fd3974f2f 100644
--- a/apps/web/src/components/dialogs/logindialog.js
+++ b/apps/web/src/components/dialogs/logindialog.js
@@ -7,17 +7,26 @@ import Field from "../field";
import { Checkbox, Label } from "@rebass/forms";
import { showForgotPasswordDialog } from "../../common/dialog-controller";
import { hashNavigate } from "../../navigation";
+import useHashLocation from "../../utils/use-hash-location";
const requiredValues = ["email", "password", "remember"];
function LoginDialog(props) {
const { onClose, title, description, positiveText, skipInit } = props;
const [error, setError] = useState();
+ const [, queryParams] = useHashLocation();
const [credential, setCredential] = useState();
const [email, setEmail] = useState();
const isLoggingIn = useStore((store) => store.isLoggingIn);
const login = useStore((store) => store.login);
const isLoggedIn = useStore((store) => store.isLoggedIn);
+ useEffect(() => {
+ if (isLoggedIn) {
+ onClose();
+ if (queryParams.redirect) hashNavigate(queryParams.redirect);
+ }
+ }, [isLoggedIn, queryParams, onClose]);
+
useEffect(() => {
if (isLoggedIn) {
onClose();
@@ -134,6 +143,9 @@ function LoginDialog(props) {
} else {
onClose();
}
+ if (queryParams.redirect) {
+ hashNavigate(queryParams.redirect);
+ }
})
.catch((e) => setError(e.message));
}}