added token refresh on vendor payouts
This commit is contained in:
parent
cf866edd41
commit
7751fecf0c
|
@ -8,6 +8,22 @@ if ($_SESSION["userId"] <> "") {
|
|||
header("location: login.php");
|
||||
}
|
||||
|
||||
if (isset($_SESSION["token"])) {
|
||||
$token = $_SESSION["token"];
|
||||
$token_parts = explode(".", $token);
|
||||
$token_payload = base64_decode($token_parts[1]);
|
||||
$token_data = json_decode($token_payload);
|
||||
|
||||
$issued_at_time = $token_data->iat;
|
||||
$expiration_time = $token_data->exp;
|
||||
$renewal_time = $issued_at_time + 3300;
|
||||
|
||||
if (time() >= $renewal_time || time() >= $expiration_time) {
|
||||
header("Location:vendor-payoutsTokenRN.php");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$vendorLoginId = searchVendorbyLoginId($_SESSION["userId"]);
|
||||
$vendorLoginIdjson = json_decode($vendorLoginId, true);
|
||||
if (isset($vendorLoginIdjson['results'][0])) {
|
||||
|
@ -16,24 +32,8 @@ if (isset($vendorLoginIdjson['results'][0])) {
|
|||
$_SESSION["LoggedInVendorId"] = $vendorId;
|
||||
}
|
||||
|
||||
$token = $_SESSION["token"];
|
||||
|
||||
$token_parts = explode(".", $token);
|
||||
$token_payload = base64_decode($token_parts[1]);
|
||||
$token_data = json_decode($token_payload);
|
||||
|
||||
$expiration_time = $token_data->exp;
|
||||
$issued_at_time = $token_data->iat;
|
||||
|
||||
$renewal_time = $issued_at_time + 3300;
|
||||
|
||||
|
||||
if (time() >= $renewal_time) {
|
||||
$token = loginRenew($_SESSION["email"], $_SESSION["password"], $token);
|
||||
$_SESSION["token"] = $token;
|
||||
}
|
||||
|
||||
$authToken = $_SESSION['token'];
|
||||
|
||||
$response = getAllPayout($authToken);
|
||||
$vendorPayoutData = json_decode($response, true);
|
||||
|
||||
|
@ -142,6 +142,7 @@ $vendorPayoutData = json_decode($response, true);
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php echo($authToken);?>
|
||||
<div class="ec-shop-rightside col-lg-9 col-md-12">
|
||||
<div class="ec-vendor-dashboard-card ec-vendor-setting-card">
|
||||
<div class="ec-vendor-card-body">
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
include "functions.php";
|
||||
|
||||
$token = loginRenew($_SESSION["email"], $_SESSION["password"], $_SESSION["token"]);
|
||||
$_SESSION["token"] = $token;
|
||||
|
||||
header("Location: vendor-payouts.php");
|
||||
exit;
|
||||
|
||||
?>
|
Loading…
Reference in New Issue