mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
refactor: update validation
This commit is contained in:
parent
55abac3f2f
commit
6ec60b6bab
@ -59,6 +59,14 @@ export const validateRequest = async (request: IncomingMessage) => {
|
||||
}),
|
||||
});
|
||||
|
||||
if (!session?.session || !session.user) {
|
||||
return {
|
||||
session: null,
|
||||
user: null,
|
||||
};
|
||||
}
|
||||
|
||||
if (session?.user) {
|
||||
if (session?.user.role === "user") {
|
||||
const owner = await db.query.member.findFirst({
|
||||
where: eq(schema.member.userId, session.user.id),
|
||||
@ -71,14 +79,8 @@ export const validateRequest = async (request: IncomingMessage) => {
|
||||
session.user.ownerId = owner.organization.ownerId;
|
||||
}
|
||||
} else {
|
||||
session.user.ownerId = session?.user.id;
|
||||
session.user.ownerId = session?.user?.id || "";
|
||||
}
|
||||
|
||||
if (!session?.session || !session.user) {
|
||||
return {
|
||||
session: null,
|
||||
user: null,
|
||||
};
|
||||
}
|
||||
|
||||
return session;
|
||||
|
@ -14,7 +14,7 @@ import { IS_CLOUD } from "../constants";
|
||||
export type Admin = typeof users_temp.$inferSelect;
|
||||
export const createInvitation = async (
|
||||
input: typeof apiCreateUserInvitation._type,
|
||||
adminId: string,
|
||||
adminId: string
|
||||
) => {
|
||||
await db.transaction(async (tx) => {
|
||||
const result = await tx
|
||||
@ -79,7 +79,7 @@ export const updateUser = async (userId: string, userData: Partial<Admin>) => {
|
||||
|
||||
export const updateAdminById = async (
|
||||
adminId: string,
|
||||
adminData: Partial<Admin>,
|
||||
adminData: Partial<Admin>
|
||||
) => {
|
||||
const admin = await db
|
||||
.update(admins)
|
||||
@ -101,8 +101,8 @@ export const findAdminById = async (userId: string) => {
|
||||
};
|
||||
|
||||
export const isAdminPresent = async () => {
|
||||
const admin = await db.query.user.findFirst({
|
||||
where: eq(user.role, "admin"),
|
||||
const admin = await db.query.users_temp.findFirst({
|
||||
where: eq(users_temp.role, "admin"),
|
||||
});
|
||||
if (!admin) {
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user