Skip to content

Commit

Permalink
added changes
Browse files Browse the repository at this point in the history
  • Loading branch information
gaokevin1 committed Jul 26, 2024
1 parent 65b8253 commit 4e016ae
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 10 deletions.
2 changes: 0 additions & 2 deletions sample/callback.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
]);

if (isset($_POST["sessionToken"]) && $descopeSDK->verify($_POST["sessionToken"])) {
session_start()

$_SESSION["user"] = json_decode($_POST["userDetails"], true);
$_SESSION["sessionToken"] = $_POST["sessionToken"];

Expand Down
2 changes: 1 addition & 1 deletion sample/dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
session_start();
if (!isset($_SESSION["user"])) {
session_destroy();
header('Location: login.php');
// header('Location: login.php');
exit();
}

Expand Down
2 changes: 1 addition & 1 deletion sample/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ function sendFormData(sessionToken, userDetails) {
async function getUserDetails() {
const user = await sdk.me();
console.log(user);
return user;
}
Expand All @@ -41,7 +42,6 @@ function sendFormData(sessionToken, userDetails) {
if (validRefreshToken) {
console.log("Valid refresh token found. Logging in...");
sdk.refresh();
const user = getUserDetails().then((user) => {
const sessionToken = sdk.getSessionToken();
sendFormData(sessionToken, user.data);
Expand Down
8 changes: 6 additions & 2 deletions src/SDK/Configuration/SDKConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public function __construct(array $config)
$this->managementKey = $config['managementKey'] ?? '';

EndpointsV2::setBaseUrl($config['projectId']);

$this->jwkSets = $this->getJWKSets();
}

Expand All @@ -31,9 +32,12 @@ public function __construct(array $config)
private function getJWKSets()
{
try {
$url = EndpointsV2::getPublicKeyPath();

// Fetch JWK public key from Descope API
$response = $this->api->doGet(EndpointsV2::getPublicKeyPath(), false);
return json_decode($response->getBody(), true);
$res = $this->client->request('GET', $url);
$jwkSets = json_decode($res->getBody(), true);
return $jwkSets;
} catch (RequestException $re) {
return $re;
}
Expand Down
4 changes: 1 addition & 3 deletions src/SDK/DescopeSDK.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ class DescopeSDK
public Management $management;
public API $api;

public string $baseUrl;

/**
* Constructor for DescopeSDK class.
*
Expand All @@ -38,7 +36,7 @@ public function __construct(array $config)
EndpointsV1::setBaseUrl($config['projectId']);
EndpointsV2::setBaseUrl($config['projectId']);

$this->config = new SDKConfig($config, $baseUrl);
$this->config = new SDKConfig($config);

$this->api = new API($config['projectId'], $config['managementKey'] ?? '');
// If OPTIONAL management key was provided in $config
Expand Down
1 change: 0 additions & 1 deletion src/SDK/Management/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,6 @@ public function searchAll(
}

$jsonBody = json_encode($body);
print($jsonBody);

try {
$response = $this->api->doPost(
Expand Down

0 comments on commit 4e016ae

Please sign in to comment.