fixes #2404 notify users of impending API key expiration

Adds logic to detect when an API key is about to expire and sends a notification email to the user if the key expires within 7 days and no recent notification was sent. Introduces a new 'last_notified_on' column to the user_auth_keys table to track notification timing.
This commit is contained in:
Linty
2025-09-04 17:21:53 +02:00
parent c078cffb8b
commit dbec498287
5 changed files with 124 additions and 13 deletions
+24
View File
@@ -253,6 +253,30 @@ if (isset($page['auth_key_invalid']) and $page['auth_key_invalid'])
;
}
// check if we need to notified user about api_key expiration
if (isset($page['notify_api_key_expiration']) and is_array($page['notify_api_key_expiration']))
{
$is_mail_send = notification_api_key_expiration(
$user['username'],
$user['email'],
$page['notify_api_key_expiration']['days_left']
);
if ($is_mail_send)
{
single_update(
USER_AUTH_KEYS_TABLE,
array('last_notified_on' => $page['notify_api_key_expiration']['dbnow']),
array(
'user_id' => $user['id'],
'auth_key' => $page['notify_api_key_expiration']['auth_key']
),
);
}
unset($page['notify_api_key_expiration']);
}
// template instance
if (defined('IN_ADMIN') and IN_ADMIN )
{// Admin template