mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 08:28:19 +01:00
refactor(api): ♻️ Remove password2 from password resets (done on client)
This commit is contained in:
parent
0645203d97
commit
d4894c362e
|
|
@ -24,7 +24,6 @@ export const schemas = {
|
||||||
form: z.object({
|
form: z.object({
|
||||||
token: z.string().min(1),
|
token: z.string().min(1),
|
||||||
password: z.string().min(3).max(100),
|
password: z.string().min(3).max(100),
|
||||||
password2: z.string().min(3).max(100),
|
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -51,7 +50,7 @@ export default (app: Hono) =>
|
||||||
meta.route,
|
meta.route,
|
||||||
zValidator("form", schemas.form, handleZodError),
|
zValidator("form", schemas.form, handleZodError),
|
||||||
async (context) => {
|
async (context) => {
|
||||||
const { token, password, password2 } = context.req.valid("form");
|
const { token, password } = context.req.valid("form");
|
||||||
|
|
||||||
const user = await User.fromSql(
|
const user = await User.fromSql(
|
||||||
eq(Users.passwordResetToken, token),
|
eq(Users.passwordResetToken, token),
|
||||||
|
|
@ -61,14 +60,6 @@ export default (app: Hono) =>
|
||||||
return returnError(token, "invalid_token", "Invalid token");
|
return returnError(token, "invalid_token", "Invalid token");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (password !== password2) {
|
|
||||||
return returnError(
|
|
||||||
token,
|
|
||||||
"password_mismatch",
|
|
||||||
"Passwords do not match",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
await user.update({
|
await user.update({
|
||||||
password: await Bun.password.hash(password),
|
password: await Bun.password.hash(password),
|
||||||
passwordResetToken: null,
|
passwordResetToken: null,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue