import { Request , Response } from "@architect/shared/architect-types" ; import { STATUSES , CONTENT_TYPES , stringify , log , ObjectLiteral , } from "@architect/shared/utils" ; import { webAppResponse , layoutPage } from "@architect/views/page-layout" ; import redirect from "@architect/shared/redirect" ; import arc from "@architect/functions" ; import { dbOperation } from "@architect/shared/documentdb" ; import assert from "assert" ; import config from "@architect/shared/config" ; export async function handler ( request ) { const passwordResetToken = request . pathParameters . token ; assert ( passwordResetToken ) ; const now = Date . now ( ) ; let person ; try { person = await dbOperation ( function ( database ) { return database . collection ( "people" ) . findOne ( { passwordResetToken , passwordResetTokenExpires : { $gte : now } , } ) ; } ) ; } catch ( error ) { log ( `Error getting person for password reset token ${ error . message }` ) ; return redirect ( "/forgot" ) ; } if ( ! person ) { log ( `Could not find person matching password reset token ${ passwordResetToken }` ) ; return redirect ( "/forgot" ) ; } return webAppResponse ; }