From 8a973fbef639cd481d7502013d9fc9628c0a1a79 Mon Sep 17 00:00:00 2001 From: Wind-Explorer <66894537+Wind-Explorer@users.noreply.github.com> Date: Tue, 13 Aug 2024 03:02:05 +0800 Subject: [PATCH] Properly handling archived account login --- client/src/App.tsx | 8 ++- client/src/components/SignInModule.tsx | 19 +++-- client/src/pages/AccountInaccessiblePage.tsx | 76 ++++++++++++++++++++ client/src/pages/SpringboardPage.tsx | 68 +----------------- 4 files changed, 95 insertions(+), 76 deletions(-) create mode 100644 client/src/pages/AccountInaccessiblePage.tsx diff --git a/client/src/App.tsx b/client/src/App.tsx index 2d428b3..218d9f5 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -36,7 +36,7 @@ import FeedbackPage from "./pages/FeedbackPage"; import UserVouchersPage from "./pages/UserVouchersPage"; import ManageFeedbacksPage from "./pages/ManageFeedbacksPage"; import TagManagement from "./pages/TagManagement"; - +import AccoutnInaccessiblePage from "./pages/AccountInaccessiblePage"; function App() { return ( @@ -81,8 +81,6 @@ function App() { } path="user-voucher" /> - - {/* Special (Restricted) Routes */} }> } path="forgot-password" /> @@ -91,6 +89,10 @@ function App() { path="reset-password/:token" /> } path="feedback" /> + } + path="account-inaccessible" + /> diff --git a/client/src/components/SignInModule.tsx b/client/src/components/SignInModule.tsx index 3d810bc..e106220 100644 --- a/client/src/components/SignInModule.tsx +++ b/client/src/components/SignInModule.tsx @@ -39,14 +39,19 @@ export default function SignInModule() { instance .post(config.serverAddress + "/users/login", values) .then((response) => { + console.log("logging in"); localStorage.setItem("accessToken", response.data.accessToken); - retrieveUserInformation().then((value) => { - if (value.accountType == 2) { - navigate("/admin"); - } else { - window.location.reload(); - } - }); + retrieveUserInformation() + .then((value) => { + if (value.accountType == 2) { + navigate("/admin"); + } else { + window.location.reload(); + } + }) + .catch(() => { + navigate("/account-inaccessible"); + }); }) .catch((error) => { popErrorToast(error); diff --git a/client/src/pages/AccountInaccessiblePage.tsx b/client/src/pages/AccountInaccessiblePage.tsx new file mode 100644 index 0000000..2f5de03 --- /dev/null +++ b/client/src/pages/AccountInaccessiblePage.tsx @@ -0,0 +1,76 @@ +import { Button, Card, Link } from "@nextui-org/react"; +import { LockClosedIcon } from "../icons"; +import { useNavigate } from "react-router-dom"; + +export default function AccoutnInaccessiblePage() { + const navigate = useNavigate(); + return ( +
+
+
+
+
+ +
+
+
+
+

Account unavailable.

+

+ The access to this account has been revoked. +

+
+

+ If you wish to recover the account, please{" "} + { + window.location.href = "mailto:support@ecoconnect.gov.sg"; + }} + > + contact us + +

+
+
+
+
+
+ +
+
+
+
+

Why am I seeing this?

+
+

+ You have attempted to access an account that has been marked as + inactive. +

+

+ This may due to, either manual operation by the owner of the + account, or administrative decision from the management team. +

+

+ The information related to this account remains, however the access + to the account will not be available. +

+

+ If you believe that this is incorrect, or would like to request a + re-activation, please{" "} + { + window.location.href = "mailto:support@ecoconnect.gov.sg"; + }} + > + contact us + + . +

+
+
+
+ ); +} diff --git a/client/src/pages/SpringboardPage.tsx b/client/src/pages/SpringboardPage.tsx index 349f3a8..b361706 100644 --- a/client/src/pages/SpringboardPage.tsx +++ b/client/src/pages/SpringboardPage.tsx @@ -1,7 +1,7 @@ import { useNavigate } from "react-router-dom"; import { useEffect, useState } from "react"; import { Button, Card, Link } from "@nextui-org/react"; -import { LockClosedIcon, PencilSquareIcon } from "../icons"; +import { PencilSquareIcon } from "../icons"; import SpringboardButton from "../components/SpringboardButton"; import { getTimeOfDay } from "../utilities"; import { retrieveUserInformation } from "../security/users"; @@ -16,7 +16,6 @@ export default function SpringboardPage() { navigate("/signin"); } const [userInformation, setUserInformation] = useState(); - const [accountUnavailable, setAccountUnavaliable] = useState(false); const [events, setEvents] = useState([]); let timeOfDay = getTimeOfDay(); @@ -38,7 +37,7 @@ export default function SpringboardPage() { setUserInformation(response); }) .catch((_) => { - setAccountUnavaliable(true); + navigate("/account-inaccessible"); }); instance.get("/events").then((response) => { @@ -170,69 +169,6 @@ export default function SpringboardPage() { )} -
- {accountUnavailable && ( -
- -
-
-
-
- -
-
-
-
-

Account unavailable.

-

- This account has been archived. -

-
-

- If you wish to recover the account, please{" "} - - contact us - -

-
-
-
-
-
- -
-
-
-
- -
-

Why am I seeing this?

-
-

- You have attempted to access an account that has been - archived. -

-

- This may due to, either manual operation by the owner of the - account, or administrative decision from the management - team. -

-

- The information related to this account remains, however the - access to the account will not be available. -

-

- If you believe that this is incorrect, or would like to - request an unarchive, please contact us. -

-
-
-
-
- )} -
); }