2 * ================================================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ================================================================================
22 class EditProfileModalCtrl {
23 constructor($log,ngDialog,usersService,confirmBoxService,adminsService) {
30 this.confirmLoginPwd=''
31 this.isLoading = false;
33 this.isLoading = true;
34 usersService.getLoggedInUser()
36 var data = user.response;
38 this.firstName =data.firstName;
39 this.middleName =data.middleName;
40 this.lastName =data.lastName;
41 this.email =data.email;
42 this.loginId =data.loginId;
43 this.loginPwd =data.loginPassword;
44 this.isLoading = false;
46 $log.error('EditProfileModalCtrl.getUser:: Error retrieving ECMOP portal user: ' + err);
53 firstName : this.firstName,
54 middleName :this.middleName,
55 lastName :this.lastName,
57 loginId :this.loginId,
58 loginPassword :this.loginPwd
60 if (this.firstName =='' || this.lastName == '' || this.email == '' || this.loginId =='' || this.loginPwd ==''|| this.confirmLoginPwd ==''){
61 var warningMsg = "Please enter a value for all fields marked with *.";
62 confirmBoxService.showInformation(warningMsg).then(isConfirmed => {return;});
64 } else if (this.loginPwd != this.confirmLoginPwd) {
65 var warningMsg = "Passwords do not match, please try again.";
66 confirmBoxService.showInformation(warningMsg).then(isConfirmed => {return;});
69 // check password length complexity.
70 var warningMsg = adminsService.isComplexPassword(this.loginPwd);
71 if (warningMsg != null) {
72 confirmBoxService.showInformation(warningMsg).then(isConfirmed => {return;});
76 usersService.modifyLoggedInUser(profileDetail).then(res=> {
77 confirmBoxService.showInformation("Profile detail updated").then(isConfirmed => {return;});
79 $log.error('EditProfileModalCtrl.getUser:: Error retrieving ECMOP portal user: ' + err);
80 confirmBoxService.showInformation("Error while updating profile detail: "+ err).then(isConfirmed => {return;});
85 EditProfileModalCtrl.$inject = ['$log', 'ngDialog','usersService','confirmBoxService','adminsService'];
86 angular.module('ecompApp').controller('EditProfileModalCtrl', EditProfileModalCtrl);