mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-12 13:13:45 +01:00
Migrate setNewUserPassword to zod
GitOrigin-RevId: 5f5b66baac696a36d4989de3b76e46279da8f53c
This commit is contained in:
@@ -10,9 +10,17 @@ import EmailsHelper from '../Helpers/EmailHelper.js'
|
||||
import { expressify } from '@overleaf/promise-utils'
|
||||
import { z, validateReq } from '../../infrastructure/Validation.js'
|
||||
|
||||
const setNewUserPasswordSchema = z.object({
|
||||
body: z.object({
|
||||
password: z.string(),
|
||||
passwordResetToken: z.string(),
|
||||
}),
|
||||
})
|
||||
|
||||
async function setNewUserPassword(req, res, next) {
|
||||
let user
|
||||
let { passwordResetToken, password, email } = req.body
|
||||
const { body } = validateReq(req, setNewUserPasswordSchema)
|
||||
let { passwordResetToken, password, email } = body
|
||||
if (!passwordResetToken || !password) {
|
||||
return res.status(400).json({
|
||||
message: {
|
||||
|
||||
@@ -3,7 +3,6 @@ import AuthenticationController from '../Authentication/AuthenticationController
|
||||
import CaptchaMiddleware from '../../Features/Captcha/CaptchaMiddleware.mjs'
|
||||
import { RateLimiter } from '../../infrastructure/RateLimiter.js'
|
||||
import RateLimiterMiddleware from '../Security/RateLimiterMiddleware.js'
|
||||
import { Joi, validate } from '../../infrastructure/Validation.js'
|
||||
|
||||
const rateLimiter = new RateLimiter('password_reset_rate_limit', {
|
||||
points: 6,
|
||||
@@ -35,12 +34,6 @@ export default {
|
||||
)
|
||||
webRouter.post(
|
||||
'/user/password/set',
|
||||
validate({
|
||||
body: Joi.object({
|
||||
password: Joi.string().required(),
|
||||
passwordResetToken: Joi.string().required(),
|
||||
}),
|
||||
}),
|
||||
rateLimit,
|
||||
PasswordResetController.setNewUserPassword
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user