43 lines
1.0 KiB
TypeScript
43 lines
1.0 KiB
TypeScript
import checkUserAccess from "@/src/functions/backend/auth/check-user-access";
|
|
import userAuth from "@/src/functions/backend/auth/user-auth";
|
|
import grabSystemSetupStatus, {
|
|
type SystemSetupStatus,
|
|
} from "@/src/functions/backend/setup/grab-system-setup-status";
|
|
import type {
|
|
APIResponseObject,
|
|
BunextAPIRouteHandler,
|
|
} from "@moduletrace/bunext/types";
|
|
|
|
export const handler: BunextAPIRouteHandler<
|
|
APIResponseObject<SystemSetupStatus>
|
|
> = async ({ req }) => {
|
|
if (req.method !== "GET") {
|
|
return {
|
|
success: false,
|
|
};
|
|
}
|
|
|
|
const { user, user_types } = await userAuth({ req });
|
|
|
|
if (!user?.logged_in_status) {
|
|
return {
|
|
success: false,
|
|
msg: `Unauthorized`,
|
|
logoutUser: true,
|
|
};
|
|
}
|
|
|
|
const is_super_admin = checkUserAccess({ user_types });
|
|
|
|
if (!is_super_admin.success) {
|
|
return {
|
|
success: false,
|
|
msg: `Unauthorized`,
|
|
};
|
|
}
|
|
|
|
return {
|
|
success: true,
|
|
singleRes: grabSystemSetupStatus(),
|
|
};
|
|
}; |