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 * ================================================================================
24 constructor($q, $log, $http, conf,uuid) {
33 let deferred = this.$q.defer();
34 this.$log.info('AdminsService::get all applications admins list');
38 url: this.conf.api.accountAdmins,
40 'X-ECOMP-RequestID':this.uuid.generate()
44 if (Object.keys(res.data).length == 0) {
45 deferred.reject("AdminsService::getAccountAdmins Failed");
47 this.$log.info('AdminsService::getAccountAdmins Succeeded');
48 deferred.resolve(res.data);
52 deferred.reject(status);
55 return deferred.promise;
58 getAdminAppsRoles(orgUserId) {
59 let deferred = this.$q.defer();
60 this.$log.info('AdminsService::getAdminAppsRoles.adminAppsRoles');
64 url: this.conf.api.adminAppsRoles,
65 params: {orgUserId: orgUserId},
68 'X-ECOMP-RequestID':this.uuid.generate()
71 if (Object.keys(res.data).length == 0) {
72 deferred.reject("AdminsService::getAdminAppsRoles.adminAppsRoles Failed");
74 this.$log.info('AdminsService::getAdminAppsRoles.adminAppsRoles Succeeded');
75 deferred.resolve(res.data);
79 deferred.reject(status);
82 return deferred.promise;
85 updateAdminAppsRoles(newAdminAppRoles) {
86 let deferred = this.$q.defer();
87 this.$log.info('AdminsService::updateAdminAppsRoles');
90 url: this.conf.api.adminAppsRoles,
91 data: newAdminAppRoles,
93 'X-ECOMP-RequestID':this.uuid.generate()
96 deferred.resolve(res.data);
99 deferred.reject(status);
102 return deferred.promise;
105 addNewUser(newUser,checkDuplicate) {
106 // this.$log.info(newContactUs)
107 let deferred = this.$q.defer();
108 // this.$log.info('ContactUsService:: add Contact Us' + JSON.stringify(newContactUs));
111 firstName:newUser.firstName,
112 middleInitial:newUser.middleName,
113 lastName:newUser.lastName,
114 email:newUser.emailAddress,
115 loginId:newUser.loginId,
116 loginPwd:newUser.loginPwd,
119 url: this.conf.api.saveNewUser + "?isCheck=" + checkDuplicate,
123 'X-ECOMP-RequestID':this.uuid.generate()
127 // this.$log.info('ContactUsService:: add Contact Us res' ,res);
128 // If response comes back as a redirected HTML page which IS NOT a success
129 if (res==null || Object.keys(res.data).length == 0 || res.data.message == 'failure') {
130 deferred.reject("Add new User failed");
131 this.$log.error('adminService:: add New User failed');
133 deferred.resolve(res.data);
136 deferred.reject(errRes);
138 return deferred.promise;
142 * Tests the specified password against complexity requirements.
143 * Returns an explanation message if the test fails; null if it passes.
145 isComplexPassword(str) {
147 let message = 'Password is too simple. Minimum length is '+ minLength + ', '
148 + 'and it must use letters, digits and special characters.';
152 let hasLetter = false;
153 let hasDigit = false;
154 let hasSpecial = false;
156 for (i = 0, len = str.length; i < len; i++) {
157 code = str.charCodeAt(i);
158 if (code > 47 && code < 58) // numeric (0-9)
160 else if ((code > 64 && code < 91) || (code > 96 && code < 123)) // A-Z, a-z
166 if (str.length < minLength || !hasLetter || !hasDigit || !hasSpecial)
174 AdminsService.$inject = ['$q', '$log', '$http', 'conf','uuid4'];
175 angular.module('ecompApp').service('adminsService', AdminsService)