fix: add validation to prevent overwrite user

This commit is contained in:
Mauricio Siu
2024-09-01 19:12:26 -06:00
parent 1650e1bb74
commit 879311c332
6 changed files with 22 additions and 25 deletions

View File

@@ -129,13 +129,9 @@ export const getUserByToken = async (token: string) => {
message: "Invitation not found",
});
}
const now = new Date();
const isExpired = isAfter(now, new Date(user.expirationDate));
return {
...user,
isExpired,
isExpired: user.isRegistered,
};
};

View File

@@ -72,7 +72,7 @@ export const createUser = async (input: typeof apiCreateUser._type) => {
.update(users)
.set({
isRegistered: true,
expirationDate: new Date().toISOString(),
expirationDate: undefined,
})
.where(eq(users.token, input.token))
.returning()