Skip to content

Commit

Permalink
Merge pull request #1092 from gnehapk/edit-user-issue
Browse files Browse the repository at this point in the history
Fixed user setting issue
  • Loading branch information
gnehapk authored Dec 11, 2018
2 parents 34100fb + 3305f80 commit 636b6d2
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions src/modules/base/header/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@
vm.userScope.formSubmitInProgress = true;
if (_validateUIFields()) {
vm.userScope.user.notification = vm.userScope.user.email_notifications;

//this gets checked when user has entered password and then deleted
if (!vm.userScope.user.password.length) {
delete vm.userScope.user.password;
}

userStore.editUser(vm.userScope.user)
.then(function(data) {
vm.showUserSetting = false;
Expand All @@ -85,10 +91,15 @@
if (data !== null) {
$rootScope.$broadcast("UpdatedUserList", data);
}

});
}
Notifications.message("success", "", " Profile updated Successfully.");

userStore.getUserInfo()
.then(function(data) {
vm.currentUser = data.name;
Notifications.message("success", "", " Profile updated Successfully.");
});

}).catch(function(e) {
var keys,
messages;
Expand Down Expand Up @@ -128,8 +139,6 @@
.then(function(data) {
vm.userScope.isDataLoading = false;
vm.userScope.user = data;
vm.userScope.user["password"] = "";
vm.userScope.user["confirmPassword"] = "";
});
}

Expand Down Expand Up @@ -158,9 +167,6 @@
//vm.userScope.errorMsg = "Password and Confirm Password doesn't match.";
isFormValid = false;
Notifications.message("danger", "", "Your password and confirmation password do not match. Go to My Settings to reset your password.");
} else if (form.password.$invalid) {
vm.userScope.errorMsg = "Password should be 8 characters minimum";
isFormValid = false;
} else if (form.email.$invalid) {
vm.userScope.errorMsg = "Please enter Email id.";
isFormValid = false;
Expand All @@ -170,7 +176,16 @@
}

function _isPasswordSame() {
if (vm.userScope.user.password == vm.userScope.user.confirmPassword) {

if (typeof vm.userScope.user.password === "undefined") {
vm.userScope.user.password = "";
}

if (typeof vm.userScope.user.confirmPassword === "undefined") {
vm.userScope.user.confirmPassword = "";
}

if (vm.userScope.user.password === vm.userScope.user.confirmPassword) {
return true;
} else {
return false;
Expand Down

0 comments on commit 636b6d2

Please sign in to comment.