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 * ================================================================================
23 class EditUserController {
24 constructor($scope,$log, message, $q, $http, conf,contactUsService,confirmBoxService,userProfileService,adminsService) {
35 $scope.userId = $scope.ngDialogData.loginId;
36 $scope.updateRemoteApp = $scope.ngDialogData.updateRemoteApp;
38 userProfileService.getCurrentUserProfile($scope.userId)
40 $scope.newUser.firstName = res.firstName;
41 $scope.newUser.lastName = res.lastName;
42 $scope.newUser.emailAddress = res.email;
43 $scope.newUser.middleName = res.middleInitial;
44 $scope.newUser.loginId = res.loginId;
45 $scope.newUser.loginPwd = res.loginPwd;
46 $scope.newUser.loginPwdCheck = res.loginPwd;
49 $log.error('HeaderCtrl::LoginSnippetCtrl:get Current User Profile error: ' + err);
52 $log.error('HeaderCtrl::LoginSnippetCtrl:getFunctionalMenuStaticInfo failed: ' + err);
55 $scope.changePwdText = function(){
56 $scope.newUser.loginPwdCheck = '';
59 $scope.closeDialog = function(){
60 $scope.closeThisDialog( $scope.widgetData);
63 $scope.updateUserFun = function(){
65 if ($scope.newUser.firstName==''||$scope.newUser.lastName==''||$scope.newUser.loginPwd=='') {
66 var warningMsg = "Please enter missing values";
67 confirmBoxService.showInformation(warningMsg).then(isConfirmed => {return;});
69 } else if ($scope.newUser.loginPwd != $scope.newUser.loginPwdCheck) {
70 var warningMsg = "Passwords do not match, please try again.";
71 confirmBoxService.showInformation(warningMsg).then(isConfirmed => {return;});
75 // check password length complexity.
76 var warningMsg = adminsService.isComplexPassword($scope.newUser.loginPwd);
77 if (warningMsg != null) {
78 confirmBoxService.showInformation(warningMsg).then(isConfirmed => {return;});
82 adminsService.addNewUser($scope.newUser,'No').then(res=> {
84 $scope.closeThisDialog();
86 confirmBoxService.showInformation('Update User Info successfully');
87 userProfileService.broadCastUpdatedUserInfo();
90 if($scope.updateRemoteApp){
91 //need update remote app's database
92 var remoteAppId = $scope.ngDialogData.appId;
93 if(remoteAppId!=null){
95 userProfileService.updateRemoteUserProfile($scope.userId,remoteAppId).then(res=> {
99 $log.error('userProfileService: update user profile in remote app error:: ', err);
100 confirmBoxService.showInformation('Update User in remote app failed: ' + err);
112 $log.error('adminsService: addNewUser error:: ', err);
113 // $scope.errMsg=err;
114 confirmBoxService.showInformation('Add New User failed: ' + err);
117 //this.isLoadingTable = false;
127 EditUserController.$inject = ['$scope','$log', 'message', '$q', '$http', 'conf','contactUsService','confirmBoxService','userProfileService','adminsService'];
128 angular.module('ecompApp').controller('editUserController', EditUserController);
132 function validateUrl(value){
133 return /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\u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