Redesign 1 bcrypt #226

Merged
bones7242 merged 156 commits from redesign-1-bcrypt into master 2017-10-30 15:55:14 +01:00
Showing only changes of commit 4d9671f5c8 - Show all commits

View file

@ -143,34 +143,43 @@ function checkChannelName(name){
// validation function which checks all aspects of the publish submission // validation function which checks all aspects of the publish submission
function validateFilePublishSubmission(stagedFiles, claimName, channelName){ function validateFilePublishSubmission(stagedFiles, claimName, channelName){
console.log(`validating name: ${claimName} channel: ${channelName} file:`, stagedFiles); console.log(`validating publish submission > name: ${claimName} channel: ${channelName} file:`, stagedFiles);
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
// 1. make sure 1 file was staged // 1. make sure 1 file was staged
if (!stagedFiles) { if (!stagedFiles) {
return reject(new FileError("Please select a file")); reject(new FileError("Please select a file"));
return;
} else if (stagedFiles.length > 1) { } else if (stagedFiles.length > 1) {
return reject(new FileError("Only one file is allowed at a time")); reject(new FileError("Only one file is allowed at a time"));
return;
} }
// 2. validate the file's name, type, and size // 2. validate the file's name, type, and size
try { try {
validateFile(stagedFiles[0]); validateFile(stagedFiles[0]);
} catch (error) { } catch (error) {
return reject(error); reject(error);
return;
} }
// 3. validate that a channel was chosen // 3. validate that a channel was chosen
if (channelName === 'new' || channelName === 'login') { if (channelName === 'new' || channelName === 'login') {
return reject(new ChannelNameError("Please select a valid channel")); reject(new ChannelNameError("Please select a valid channel"));
return;
}; };
// 4. validate the claim name // 4. validate the claim name
try { try {
validateClaimName(claimName); validateClaimName(claimName);
} catch (error) { } catch (error) {
return reject(error); reject(error);
return;
} }
// if all validation passes, check availability of the name // if all validation passes, check availability of the name
isNameAvailable(claimName, '/api/isClaimAvailable/') return isNameAvailable(claimName, '/api/isClaimAvailable/')
.then(() => { .then(result => {
if (result) {
resolve(); resolve();
} else {
reject(new NameError('that url ending is already taken'));
}
}) })
.catch(error => { .catch(error => {
reject(error); reject(error);
@ -178,7 +187,7 @@ function validateFilePublishSubmission(stagedFiles, claimName, channelName){
}); });
} }
// validation function which checks all aspects of the publish submission // validation function which checks all aspects of a new channel submission
function validateNewChannelSubmission(channelName, password){ function validateNewChannelSubmission(channelName, password){
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
// 1. validate name // 1. validate name