A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
mobile: reset login state on token expiry
ammarahm-ed65cae7888e51
diff --git a/apps/mobile/app/components/auth/login.js b/apps/mobile/app/components/auth/login.jsindex 0702472e4..4625f0601 100644--- a/apps/mobile/app/components/auth/login.js+++ b/apps/mobile/app/components/auth/login.js@@ -59,7 +59,7 @@ export const Login = ({ changeMode }) => {setLoading,setError,login- } = useLogin(undefined, async () => {+ } = useLogin(async () => {hideAuth();eSendEvent("userLoggedIn", true);await sleep(500);diff --git a/apps/mobile/app/components/auth/session-expired.js b/apps/mobile/app/components/auth/session-expired.jsindex 5b0df720b..af679ffed 100644--- a/apps/mobile/app/components/auth/session-expired.js+++ b/apps/mobile/app/components/auth/session-expired.js@@ -22,6 +22,7 @@ import { Modal, View } from "react-native";import { db } from "../../common/database";import BiometricService from "../../services/biometrics";import {+ eSendEvent,eSubscribeEvent,eUnSubscribeEvent,ToastEvent@@ -57,8 +58,8 @@ export const SessionExpired = () => {const [visible, setVisible] = useState(false);const [focused, setFocused] = useState(false);const { step, password, email, passwordInputRef, loading, login } = useLogin(- undefined,() => {+ eSendEvent("userLoggedIn", true);setVisible(false);});diff --git a/apps/mobile/app/components/auth/use-login.js b/apps/mobile/app/components/auth/use-login.jsindex 25dbf0c5a..60946b94e 100644--- a/apps/mobile/app/components/auth/use-login.js+++ b/apps/mobile/app/components/auth/use-login.js@@ -25,9 +25,6 @@ import PremiumService from "../../services/premium";import SettingsService from "../../services/settings";import { useUserStore } from "../../stores/use-user-store";import { eCloseSheet } from "../../utils/events";-import { sleep } from "../../utils/time";-import { Progress } from "../sheets/progress";-import { hideAuth } from "./common";import TwoFactorVerification from "./two-factor";export const LoginSteps = {@@ -36,12 +33,12 @@ export const LoginSteps = {passwordAuth: 3};-export const useLogin = (defaultEmail, onFinishLogin) => {+export const useLogin = (onFinishLogin) => {const [error, setError] = useState(false);const [loading, setLoading] = useState(false);const setUser = useUserStore((state) => state.setUser);const [step, setStep] = useState(LoginSteps.emailAuth);- const email = useRef(defaultEmail);+ const email = useRef();const password = useRef();const emailInputRef = useRef();const passwordInputRef = useRef();@@ -92,6 +89,7 @@ export const useLogin = (defaultEmail, onFinishLogin) => {if (e.message === "invalid_grant") {eSendEvent(eCloseSheet, "two_factor_verify");setLoading(false);+ setStep(LoginSteps.emailAuth);}}}, mfaInfo);@@ -111,6 +109,7 @@ export const useLogin = (defaultEmail, onFinishLogin) => {};const finishWithError = async (e) => {+ if (e.message === "invalid_grant") setStep(LoginSteps.emailAuth);setLoading(false);ToastEvent.show({heading: "Login failed",