maestro-server/server-app

View on GitHub
app/identity/services/validator/validPassMatch.js

Summary

Maintainability
A
25 mins
Test Coverage
A
100%
'use strict';

const PermissionError = require('core/errors/factoryError')('PermissionError');
const bcrypt = require('bcrypt');


module.exports = (password) => (obj) => {

    if(obj.hasOwnProperty('password')) {
        if(obj && bcrypt.compareSync(password, obj.password)) {
            return obj;
        }
    }

    throw new PermissionError("Invalid username or password");

};