]> git.mxchange.org Git - friendica.git/commitdiff
Add API login capture 12h cooldown to spare database writes
authorHypolite Petovan <hypolite@mrpetovan.com>
Tue, 23 Jun 2020 14:15:39 +0000 (10:15 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Tue, 23 Jun 2020 14:15:39 +0000 (10:15 -0400)
include/api.php

index ba87c8c366899ecc70dfa35521798bf93e78c024..e69fefa27a702f2e54251f8de6eb2a41860cb372 100644 (file)
@@ -264,7 +264,10 @@ function api_login(App $a)
                throw new UnauthorizedException("This API requires login");
        }
 
-       DI::auth()->setForUser($a, $record, false, false, true);
+       // Don't refresh the login date more often than twice a day to spare database writes
+       $login_refresh = strcmp(DateTimeFormat::utc('now - 12 hours'), $record['login_date']) > 0;
+
+       DI::auth()->setForUser($a, $record, false, false, $login_refresh);
 
        $_SESSION["allow_api"] = true;