spee.ch/server/routes/auth/login.js

29 lines
690 B
JavaScript
Raw Normal View History

2018-04-18 21:01:26 +02:00
const speechPassport = require('../../speechPassport');
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;