only log if api key was reset on purpose

This commit is contained in:
Felix Favre 2014-12-16 00:54:50 +01:00
parent d2e59e8f86
commit 807e420883
3 changed files with 34 additions and 33 deletions

View File

@ -49,7 +49,7 @@ function user_controller() {
}
if ($user_source['api_key'] == "")
User_reset_api_key($user_source);
User_reset_api_key($user_source, false);
return array(
$user_source['Nick'],

View File

@ -191,11 +191,12 @@ function User_by_password_recovery_token($token) {
*
* @param User $user
*/
function User_reset_api_key(&$user) {
function User_reset_api_key(&$user, $log = true) {
$user['api_key'] = md5($user['Nick'] . time() . rand());
$result = sql_query("UPDATE `User` SET `api_key`='" . sql_escape($user['api_key']) . "' WHERE `UID`='" . sql_escape($user['UID']) . "' LIMIT 1");
if ($result === false)
return false;
if ($log)
engelsystem_log(sprintf("API key resetted (%s).",User_Nick_render($user)));
}

View File

@ -749,7 +749,7 @@ function view_user_shifts() {
}
if ($user['api_key'] == "")
User_reset_api_key($user);
User_reset_api_key($user, false);
return page(array(
'<div class="col-md-12">',