refactor: update

This commit is contained in:
Mauricio Siu
2025-02-16 13:28:29 -06:00
parent 27736c7c97
commit a8d1471b16
14 changed files with 133 additions and 294 deletions

View File

@@ -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)

View File

@@ -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);