CMXX - Bugfix contract_manage and authorization api

This commit is contained in:
“VeLiTi”
2024-10-30 17:36:59 +01:00
parent fece6fa5c2
commit f51af664cf
5 changed files with 112 additions and 11 deletions

View File

@@ -34,19 +34,21 @@ if (!empty($username) && !empty($password)) {
http_response_code(401);
}
else {
$service = bin2hex(random_bytes(25)); //$row['service'];
//Check valid userkey
//Default service key
$service = $row['service'];
//Check valid userkey lastlogin less than 30minutes
$valid_key = strtotime('+30 minutes',strtotime($row['lastlogin']));
$valid = ($valid_key <= time())?0:1;
if ($row['service'] != '' && $valid == 0){
//Key is not valid anymore => update new servicekey
$service = bin2hex(random_bytes(25));
$sql_service = 'UPDATE users SET service = ? WHERE id = ?';
$stmt_service = $conn->prepare($sql_service);
$stmt_service->execute([$service, $row['id']]);
}
}
$jwt = createCommunicationToken($service);
$logindate = date('Y-m-d H:i:s');