fix: Validate identifier payload for reset password (#9302)
Closes CC-526
This commit is contained in:
@@ -4,13 +4,14 @@ import {
|
||||
AuthenticatedMedusaRequest,
|
||||
MedusaResponse,
|
||||
} from "../../../../../types/routing"
|
||||
import { ResetPasswordRequestType } from "../../../validators"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest,
|
||||
req: AuthenticatedMedusaRequest<ResetPasswordRequestType>,
|
||||
res: MedusaResponse
|
||||
) => {
|
||||
const { auth_provider, actor_type } = req.params
|
||||
const { identifier } = req.body
|
||||
const { identifier } = req.validatedBody
|
||||
|
||||
const { http } = req.scope.resolve(
|
||||
ContainerRegistrationKeys.CONFIG_MODULE
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { authenticate, MiddlewareRoute } from "@medusajs/framework/http"
|
||||
import { validateAndTransformBody } from "../utils/validate-body"
|
||||
import { validateScopeProviderAssociation } from "./utils/validate-scope-provider-association"
|
||||
import { validateToken } from "./utils/validate-token"
|
||||
import { ResetPasswordRequest } from "./validators"
|
||||
|
||||
export const authRoutesMiddlewares: MiddlewareRoute[] = [
|
||||
{
|
||||
@@ -41,7 +43,10 @@ export const authRoutesMiddlewares: MiddlewareRoute[] = [
|
||||
{
|
||||
method: ["POST"],
|
||||
matcher: "/auth/:actor_type/:auth_provider/reset-password",
|
||||
middlewares: [validateScopeProviderAssociation()],
|
||||
middlewares: [
|
||||
validateScopeProviderAssociation(),
|
||||
validateAndTransformBody(ResetPasswordRequest),
|
||||
],
|
||||
},
|
||||
{
|
||||
method: ["POST"],
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
import { z } from "zod"
|
||||
|
||||
export const ResetPasswordRequest = z.object({
|
||||
identifier: z.string(),
|
||||
})
|
||||
export type ResetPasswordRequestType = z.infer<typeof ResetPasswordRequest>
|
||||
Reference in New Issue
Block a user