Commit 8f39229a92fdc36f25c08d1ec4ff63fc1f20360e
1 parent
39a845dc
Exists in
master
Add DDService method to reset user password
Showing
2 changed files
with
51 additions
and
3 deletions
Show diff stats
src/DDSERVICES/SOAP/DDserverWeb.php
... | ... | @@ -169,7 +169,7 @@ |
169 | 169 | return array( |
170 | 170 | "valid" => FALSE, |
171 | 171 | ); |
172 | - } | |
172 | + } | |
173 | 173 | |
174 | 174 | $data_array = json_decode($data_decoded, TRUE); |
175 | 175 | if (empty($data_array) || empty($data_array["timestamp"])) { |
... | ... | @@ -276,7 +276,32 @@ |
276 | 276 | $last_name = !array_key_exists('last_name', $data_array) ? "" : $data_array['last_name']; |
277 | 277 | $email = !array_key_exists('email', $data_array) ? "" : $data_array['email']; |
278 | 278 | return ($userManager->AddUser($data_array['login'], $pwd_hash, $first_name, $last_name, $email, 1, '') == 1); |
279 | - } | |
279 | + } | |
280 | + | |
281 | + function resetUserPwd($data, $key, $check) | |
282 | + { | |
283 | + $data_array = $this->checkProtectedAPI($data, $key, $check); | |
284 | + if ($data_array['valid'] == FALSE) { | |
285 | + return FALSE; | |
286 | + } | |
287 | + | |
288 | + if (empty($data_array['login']) || empty($data_array['crtpwd']) || empty($data_array['newpwd'])) { | |
289 | + return FALSE; | |
290 | + } | |
291 | + | |
292 | + require_once userMgrDir."/UserManagerClass.php"; | |
293 | + putenv("PATH=./:".DDBASEBIN.":/bin:/usr/bin"); | |
294 | + putenv("DDINFO=".extBaseDir); | |
295 | + putenv("DDBASE=".baseDir); | |
296 | + putenv("AMDA_USERS_INFO=AMDA_Users_Info.xml"); | |
297 | + putenv("AMDA_GROUPS_INFO=AMDA_Users.xml"); | |
298 | + $stderr = fopen("php://stderr","w"); | |
299 | + $userManager = new UserManagerClass($stderr); | |
300 | + $crtpwd_hash = $userManager->cryptPwd($data_array['login'], $data_array['crtpwd']); | |
301 | + $newpwd_hash = crypt($data_array['newpwd'],chr(rand(97,122)).chr(rand(97,122))); | |
302 | + return ($userManager->ModifyUserPwd($data_array['login'], $crtpwd_hash, $newpwd_hash) == 1); | |
303 | + | |
304 | + } | |
280 | 305 | |
281 | 306 | /* |
282 | 307 | * Return a list of group for which a user is a member | ... | ... |
src/DDSERVICES/SOAP/dd.wsdl.in
... | ... | @@ -163,6 +163,14 @@ |
163 | 163 | <message name='createUserResponse'> |
164 | 164 | <part name='Result' type='xsd:boolean'/> |
165 | 165 | </message> |
166 | +<message name='resetUserPwdRequest'> | |
167 | + <part name='data' type='xsd:string'/> | |
168 | + <part name='key' type='xsd:string'/> | |
169 | + <part name='check' type='xsd:string'/> | |
170 | +</message> | |
171 | +<message name='resetUserPwdResponse'> | |
172 | + <part name='Result' type='xsd:boolean'/> | |
173 | +</message> | |
166 | 174 | <message name='getTimeRestrictionRequest'> |
167 | 175 | <part name='dataSet' type='xsd:string'/> |
168 | 176 | </message> |
... | ... | @@ -247,7 +255,11 @@ |
247 | 255 | <operation name='createUser'> |
248 | 256 | <input message='tns:createUserRequest'/> |
249 | 257 | <output message='tns:createUserResponse'/> |
250 | - </operation> | |
258 | + </operation> | |
259 | + <operation name='resetUserPwd'> | |
260 | + <input message='tns:resetUserPwdRequest'/> | |
261 | + <output message='tns:resetUserPwdResponse'/> | |
262 | + </operation> | |
251 | 263 | <operation name='getTimeRestriction'> |
252 | 264 | <input message='tns:getTimeRestrictionRequest'/> |
253 | 265 | <output message='tns:getTimeRestrictionResponse'/> |
... | ... | @@ -459,6 +471,17 @@ |
459 | 471 | encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/> |
460 | 472 | </output> |
461 | 473 | </operation> |
474 | + <operation name='resetUserPwd'> | |
475 | + <soap:operation soapAction='resetUserPwd'/> | |
476 | + <input> | |
477 | + <soap:body use='encoded' | |
478 | + encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/> | |
479 | + </input> | |
480 | + <output> | |
481 | + <soap:body use='encoded' | |
482 | + encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/> | |
483 | + </output> | |
484 | + </operation> | |
462 | 485 | <operation name='getTimeRestriction'> |
463 | 486 | <soap:operation soapAction='getTimeRestriction'/> |
464 | 487 | <input> | ... | ... |