routes/apiHandlers.js
/**
 * After the account approval, the user receive an email to continue the creation process.
 * We verify that the account is confirmed, confirm the email
 * and initialize his username if it's still available
 * Rejected accounts are marked as pending review
 */
After the account approval, the user receive an email to continue the creation process.
We verify that the account is confirmed, confirm the email
and initialize his username if it's still available
Rejected accounts are marked as pending review
After the account approval the user receive an email to continue the creation process . We verify that the account is confirmed confirm the email and initialize his username if it ' s still available Rejected accounts are marked as pending review
async function handleConfirmAccount(token) {
    const decoded = verifyToken(token, 'create_account');
    const user = await database.findUser({
        where: { email: decoded.email },
    });
    if (!user) {
        throw new ApiError({ type: 'error_api_user_exists_not' });
    }
    if (user.status === 'manual_review' || user.status === 'rejected') {
        throw new ApiError({
            type: 'error_api_account_verification_pending',
        });
    }
    if (user.status === 'created') {
        throw new ApiError({ type: 'error_api_account_created' });
    }
    if (user.status !== 'approved') {
        throw new ApiError({
            type: 'error_api_account_verification_pending',
        });
    }
    await database.updateUsers(
        {
            email_is_verified: true,
        },
        { where: { email: decoded.email } }
    );
    const userExists = await services.checkUsername(user.username);
    if (userExists) {
        return {
            success: true,
            username: '',
            reservedUsername: user.username,
            query: user.metadata.query,
            email: user.email,
            xref: user.tracking_id,
        };
    }
    return {
        success: true,
        username: user.username,
        reservedUsername: '',
        query: user.metadata.query,
        email: user.email,
        xref: user.tracking_id,
    };
}
async function handleConfirmAccount ( token ) { const decoded = verifyToken ( token , 'create_account' ) ; const user = await database . findUser ( { where : { email : decoded . email } , } ) ; if ( ! user ) { throw new ApiError ( { type : 'error_api_user_exists_not' } ) ; } if ( user . status === 'manual_review' || user . status === 'rejected' ) { throw new ApiError ( { type : 'error_api_account_verification_pending' , } ) ; } if ( user . status === 'created' ) { throw new ApiError ( { type : 'error_api_account_created' } ) ; } if ( user . status !== 'approved' ) { throw new ApiError ( { type : 'error_api_account_verification_pending' , } ) ; } await database . updateUsers ( { email_is_verified : true , } , { where : { email : decoded . email } } ) ; const userExists = await services . checkUsername ( user . username ) ; if ( userExists ) { return { success : true , username : '' , reservedUsername : user . username , query : user . metadata . query , email : user . email , xref : user . tracking_id , } ; } return { success : true , username : user . username , reservedUsername : '' , query : user . metadata . query , email : user . email , xref : user . tracking_id , } ; }
After the account approval, the user receive an email to continue the creation process.
After the account approval the user receive an email to continue the creation process .