library-ts/node/users/handlers/_/confirm-signup.ts

32 lines
866 B
TypeScript

import { CryptIO } from "../../../crypt/CryptIO";
import { RJLog } from "../../../log/RJLog";
import { RequestHandler, RequestType } from "../../RequestHandler";
import { FastifyRequest, FastifyReply } from 'fastify';
export class ConfirmSignUpHandler extends RequestHandler
{
static url = "/confirm-signup";
constructor(){ super( RequestType.GET, ConfirmSignUpHandler.url ); }
async _handle( request:FastifyRequest, reply:FastifyReply )
{
const { id, token } = request.query as { id?: string; token?: string };
if ( ! id || ! token )
{
return this.sendError( "Missing id or token" );
}
let result = await this.userDB.confirmUserSignUp( id, token, this.ip );
if ( ! result )
{
return this.sendError( "User signup confimration failed" );
}
return this.sendInfo( "User creation confirmed" );
}
}