const bcrypt = require('bcryptjs');
const User = require('../../models/user');

function comparePass(userPassword, databasePassword) {
    return bcrypt.compareSync(userPassword, databasePassword);
}

function loginRedirect (req, res, next) {
    if (req.user) return res.redirect('/');
    return next();
}

function loginRequired(req, res, next) {
    if (req.user === undefined) {
        return res.redirect('/auth/login');
    }
    return next();
}

module.exports = {
    comparePass,
    loginRedirect,
    loginRequired,
}
const bcrypt = require('bcryptjs');
const User = require('../../models/user');

function comparePass(userPassword, databasePassword) {
    return bcrypt.compareSync(userPassword, databasePassword);
}

module.exports = {
    comparePass,
}
remove unused functions