All files / src/routes/users_routes user_changePassword_post.js

60% Statements 3/5
25% Branches 1/4
100% Functions 1/1
60% Lines 3/5

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            2x 2x 2x                
import UsersController from '../../controllers/users-controllers/UsersController.js';
import ErrorGenerator from '../../utilities/ErrorGenerator.js';
import asyncRouteHandler from '../../utilities/asyncRouteHandler.js';
 
export default asyncRouteHandler(
    async function user_changePassword_post(req, res, next) {
        const respond = await UsersController.changePassword(req.userId, req.body);
        if (respond) {
            res.status(200).json(respond);
        } else E{
            const message = respond === null
                ? "You have changed your password since less than a month, You can't change it again, Try again after a month since last change"
                : "Unexpected Error!"
            next(new ErrorGenerator(message, 400));
        }
    }
)