routes/apiHandlers.js
// TODO: this should be a POST request like all other api calls
this should be a POST request like all other api calls
this should be a POST request like all other api calls
async function handleConfirmEmail(req) {
    const decoded = verifyToken(req.query.token, 'confirm_email');
    const user = await database.findUser({
        where: { email: decoded.email },
    });
    if (!user) {
        throw new ApiError({ type: 'error_api_email_exists_not' });
    }
    const token = jwt.sign(
        {
            type: 'signup',
            email: decoded.email,
        },
        process.env.JWT_SECRET
    );
    if (!user.email_is_verified) {
        user.email_is_verified = true;
        await user.save();
        await finalizeSignup(user, req);
    }
    return {
        approved: user.approved,
        completed: user.phone_number_is_verified && user.email_is_verified,
        email: user.email,
        success: true,
        token,
        username: user.username,
        xref: user.tracking_id,
    };
}
async function handleConfirmEmail ( req ) { const decoded = verifyToken ( req . query . token , 'confirm_email' ) ; const user = await database . findUser ( { where : { email : decoded . email } , } ) ; if ( ! user ) { throw new ApiError ( { type : 'error_api_email_exists_not' } ) ; } const token = jwt . sign ( { type : 'signup' , email : decoded . email , } , process . env . JWT_SECRET ) ; if ( ! user . email_is_verified ) { user . email_is_verified = true ; await user . save ( ) ; await finalizeSignup ( user , req ) ; } return { approved : user . approved , completed : user . phone_number_is_verified && user . email_is_verified , email : user . email , success : true , token , username : user . username , xref : user . tracking_id , } ; }
TODO: this should be a POST request like all other api calls
TODO : this should be a POST request like all other api calls