1var boss_user_module = angular.module('bossApp'); 2 3boss_user_module.factory('UserNewEditService', function($http,$q,CacheFactory,$rootScope) { 4 var _user = angular.copy($rootScope.currentUser); 5 if (!CacheFactory.get('manageUserCache')) { 6 CacheFactory.createCache('manageUserCache'); 7 } 8 var userCache = CacheFactory.get('manageUserCache'); 9 return { 10 getLoggedInUser: function() { 11 userCache.removeAll(); 12 var actionUrl = $rootScope.api_Path + 'user/getUserProfile'; 13 return $http.get(actionUrl).then(function(response) { 14 return response.data; 15 }); 16 }, 17 newedit: function(userId) { 18 userCache.removeAll(); 19 var actionUrl = $rootScope.api_Path + 'user/getUser'; 20 actionUrl = actionUrl + '?leId=' + _user.entityId + '&id=' + userId; 21 return $http.get(actionUrl).then(function(response) { 22 return response.data; 23 }); 24 }, 25 saveUser: function(user, entitlement) { 26 delete user.fxwebEntitlements; 27 userCache.removeAll(); 28 user.entitlements = entitlement; 29 if(!user.paymentLimitPerDay) 30 user.paymentLimitPerDay = 0; 31 if(!user.paymentLimitPerTransaction) 32 user.paymentLimitPerTransaction = 0; 33 req = { 34 method: 'POST', 35 url: $rootScope.api_Path + 'user/saveUser', 36 data: JSON.stringify(user), 37 contentType: "application/json; charset=utf-8" 38 } 39 return $http(req).then(function(response) { 40 return response.data; 41 }); 42 }, 43 updateUser: function(user, entitlement) { 44 delete user.fxwebEntitlements; 45 userCache.removeAll(); 46 user.entitlements = entitlement; 47 if(!user.paymentLimitPerTransaction){ 48 user.paymentLimitPerTransaction = 0; 49 } 50 if(!user.paymentLimitPerDay){ 51 user.paymentLimitPerDay = 0; 52 } 53 req = { 54 method: 'POST', 55 url: $rootScope.api_Path + 'user/updateUser', 56 data: JSON.stringify(user), 57 contentType: "application/json; charset=utf-8" 58 } 59 return $http(req).then(function(response) { 60 return response.data; 61 }); 62 }, 63 userWithOobaCallback: function (user, entitlement, _action, _updatedUserId, _currentPassword, _password, _rePassword) { 64 if (user && entitlement) { 65 delete user.fxwebEntitlements; 66 userCache.removeAll(); 67 user.legalEntityId = _user.entityId; 68 user.entitlements = entitlement; 69 if (!user.paymentLimitPerTransaction) { 70 user.paymentLimitPerTransaction = 0; 71 } 72 if (!user.paymentLimitPerDay) { 73 user.paymentLimitPerDay = 0; 74 } 75 } 76 req = { 77 method: 'POST', 78 url: $rootScope.api_Path + 'twoFactorAuthentication/user-with-ooba-callback', 79 data: user, 80 params: { 81 action: _action, 82 updatedUserId: _updatedUserId, 83 currentPassword: _currentPassword, 84 password: _password, 85 rePassword: _rePassword 86 } 87 } 88 return $http(req).then(function (response) { 89 return response.data; 90 }); 91 }, 92 updateUserProfile: function(user, entitlement) { 93 delete user.fxwebEntitlements; 94 userCache.removeAll(); 95 user.legalEntityId = _user.entityId; 96 user.entitlements = entitlement; 97 user.userId=null; 98 user.id=null; 99 req = { 100 method: 'POST', 101 url: $rootScope.api_Path + 'user/updateMyProfileInfo', 102 data: user 103 } 104 return $http(req).then(function(response) { 105 return response.data; 106 }); 107 }, 108 approveUser: function(user) { 109 userCache.removeAll(); 110 req = { 111 method: 'POST', 112 url: $rootScope.api_Path + 'user/approveUser', 113 params: { 114 userId: user.id 115 } 116 } 117 return $http(req).then(function(response) { 118 return response.data; 119 }); 120 }, 121 deleteUser: function(_userId) { 122 userCache.removeAll(); 123 req = { 124 method: 'POST', 125 url: $rootScope.api_Path + 'user/deleteUser', 126 params: { 127 userId : _userId, 128 leId: _user.entityId 129 } 130 } 131 return $http(req).then(function(response) { 132 return response.data; 133 }); 134 }, 135 updatePassword: function (_currentPassword, _password, _userId, _rePassword) { 136 userCache.removeAll(); 137 req = { 138 method: 'POST', 139 url: $rootScope.api_Path + 'user/updatePassword', 140 params: { 141 currentPassword: _currentPassword, 142 password: _password, 143 rePassword: _rePassword, 144 userId: _userId 145 } 146 } 147 return $http(req).then(function (response) { 148 return response.data; 149 }); 150 }, 151 getUserList: function() { 152 var deferred = $q.defer(); 153 //if (userCache.get("getUserList")) { 154 // deferred.resolve(userCache.get("getUserList")); 155 //} else { 156 req = { 157 method: 'GET', 158 url: $rootScope.api_Path + 'user/getUserList' 159 } 160 $http(req,{cache:userCache}).then(function(response) { 161 //userCache.put("getUserList", response); 162 deferred.resolve(response.data); 163 }); 164 //} 165 return deferred.promise; 166 }, 167 getPasswordTips: function() { 168 var deferred = $q.defer(); 169 if (userCache.get("getPasswordTips")) { 170 deferred.resolve(userCache.get("getPasswordTips")); 171 } else { 172 req = { 173 method: 'GET', 174 url: $rootScope.api_Path + 'user/getPasswordTips', 175 } 176 $http(req,{cache:userCache}).then(function(response) { 177 userCache.put("getPasswordTips", response.data); 178 deferred.resolve(response.data); 179 }); 180 } 181 return deferred.promise; 182 }, 183 validatePassword: function(password,confirmPassword) { 184 req = { 185 method: 'GET', 186 url: $rootScope.api_Path + 'user/validatePassword', 187 params: { 188 password : password, 189 confirmPassword : confirmPassword 190 } 191 } 192 return $http(req).then(function(response) { 193 return response.data; 194 }); 195 } 196 }; 197});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.