Skip to content

Commit 75941f9

Browse files
committed
fix the wrong time show
1 parent 46f5a8f commit 75941f9

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

jwt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ int jwt_verify_body(char *body, zval *return_value)
274274
struct tm *timeinfo;
275275
char buf[128];
276276

277-
timeinfo = localtime(&curr_time);
277+
timeinfo = localtime(&JWT_G(not_before));
278278
strftime(buf, sizeof(buf), "Cannot handle token prior to %Y-%m-%d %H:%M:%S", timeinfo);
279279
err_msg = buf;
280280
}
@@ -288,7 +288,7 @@ int jwt_verify_body(char *body, zval *return_value)
288288
struct tm *timeinfo;
289289
char buf[128];
290290

291-
timeinfo = localtime(&curr_time);
291+
timeinfo = localtime(&JWT_G(iat));
292292
strftime(buf, sizeof(buf), "Cannot handle token prior to %Y-%m-%d %H:%M:%S", timeinfo);
293293
err_msg = buf;
294294
}

jwt.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
"admin" => true
1313
],
1414
"sub" => "1234567890",
15-
"nbf" => time() + 10
15+
"nbf" => time() + 100
1616
);
1717

1818
// default HS256 algorithm
1919
$token = jwt_encode($claims, $key);
2020

2121
echo $token . PHP_EOL;
22-
print_r(jwt_decode($token, $key, ['leeway' => 20, "iss" => "http://example.org"]));
22+
print_r(jwt_decode($token, $key, ['leeway' => 2, "iss" => "http://example.org"]));

0 commit comments

Comments
 (0)