Skip to content
This repository was archived by the owner on Dec 10, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/app/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ export default async function AppLayout({
}
const mustShowOOB = await api.user.mustShowOOB(session?.user.session_user.id)
const user = await api.user.getUser().catch(async ()=>{
// Redirect the user to the sign-in page if the user is not found
redirect("/api/auth/signin")
// If the user is not found, redirect the user to the sign-out page
// to clear session after that redirect to sign-in page if the user
// is not found
redirect("/auth/signout?forced=true")
})
if(!user){
redirect("/")
Expand Down Expand Up @@ -91,4 +93,4 @@ export default async function AppLayout({
</SidebarProvider>
</HydrateClient>
)
}
}
2 changes: 1 addition & 1 deletion src/app/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default function App(){
const [size, setSize] = useState<number>(0)

const router = useRouter()
const handler = async (path: string) => {
const handler = (path: string) => {
router.push(path + "?" + params.toString())
}

Expand Down
12 changes: 9 additions & 3 deletions src/app/auth/signout/page.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
'use client'
import {signOut} from "next-auth/react";
import {useEffect, useState} from "react";
import {Suspense, useEffect, useState} from "react";
import Link from "next/link";
import {Button} from "@/components/ui/button";
import {useParams} from "next/navigation";

export default function SignOutPage(){
const params = useParams<{forced: string}>()
useEffect(() => {
if(window){
void signOut({redirect: false})
// this is needed to fix infinity redirect bug if creds are not valid
if(params.forced === "true"){
void signOut({redirectTo: "/auth/signin", redirect: true})
}
void signOut({redirect: false})
}
}, []);
return(
Expand All @@ -21,4 +27,4 @@ export default function SignOutPage(){
</div>
</div>
)
}
}
10 changes: 7 additions & 3 deletions src/app/user/pw-reset/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export default function Page(){
toast.error("Ther was an error changing your password, please try again.");
}
})
function handleSubmit(){
function handleSubmit(event: Event){
event.preventDefault()
if(!newPW.current || !repeatPW.current || !oldPW.current){
toast.error("Please fill in all fields.");
return;
Expand All @@ -55,6 +56,7 @@ export default function Page(){
newPassword: newPW.current.value,
repeatPassword: repeatPW.current.value
});

}
return (
<div className="flex justify-center items-center h-screen">
Expand All @@ -68,6 +70,7 @@ export default function Page(){
<CardDescription>
You must reset your password before you can continue.
</CardDescription>
<form onSubmit={handleSubmit}>
<div className="flex flex-col gap-2">
<label htmlFor="current-password">Current Password</label>
<Input
Expand All @@ -90,11 +93,12 @@ export default function Page(){
name="repeat-password"
ref={repeatPW}
/>
<Button type="submit">Change Password</Button>
</div>
<Button type="submit" onClick={handleSubmit}>Change Password</Button>
</form>
</CardContent>
</Card>
<Toaster richColors={true} />
</div>
)
}
}