diff --git a/passport/local-login.js b/passport/local-login.js index e3d72e88..7263b455 100644 --- a/passport/local-login.js +++ b/passport/local-login.js @@ -37,7 +37,7 @@ module.exports = new PassportLocalStrategy( .then(user => { if (!user) { // logger.debug('no user found'); - return done(null, false, {message: 'Incorrect username or password.'}); + return done(null, false, {message: 'Incorrect username or password'}); } user.comparePassword(password, (passwordErr, isMatch) => { if (passwordErr) { @@ -46,7 +46,7 @@ module.exports = new PassportLocalStrategy( } if (!isMatch) { // logger.debug('incorrect password'); - return done(null, false, {message: 'Incorrect username or password.'}); + return done(null, false, {message: 'Incorrect username or password'}); } logger.debug('Password was a match, returning User'); return returnUserAndChannelInfo(user) diff --git a/public/assets/js/loginFunctions.js b/public/assets/js/loginFunctions.js index 69cd0bd4..b13710ab 100644 --- a/public/assets/js/loginFunctions.js +++ b/public/assets/js/loginFunctions.js @@ -14,6 +14,7 @@ function loginToChannel (event) { credentials: 'include', }) .then(function(response) { + console.log(response); if (response.ok){ return response.json(); } else { @@ -24,12 +25,17 @@ function loginToChannel (event) { throw error; }) }) - .then(result => { - window.location = '/'; + .then(function({success, message}) { + if (success) { + window.location = '/'; + } else { + throw new Error(message); + } + }) .catch(error => { const loginErrorDisplayElement = document.getElementById('login-error-display-element'); - if (error.name){ + if (error.message){ validationFunctions.showError(loginErrorDisplayElement, error.message); } else { validationFunctions.showError(loginErrorDisplayElement, 'There was an error logging into your channel');