Skip to content

Commit

Permalink
Add delete_user method
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenclouston committed Oct 3, 2024
1 parent 45a3fed commit 5fadb1b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Check out our [official PHP SDK documentation](https://docs.authsignal.com/sdks/
```php
"require": {
...
"authsignal/authsignal-php" : "2.0.0"
"authsignal/authsignal-php" : "2.0.2"
...
}
```
Expand Down
17 changes: 16 additions & 1 deletion lib/Authsignal/Authsignal.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

abstract class Authsignal
{
const VERSION = '2.0.0';
const VERSION = '2.0.2';

public static $apiKey;

Expand Down Expand Up @@ -132,6 +132,21 @@ public static function enrollVerifiedAuthenticator(string $userId, Array $authen
return $response;
}

/**
* Delete a user
* @param string $userId The userId of the user you want to delete
* @return Array The authsignal response
*/
public static function deleteUser(string $userId)
{
$request = new AuthsignalClient();
$userId = urlencode($userId);
$url = "/users/{$userId}";
list($response, $request) = $request->send($url, null, 'delete');

return $response;
}

/**
* Validate Challenge
* Validates the token returned on a challenge response, this is a critical security measure
Expand Down
10 changes: 10 additions & 0 deletions test/AuthsignalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,14 @@ public function testValidateChallengeOptionalUserId() {

$this->assertEquals($response["isValid"], "true");
}

public function testDeleteUser() {
$mockedResponse = array("success" => true);

self::$server->setResponseOfPath("/v1/users/1234", new Response(json_encode($mockedResponse), 200));

$response = Authsignal::deleteUser("1234");

$this->assertEquals($response["success"], true);
}
}

0 comments on commit 5fadb1b

Please sign in to comment.