diff --git a/public/images/favicon.png b/public/images/favicon.png new file mode 100644 index 0000000..fb29076 Binary files /dev/null and b/public/images/favicon.png differ diff --git a/src/assets/styles/global.css b/src/assets/styles/global.css index 814df3c..c23e3ef 100644 --- a/src/assets/styles/global.css +++ b/src/assets/styles/global.css @@ -216,6 +216,9 @@ Custom .btn { margin-top: 1.5% !important; + font-weight: 600; + font-size: 15px; + letter-spacing: 0.01em; } .hr { diff --git a/src/components/AppLayout.jsx b/src/components/AppLayout.jsx index ad95a3c..9f0dbcc 100644 --- a/src/components/AppLayout.jsx +++ b/src/components/AppLayout.jsx @@ -19,6 +19,7 @@ const Player = lazy(() => import('./AudioPlayer.jsx')); export default function Root({ child, user = undefined, ...props }) { window.toast = toast; const theme = document.documentElement.getAttribute("data-theme") + const loggedIn = props.loggedIn ?? Boolean(user); usePrimeReactThemeSwitcher(theme); return ( @@ -34,7 +35,7 @@ export default function Root({ child, user = undefined, ...props }) { color="danger"> Work in progress... bugs are to be expected. */} - {child == "LoginPage" && ()} + {child == "LoginPage" && ()} {child == "LyricSearch" && ()} {child == "Player" && ()} {child == "Memes" && } diff --git a/src/components/Login.jsx b/src/components/Login.jsx index 0a1022e..93e97db 100644 --- a/src/components/Login.jsx +++ b/src/components/Login.jsx @@ -1,4 +1,5 @@ import React, { useState, useRef, useEffect } from "react"; +import Button from "@mui/joy/Button"; import { toast } from "react-toastify"; import { API_URL } from "@/config"; @@ -13,7 +14,7 @@ function clearCookie(name) { document.cookie = `${name}=; Max-Age=0; path=/;`; } -export default function LoginPage() { +export default function LoginPage({ loggedIn = false }) { const [username, setUsername] = useState(""); const [password, setPassword] = useState(""); const [loading, setLoading] = useState(false); @@ -79,8 +80,7 @@ export default function LoginPage() { toast.success("Login successful!", { toastId: "login-success-toast", }); - const returnTo = getCookie("returnTo") || "/TRip"; - clearCookie("returnTo"); + const returnTo = "/"; window.location.href = returnTo; } else { toast.error("Login failed: no access token received", { @@ -97,6 +97,30 @@ export default function LoginPage() { } } + if (loggedIn) { + return ( +
+
+ Logo +

You're already logged in

+

You do not have permission to access this resource. +

+

+ If you feel you have received this message in error, scream at codey. +

+ +
+
+ ); + } + return (
diff --git a/src/pages/TRip/index.astro b/src/pages/TRip/index.astro index d175729..5004cf4 100644 --- a/src/pages/TRip/index.astro +++ b/src/pages/TRip/index.astro @@ -6,8 +6,6 @@ import { requireAuthHook } from "@/hooks/requireAuthHook"; const user = await requireAuthHook(Astro); if (!user) { - const decodedUrl = decodeURIComponent(Astro.url.pathname + Astro.url.search); - Astro.cookies.set('returnTo', decodedUrl, { path: '/' }); return Astro.redirect('/login'); } diff --git a/src/pages/TRip/requests.astro b/src/pages/TRip/requests.astro index 8a8ae1a..d3dc836 100644 --- a/src/pages/TRip/requests.astro +++ b/src/pages/TRip/requests.astro @@ -6,8 +6,6 @@ import { requireAuthHook } from "@/hooks/requireAuthHook"; const user = await requireAuthHook(Astro); if (!user) { - const decodedUrl = decodeURIComponent(Astro.url.pathname + Astro.url.search); - Astro.cookies.set('returnTo', decodedUrl, { path: '/' }); return Astro.redirect('/login'); } diff --git a/src/pages/lighting.astro b/src/pages/lighting.astro index 3fc3228..6012c3f 100644 --- a/src/pages/lighting.astro +++ b/src/pages/lighting.astro @@ -6,8 +6,6 @@ import { requireAuthHook } from "@/hooks/requireAuthHook"; const user = await requireAuthHook(Astro); if (!user || !user.roles.includes('lighting')) { - const decodedUrl = decodeURIComponent(Astro.url.pathname + Astro.url.search); - Astro.cookies.set('returnTo', decodedUrl, { path: '/' }); return Astro.redirect('/login'); } --- diff --git a/src/pages/login.astro b/src/pages/login.astro index edab326..ecf7133 100644 --- a/src/pages/login.astro +++ b/src/pages/login.astro @@ -2,11 +2,15 @@ import LoginPage from '@/components/Login.jsx'; import Base from "@/layouts/Base.astro"; import Root from "@/components/AppLayout.jsx"; +import { requireAuthHook } from '@/hooks/requireAuthHook'; +const user = await requireAuthHook(Astro); +const isLoggedIn = Boolean(user); + ---
- +
\ No newline at end of file