28 lines
758 B
TypeScript
28 lines
758 B
TypeScript
import userAuth from "@/src/functions/backend/auth/user-auth";
|
|
import grabUsers from "@/src/functions/backend/db/users/grab-users";
|
|
import type { PagePropsType } from "@/src/types";
|
|
import type { BunextPageServerFn } from "@moduletrace/bunext/types";
|
|
|
|
const server: BunextPageServerFn<PagePropsType> = async ({ req }) => {
|
|
const { user } = await userAuth({ req });
|
|
|
|
if (!user?.logged_in_status || !user.id) {
|
|
return {
|
|
redirect: {
|
|
destination: "/auth/login",
|
|
permanent: false,
|
|
},
|
|
};
|
|
}
|
|
|
|
const user_res = await grabUsers({ user_id: user.id });
|
|
|
|
return {
|
|
props: {
|
|
single_user: user_res.singleRes || null,
|
|
},
|
|
};
|
|
};
|
|
|
|
export default server;
|