Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add URL validations in update profile #3051

Merged
merged 2 commits into from Oct 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 22 additions & 0 deletions frontend/src/js/controllers/updateProfileCtrl.js
Expand Up @@ -54,12 +54,34 @@

utilities.sendRequest(parameters);

vm.isURLValid = function(url) {
if (url === undefined || url === null) {
return true;
}
return (url.length <= 200);
}

// function to update Profile
vm.updateProfile = function(resetconfirmFormValid) {
if (resetconfirmFormValid) {
vm.user.github_url = vm.user.github_url === null ? "" : vm.user.github_url;
vm.user.google_scholar_url = vm.user.google_scholar_url === null ? "" : vm.user.google_scholar_url;
vm.user.linkedin_url = vm.user.linkedin_url === null ? "" : vm.user.linkedin_url;

if (!vm.isURLValid(vm.user.github_url)) {
vm.isFormError = true;
vm.FormError = "Github URL length should not be greater than 200!"
return;
} else if (!vm.isURLValid(vm.user.google_scholar_url)) {
vm.isFormError = true;
vm.FormError = "Google Scholar URL length should not be greater than 200!"
return;
} else if (!vm.isURLValid(vm.user.linkedin_url)) {
vm.isFormError = true;
vm.FormError = "LinkedIn URL length should not be greater than 200!"
return;
}

vm.startLoader("Updating Your Profile");
var parameters = {};
parameters.url = 'auth/user/';
Expand Down