增加Token有效期

This commit is contained in:
=
2022-02-24 18:36:49 +01:00
parent 2e9764f1b4
commit 8be373cd8b
9 changed files with 197 additions and 56 deletions

View File

@@ -58,8 +58,8 @@ function check_api($token)
exit(json_encode($reJson, JSON_UNESCAPED_UNICODE));
}
if (!in_array($token, $tokenList)) {
// Token错误 Token错误
if (!in_array($tokenList[$token], $tokenList)) {
// Token 是否存在
$reJson = array(
"result" => 'failed',
'code' => 202,
@@ -67,4 +67,14 @@ function check_api($token)
);
exit(json_encode($reJson, JSON_UNESCAPED_UNICODE));
}
if ($tokenList[$token]['expired'] < time()) {
// Token 是否过期
$reJson = array(
"result" => 'failed',
'code' => 203,
'message' => 'Token Expired',
);
exit(json_encode($reJson, JSON_UNESCAPED_UNICODE));
}
}

View File

@@ -28,7 +28,7 @@ if ($handle->uploaded) {
// 允许上传的mime类型
$handle->allowed = array('image/*');
// 文件命名
$handle->file_new_name_body = imgName($handle->file_src_name_body) . '_' . getID($token);
$handle->file_new_name_body = imgName($handle->file_src_name_body) . '_' . $tokenList[$token]['id'];
// 最大上传限制
$handle->file_max_sizes = $config['maxSize'];
// 最大宽度