testing custom callback for /signup

This commit is contained in:
bill bittner 2018-03-15 17:03:02 -07:00
parent 697b5eebed
commit aa5dd711de
3 changed files with 27 additions and 11 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -3,19 +3,35 @@ const passport = require('passport');
module.exports = (app) => { module.exports = (app) => {
// route for sign up // route for sign up
app.post('/signup', passport.authenticate('local-signup'), (req, res) => { app.post('/signup', (req, res, next) => {
passport.authenticate('local-signup', (err, user, info) => {
logger.verbose(`successful signup for ${req.user.channelName}`); logger.verbose(`successful signup for ${req.user.channelName}`);
if (err) {
console.log('err >> err:', err);
return res.status(400).json({
success: false,
message: info.message,
});
}
if (!user) {
console.log('!user >> info:', info);
return res.status(400).json({
success: false,
message: info.message,
});
}
res.status(200).json({ res.status(200).json({
success : true, success : true,
channelName : req.user.channelName, channelName : req.user.channelName,
channelClaimId: req.user.channelClaimId, channelClaimId: req.user.channelClaimId,
shortChannelId: req.user.shortChannelId, shortChannelId: req.user.shortChannelId,
}); });
})(req, res, next);
}); });
// route for log in // route for log in
app.post('/login', (req, res, next) => { app.post('/login', (req, res, next) => {
passport.authenticate('local-login', (err, user, info) => { passport.authenticate('local-login', (err, user, info) => {
logger.debug('info:', info); logger.verbose('login info:', info);
if (err) { if (err) {
return next(err); return next(err);
} }