React/Redux - publish component #323
2 changed files with 11 additions and 5 deletions
|
@ -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)
|
||||||
|
|
|
@ -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');
|
||||||
|
|
Loading…
Reference in a new issue