import { ManagementClient } from "../../../clients" ; import { ResetVerificationParameters as Parameters , ResetVerificationRequest as Request } from "../../../common" ; import { throwOnPasswordPolicyViolation } from "../../../utilities" ; import { Verification } from "../../../verification" ; import { handler } from "../../_" ; import schema = require ( "../../../common/events/reset/verify/index.json" ) ; param event return export const post = handler < Parameters , Request > ( schema , async ( { pathParameters : { code } , body : { password } } ) => { throwOnPasswordPolicyViolation ( password ) ; try { const verification = new Verification ( ) ; const mgmt = new ManagementClient ( ) ; const { subject } = await verification . claim ( "reset" , code ) ; await mgmt . changePassword ( subject , password ) ; } catch ( err ) { err . statusCode = 403 ; throw err ; } } ) ;