fixed error message on login

This commit is contained in:
bill bittner 2018-01-25 11:48:27 -08:00
parent a9d9a88360
commit 1f78a50b48
2 changed files with 11 additions and 5 deletions

View file

@ -37,7 +37,7 @@ module.exports = new PassportLocalStrategy(
.then(user => { .then(user => {
if (!user) { if (!user) {
// logger.debug('no user found'); // 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) => { user.comparePassword(password, (passwordErr, isMatch) => {
if (passwordErr) { if (passwordErr) {
@ -46,7 +46,7 @@ module.exports = new PassportLocalStrategy(
} }
if (!isMatch) { if (!isMatch) {
// logger.debug('incorrect password'); // 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'); logger.debug('Password was a match, returning User');
return returnUserAndChannelInfo(user) return returnUserAndChannelInfo(user)

View file

@ -14,6 +14,7 @@ function loginToChannel (event) {
credentials: 'include', credentials: 'include',
}) })
.then(function(response) { .then(function(response) {
console.log(response);
if (response.ok){ if (response.ok){
return response.json(); return response.json();
} else { } else {
@ -24,12 +25,17 @@ function loginToChannel (event) {
throw error; throw error;
}) })
}) })
.then(result => { .then(function({success, message}) {
if (success) {
window.location = '/'; window.location = '/';
} else {
throw new Error(message);
}
}) })
.catch(error => { .catch(error => {
const loginErrorDisplayElement = document.getElementById('login-error-display-element'); const loginErrorDisplayElement = document.getElementById('login-error-display-element');
if (error.name){ if (error.message){
validationFunctions.showError(loginErrorDisplayElement, error.message); validationFunctions.showError(loginErrorDisplayElement, error.message);
} else { } else {
validationFunctions.showError(loginErrorDisplayElement, 'There was an error logging into your channel'); validationFunctions.showError(loginErrorDisplayElement, 'There was an error logging into your channel');