const importcontroller = require('./importcontroller');

class LoginController {
    async login(params) {
        try {
            const user = await importcontroller.login.findOne({
                where: {
                    username: params.username,
                    password: params.password
                }
            })
            if(!user) {
                throw {}
            }
            return user;
        } catch (err) {
            throw { message: "Invalid username or password" };
        }
    }
};

module.exports = new LoginController();