First Commit. Duplicate bunext-sqlite preset
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import { AppData } from "@/src/data/app-data";
|
||||
import userAuth from "@/src/functions/backend/auth/user-auth";
|
||||
import logEvent, { grabRequestIP } from "@/src/functions/backend/logger";
|
||||
import { deleteCookies } from "@/src/utils/cookies";
|
||||
import type { BunextPageServerFn } from "@moduletrace/bunext/types";
|
||||
|
||||
export const server: BunextPageServerFn = async ({ req }) => {
|
||||
const { user } = await userAuth({ req });
|
||||
|
||||
if (user?.id) {
|
||||
await logEvent({
|
||||
title: "User logged out",
|
||||
category: "auth",
|
||||
user_id: user.id,
|
||||
plain_text: `User #${user.id} [${user.first_name} ${user.last_name}] logged out.`,
|
||||
metadata: {
|
||||
user_id: user.id,
|
||||
},
|
||||
ip_address: grabRequestIP(req),
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
res_transform(res) {
|
||||
const new_res = res.clone();
|
||||
deleteCookies(new_res, [
|
||||
{
|
||||
name: AppData["AuthKeyCookieName"],
|
||||
httpOnly: true,
|
||||
},
|
||||
{
|
||||
name: AppData["AuthCSRFCookieName"],
|
||||
httpOnly: true,
|
||||
},
|
||||
{
|
||||
name: AppData["SSOAuthCookieName"],
|
||||
httpOnly: true,
|
||||
},
|
||||
]);
|
||||
return new_res;
|
||||
},
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,47 @@
|
||||
import type { BunextPageModuleMeta } from "@moduletrace/bunext/types";
|
||||
import Section from "@moduletrace/twui/layout/Section";
|
||||
import Loading from "@moduletrace/twui/elements/Loading";
|
||||
import Row from "@moduletrace/twui/layout/Row";
|
||||
import Span from "@moduletrace/twui/layout/Span";
|
||||
import { useEffect } from "react";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
import Logo from "@/src/components/general/logo";
|
||||
import Paper from "@moduletrace/twui/elements/Paper";
|
||||
import Container from "@moduletrace/twui/layout/Container";
|
||||
import Center from "@moduletrace/twui/layout/Center";
|
||||
import { SiteData } from "@/src/data/site-data";
|
||||
|
||||
export default function LogoutPage() {
|
||||
useEffect(() => {
|
||||
setTimeout(() => {
|
||||
window.location.pathname = "/";
|
||||
}, 1000);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Section
|
||||
className={twMerge(
|
||||
"h-screen w-screen px-0 items-center justify-center",
|
||||
)}
|
||||
>
|
||||
<Center>
|
||||
<Paper className="w-auto p-10 items-center">
|
||||
<Logo
|
||||
text_props={{
|
||||
className: "text-dark dark:text-white",
|
||||
}}
|
||||
/>
|
||||
<Row>
|
||||
<Loading />
|
||||
<Span>Logging out ...</Span>
|
||||
</Row>
|
||||
</Paper>
|
||||
</Center>
|
||||
</Section>
|
||||
);
|
||||
}
|
||||
|
||||
export const meta: BunextPageModuleMeta = {
|
||||
title: `Logging Out | ${SiteData["SiteName"]}`,
|
||||
description: "You are being logged out and redirected to the homepage.",
|
||||
};
|
||||
Reference in New Issue
Block a user