瀏覽代碼

token validity check

master
Robin Thoni 9 年之前
父節點
當前提交
7da6f13162
共有 1 個檔案被更改,包括 4 行新增2 行删除
  1. 4
    2
      status.php

+ 4
- 2
status.php 查看文件

@@ -5,9 +5,11 @@ require_once "misc/config.php";
5 5
 function check_token()
6 6
 {
7 7
   $token = check_table_field("Authorization", "tokens", "token");
8
-  if ($token === false)
8
+  $date = new DateTime($token["date"]);
9
+  $date->add(new DateInterval("P1D"));
10
+  if ($token === false || $date < new DateTime())
9 11
     error(401, "Invalid token");
10
-  return $token;
12
+  return $token['token'];
11 13
 }
12 14
 
13 15
 function status_confirm($id)

Loading…
取消
儲存