mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
refactor: update
This commit is contained in:
@@ -143,27 +143,26 @@ export const findAdmin = async () => {
|
||||
};
|
||||
|
||||
export const getUserByToken = async (token: string) => {
|
||||
const user = await db.query.users.findFirst({
|
||||
where: eq(users.token, token),
|
||||
with: {
|
||||
auth: {
|
||||
columns: {
|
||||
password: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (!user) {
|
||||
throw new TRPCError({
|
||||
code: "NOT_FOUND",
|
||||
message: "Invitation not found",
|
||||
});
|
||||
}
|
||||
return {
|
||||
...user,
|
||||
isExpired: user.isRegistered,
|
||||
};
|
||||
// const user = await db.query.users.findFirst({
|
||||
// where: eq(users.token, token),
|
||||
// with: {
|
||||
// auth: {
|
||||
// columns: {
|
||||
// password: false,
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// });
|
||||
// if (!user) {
|
||||
// throw new TRPCError({
|
||||
// code: "NOT_FOUND",
|
||||
// message: "Invitation not found",
|
||||
// });
|
||||
// }
|
||||
// return {
|
||||
// ...user,
|
||||
// isExpired: user.isRegistered,
|
||||
// };
|
||||
};
|
||||
|
||||
export const removeUserById = async (userId: string) => {
|
||||
@@ -181,9 +180,9 @@ export const removeAdminByAuthId = async (authId: string) => {
|
||||
// First delete all associated users
|
||||
const users = admin.users;
|
||||
|
||||
for (const user of users) {
|
||||
await removeUserById(user.id);
|
||||
}
|
||||
// for (const user of users) {
|
||||
// await removeUserById(user.id);
|
||||
// }
|
||||
// Then delete the auth record which will cascade delete the admin
|
||||
return await db
|
||||
.delete(auth)
|
||||
|
||||
@@ -33,20 +33,6 @@ export const findUserByAuthId = async (authId: string) => {
|
||||
// return userR;
|
||||
};
|
||||
|
||||
export const findUsers = async (adminId: string) => {
|
||||
const currentUsers = await db.query.user.findMany({
|
||||
where: eq(user.adminId, adminId),
|
||||
with: {
|
||||
auth: {
|
||||
columns: {
|
||||
secret: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
return currentUsers;
|
||||
};
|
||||
|
||||
export const addNewProject = async (userId: string, projectId: string) => {
|
||||
const userR = await findUserById(userId);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user