spee.ch/server/controllers/auth/login/index.js

29 lines
699 B
JavaScript
Raw Normal View History

const speechPassport = require('../../../speechPassport/index');
2018-03-29 20:40:47 +02:00
const login = (req, res, next) => {
speechPassport.authenticate('local-login', (err, user, info) => {
if (err) {
return next(err);
}
if (!user) {
return res.status(400).json({
success: false,
message: info.message,
});
}
req.logIn(user, (err) => {
2018-03-29 07:06:08 +02:00
if (err) {
return next(err);
}
2018-03-29 20:40:47 +02:00
return res.status(200).json({
success : true,
channelName : req.user.channelName,
channelClaimId: req.user.channelClaimId,
shortChannelId: req.user.shortChannelId,
2018-03-29 07:06:08 +02:00
});
2018-03-29 20:40:47 +02:00
});
})(req, res, next);
2018-03-29 07:06:08 +02:00
};
module.exports = login;