From 75bc6267fbeedadec4f7d07d0744be7c8fce63f7 Mon Sep 17 00:00:00 2001 From: Neha Gupta Date: Thu, 6 Dec 2018 13:02:56 +0900 Subject: [PATCH] Fixed user setting issue Bugzilla: 1654623 tendrl-github-id: https://github.com/Tendrl/ui/issues/1091 --- src/modules/base/header/header.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/modules/base/header/header.js b/src/modules/base/header/header.js index 351b3350..8528d84d 100644 --- a/src/modules/base/header/header.js +++ b/src/modules/base/header/header.js @@ -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; @@ -128,8 +134,6 @@ .then(function(data) { vm.userScope.isDataLoading = false; vm.userScope.user = data; - vm.userScope.user["password"] = ""; - vm.userScope.user["confirmPassword"] = ""; }); } @@ -158,9 +162,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; @@ -170,7 +171,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;