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 => {
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)

View file

@ -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');