import { schema } from '@kbn/config-schema' ; import type { RouteDefinitionParams } from '.' ; export function defineVerifyRoute ( { router , verificationCode } ) { router . post ( { path : '/internal/interactive_setup/verify' , validate : { body : schema . object ( { code : schema . string ( ) , } ) , } , options : { authRequired : false } , } , async ( context , request , response ) => { if ( ! verificationCode . verify ( request . body . code ) ) { return response . forbidden ( { body : { message : verificationCode . remainingAttempts ? 'Invalid verification code.' : 'Maximum number of attempts exceeded. Restart Kibana to generate a new code and retry.' , attributes : { remainingAttempts : verificationCode . remainingAttempts , } , } , } ) ; } return response . noContent ( ) ; } ) ; }