updated login page validation

This commit is contained in:
bill bittner 2017-09-20 10:14:00 -07:00
parent 0575e9853f
commit 1a502c6ad8
4 changed files with 13 additions and 11 deletions

View file

@ -14,14 +14,14 @@ module.exports = new PassportLocalStrategy(
return db.User
.findOne({where: {channelName: username}})
.then(user => {
logger.debug('user', user.dataValues);
if (!user) {
return done(null, false, {message: 'Incorrect username or password.'});
}
if (!user.validPassword(password, user.password)) {
return done(null, false, {message: 'Incorrect username or password.'});
}
return done(null, user); // user.dataValues?
logger.debug('user', user.dataValues);
return done(null, user);
})
.catch(error => {
return done(error);

View file

@ -14,8 +14,8 @@ module.exports = new PassportLocalStrategy(
(req, username, password, done) => {
logger.debug('new channel signup request');
const address = config.get('WalletConfig.LbryClaimAddress');
// validate raw inputs (username, password)
username = '@' + username;
// server-side validaton of raw inputs (username, password)
// create the channel and retrieve the metadata
return lbryApi.createChannel(username)
.then(channelTx => {

View file

@ -26,7 +26,7 @@ function sendSignupRequest (channelName, password) {
}
function publishNewChannel (event) {
const channelName = document.getElementById('new-channel-name').value;
const channelName = `@${document.getElementById('new-channel-name').value}`;
const password = document.getElementById('new-channel-password').value;
const channelNameErrorDisplayElement = document.getElementById('input-error-channel-name');
const passwordErrorDisplayElement = document.getElementById('input-error-password');
@ -40,7 +40,7 @@ function publishNewChannel (event) {
.then(() => {
console.log('success');
document.getElementById('signup-form').innerHTML = '<p>Your channel has been successfully created! Redirecting you now...</p>';
window.location.href = '/channelName';
window.location.href = `/${channelName}`;
})
.catch(error => {
if (error.name === 'ChannelNameError'){

View file

@ -56,7 +56,7 @@ function validateChannelName (name) {
function validatePassword (password) {
if (password.length < 1) {
throw new ChannelNameError("You must enter a password for you channel");
throw new ChannelPasswordError("You must enter a password for you channel");
}
}
@ -172,10 +172,10 @@ function validateFilePublishSubmission(stagedFiles, claimName, channelName){
}
// if all validation passes, check availability of the name
isNameAvailable(claimName, '/api/isClaimAvailable/')
.then(function() {
.then(() => {
resolve();
})
.catch(function(error) {
.catch(error => {
reject(error);
});
});
@ -198,10 +198,12 @@ function validateNewChannelSubmission(channelName, password){
}
// 3. if all validation passes, check availability of the name
isNameAvailable(channelName, '/api/isChannelAvailable/') // validate the availability
.then(function() {
.then(() => {
console.log('channel is avaliable');
resolve();
})
.catch(function(error) {
.catch( error => {
console.log('error: channel is not avaliable');
reject(error);
});
});