Zitadel PHP Client 1.3.6 PHP Client for Zitadel

Loading...
Searching...
No Matches
Account.php
Go to the documentation of this file.
1<?php
2
3 namespace ZitadelPhpClient\User;
4
5use Exception;
6
10 class Account
11{
12 private array $settings;
13 private int $userid;
14 private string $action;
18 public function __construct(array $settings) {
19 $this->settings = $settings;
20 }
21
26 public function setUserId(int $userid): void {
27 $this->userid = $userid;
28 }
29
35 public function deactivate(): void {
36 $this->action = "deactivate";
37 $this->request();
38 }
39
45 public function reactivate(): void {
46 $this->action = "reactivate";
47 $this->request();
48 }
49
55 public function lock(): void {
56 $this->action = "lock";
57 $this->request();
58 }
59
64 public function unlock(): void {
65 $this->action = "unlock";
66 $this->request();
67 }
68
72 private function request(): void {
73 $token = $this->settings["serviceUserToken"];
74 $curl = curl_init();
75
76 curl_setopt_array($curl, array(
77 CURLOPT_URL => $this->settings["domain"] . "/v2beta/users/$this->userid/$this->action",
78 CURLOPT_RETURNTRANSFER => true,
79 CURLOPT_ENCODING => '',
80 CURLOPT_MAXREDIRS => 10,
81 CURLOPT_TIMEOUT => 0,
82 CURLOPT_FOLLOWLOCATION => true,
83 CURLOPT_CUSTOMREQUEST => 'POST',
84 CURLOPT_POSTFIELDS =>"{}",
85 CURLOPT_HTTPHEADER => array(
86 "Content-Type: application/json",
87 "Accept: application/json",
88 "Authorization: Bearer $token"
89 ),
90 ));
91
92 $response = json_decode(curl_exec($curl));
93 curl_close($curl);
94 if(isset($response->code)) {
95 throw new Exception("Error-Code: " . $response->code . " Message: " . $response->message);
96 }
97 }
98}
ZitadelPhpClient\User\Account
Definition Account.php:11
ZitadelPhpClient\User\Account\lock
lock()
Definition Account.php:55
ZitadelPhpClient\User\Account\setUserId
setUserId(int $userid)
Definition Account.php:26
ZitadelPhpClient\User\Account\deactivate
deactivate()
Definition Account.php:35
ZitadelPhpClient\User\Account\__construct
__construct(array $settings)
Definition Account.php:18
ZitadelPhpClient\User\Account\reactivate
reactivate()
Definition Account.php:45
ZitadelPhpClient\User\Account\unlock
unlock()
Definition Account.php:64
ZitadelPhpClient\User
Definition Account.php:3