1
0
mirror of https://github.com/flarum/core.git synced 2025-08-08 09:26:34 +02:00

fixed more attributes to match beta 8

This commit is contained in:
Daniel Klabbers
2018-05-14 13:49:52 +02:00
parent a9501ceae0
commit 3e3e1cbde5
22 changed files with 65 additions and 45 deletions

View File

@@ -11,6 +11,7 @@
namespace Flarum\Http;
use Carbon\Carbon;
use Flarum\Database\AbstractModel;
/**
@@ -47,7 +48,7 @@ class AccessToken extends AbstractModel
$token->id = str_random(40);
$token->user_id = $userId;
$token->last_activity = time();
$token->last_activity = Carbon::now();
$token->lifetime = $lifetime;
return $token;
@@ -55,7 +56,7 @@ class AccessToken extends AbstractModel
public function touch()
{
$this->last_activity = time();
$this->last_activity = Carbon::now();
return $this->save();
}

View File

@@ -11,6 +11,7 @@
namespace Flarum\Http;
use Carbon\Carbon;
use Dflydev\FigCookies\SetCookie;
use Flarum\Foundation\Application;
@@ -79,7 +80,7 @@ class CookieFactory
if ($maxAge) {
$cookie = $cookie
->withMaxAge($maxAge)
->withExpires(time() + $maxAge);
->withExpires(Carbon::now()->timestamp + $maxAge);
}
if ($this->domain != null) {

View File

@@ -11,6 +11,7 @@
namespace Flarum\Http\Middleware;
use Carbon\Carbon;
use Flarum\Http\AccessToken;
use Flarum\User\AuthToken;
use Flarum\User\EmailToken;
@@ -54,9 +55,11 @@ class CollectGarbage implements MiddlewareInterface
return;
}
AccessToken::whereRaw('last_activity <= ? - lifetime', [time()])->delete();
$time = Carbon::now()->timestamp;
$earliestToKeep = date('Y-m-d H:i:s', time() - 24 * 60 * 60);
AccessToken::whereRaw('last_activity <= ? - lifetime', [$time])->delete();
$earliestToKeep = date('Y-m-d H:i:s', $time - 24 * 60 * 60);
EmailToken::where('created_at', '<=', $earliestToKeep)->delete();
PasswordToken::where('created_at', '<=', $earliestToKeep)->delete();