All files / src/routes/root_routes emailVerification_post.js

85.71% Statements 6/7
50% Branches 2/4
100% Functions 1/1
85.71% Lines 6/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18              1x 1x 1x 1x 1x       1x    
import SystemController from "../../controllers/system-controller/SystemController.js";
import verificationEmailsCodesHandler from "../../controllers/system-controller/verificationEmailsCodesHandler.js";
import asyncRouteHandler from "../../utilities/asyncRouteHandler.js";
 
 
export default asyncRouteHandler(
    async function emailVerification_post(req, res) {
        const { verificationCode, userEmail } = req.body;
        const { status, response } = verificationEmailsCodesHandler({ verificationCode, userEmail })
        Eif (response.ok) {
            const verifyingRespond = await SystemController.verifyUserEmail(req.userId, userEmail)
            Iif (!verifyingRespond) {
                return res.status(400).json({ message: "Verifying your email failed for unknown reason" })
            }
        }
        res.status(status).json(response)
    }
)