This repository was archived by the owner on Sep 11, 2024. It is now read-only.
File tree 1 file changed +28
-0
lines changed
1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -441,4 +441,32 @@ private function addTokens() {
441
441
442
442
return $ headers ;
443
443
}
444
+
445
+ /**
446
+ * Allows to request password recovery and password reset.
447
+ * This endpoint works under the following conditions:
448
+ * - GLPI has notifications enabled
449
+ * - The email address of the user belongs to a user account.
450
+ *
451
+ * @param $email
452
+ * @param string $recoveryToken
453
+ * @param string $newPassword
454
+ * @return array
455
+ */
456
+ public function lostPassword ($ email , $ recoveryToken = '' , $ newPassword = '' ) {
457
+ $ params ['email ' ] = $ email ;
458
+ if (($ recoveryToken && !$ newPassword ) || (!$ recoveryToken && $ newPassword )){
459
+ throw new InsufficientArgumentsException ('The recovery and new password are mandatory ' );
460
+ }
461
+ if ($ recoveryToken && $ newPassword ){
462
+ $ params ['password_forget_token ' ] = $ recoveryToken ;
463
+ $ params ['password ' ] = $ newPassword ;
464
+ }
465
+ $ options ['body ' ] = json_encode ($ params );
466
+ $ response = $ this ->request ('put ' , 'lostPassword ' , $ options );
467
+ return [
468
+ 'statusCode ' => $ response ->getStatusCode (),
469
+ 'body ' => $ response ->getBody ()->getContents (),
470
+ ];
471
+ }
444
472
}
You can’t perform that action at this time.
0 commit comments