22 lines
650 B
JavaScript
22 lines
650 B
JavaScript
const AuthService = require('../services/auth.service');
|
|
|
|
class AuthController {
|
|
async login(req, res) {
|
|
if (req.sheepId) {
|
|
const result = await AuthService.findUserByID(req.sheepId, req.mode);
|
|
if (result) {
|
|
return res.status(200).send(result);
|
|
} else {
|
|
return res.status(404).send({
|
|
message: 'Sheep not found.'
|
|
});
|
|
}
|
|
} else {
|
|
return res
|
|
.status(403)
|
|
.send({ message: 'The sheep does not have enough rights.' });
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = new AuthController(); |