mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-24 17:51:51 +02:00
Migrate renderRequestResetForm to zod
GitOrigin-RevId: 9ae9eb6ea1bc2966406938b130e7e2410e770163
This commit is contained in:
@@ -8,6 +8,7 @@ import UserSessionsManager from '../User/UserSessionsManager.js'
|
||||
import OError from '@overleaf/o-error'
|
||||
import EmailsHelper from '../Helpers/EmailHelper.js'
|
||||
import { expressify } from '@overleaf/promise-utils'
|
||||
import { z, validateReq } from '../../infrastructure/Validation.js'
|
||||
|
||||
async function setNewUserPassword(req, res, next) {
|
||||
let user
|
||||
@@ -195,8 +196,15 @@ async function renderSetPasswordForm(req, res, next) {
|
||||
})
|
||||
}
|
||||
|
||||
const renderRequestResetFormSchema = z.object({
|
||||
query: z.object({
|
||||
error: z.string().optional(),
|
||||
}),
|
||||
})
|
||||
|
||||
async function renderRequestResetForm(req, res) {
|
||||
const errorQuery = req.query.error
|
||||
const { query } = validateReq(req, renderRequestResetFormSchema)
|
||||
const errorQuery = query.error
|
||||
let error = null
|
||||
if (errorQuery === 'token_expired') {
|
||||
error = 'password_reset_token_expired'
|
||||
|
||||
@@ -18,9 +18,6 @@ export default {
|
||||
|
||||
webRouter.get(
|
||||
'/user/password/reset',
|
||||
validate({
|
||||
query: { error: Joi.string() },
|
||||
}),
|
||||
PasswordResetController.renderRequestResetForm
|
||||
)
|
||||
webRouter.post(
|
||||
|
||||
Reference in New Issue
Block a user