mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-09-01 19:49:54 +02:00
web: fix login loop on session expiry
This commit is contained in:
@@ -172,7 +172,8 @@ function Auth(props: AuthProps) {
|
||||
useEffect(() => {
|
||||
if (!isAppLoaded) return;
|
||||
db.user?.getUser().then((user) => {
|
||||
if (user && authorizedRoutes.includes(route)) return openURL("/");
|
||||
if (user && authorizedRoutes.includes(route) && !isSessionExpired())
|
||||
return openURL("/");
|
||||
setIsReady(true);
|
||||
});
|
||||
}, [isAppLoaded, route]);
|
||||
@@ -392,8 +393,7 @@ function SessionExpiry(props: BaseAuthComponentProps<"sessionExpiry">) {
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
const user = await db.user?.getUser();
|
||||
const isSessionExpired = Config.get("sessionExpired", false);
|
||||
if (user && isSessionExpired) {
|
||||
if (user && isSessionExpired()) {
|
||||
setUser(user);
|
||||
} else if (!user) {
|
||||
Config.set("sessionExpired", false);
|
||||
@@ -988,3 +988,7 @@ function maskEmail(email: string) {
|
||||
username.length - 2
|
||||
)}@${domain}`;
|
||||
}
|
||||
|
||||
function isSessionExpired() {
|
||||
return Config.get("sessionExpired", false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user