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

32 lines
857 B
TypeScript
Raw Normal View History

2025-11-10 17:41:48 +00:00
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" );
}
}