mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 06:33:55 +01: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 OError from '@overleaf/o-error'
|
||||||
import EmailsHelper from '../Helpers/EmailHelper.js'
|
import EmailsHelper from '../Helpers/EmailHelper.js'
|
||||||
import { expressify } from '@overleaf/promise-utils'
|
import { expressify } from '@overleaf/promise-utils'
|
||||||
|
import { z, validateReq } from '../../infrastructure/Validation.js'
|
||||||
|
|
||||||
async function setNewUserPassword(req, res, next) {
|
async function setNewUserPassword(req, res, next) {
|
||||||
let user
|
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) {
|
async function renderRequestResetForm(req, res) {
|
||||||
const errorQuery = req.query.error
|
const { query } = validateReq(req, renderRequestResetFormSchema)
|
||||||
|
const errorQuery = query.error
|
||||||
let error = null
|
let error = null
|
||||||
if (errorQuery === 'token_expired') {
|
if (errorQuery === 'token_expired') {
|
||||||
error = 'password_reset_token_expired'
|
error = 'password_reset_token_expired'
|
||||||
|
|||||||
@@ -18,9 +18,6 @@ export default {
|
|||||||
|
|
||||||
webRouter.get(
|
webRouter.get(
|
||||||
'/user/password/reset',
|
'/user/password/reset',
|
||||||
validate({
|
|
||||||
query: { error: Joi.string() },
|
|
||||||
}),
|
|
||||||
PasswordResetController.renderRequestResetForm
|
PasswordResetController.renderRequestResetForm
|
||||||
)
|
)
|
||||||
webRouter.post(
|
webRouter.post(
|
||||||
|
|||||||
Reference in New Issue
Block a user