Skip to content

Commit

Permalink
Merge pull request #18 from jesscostello/fix/lastused-date-formatting
Browse files Browse the repository at this point in the history
Fix: Add formatting for LastUsed date
  • Loading branch information
blueo authored Mar 25, 2022
2 parents 36a2e37 + d521c1c commit 34f6d78
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/MemberApiKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
use LogicException;
use SilverStripe\Core\Config\Config;
use SilverStripe\ORM\DataObject;
use SilverStripe\Security\Member;
use SilverStripe\ORM\FieldType\DBDatetime;
use SilverStripe\Security\Member;

class MemberApiKey extends DataObject
{
Expand All @@ -20,7 +20,7 @@ class MemberApiKey extends DataObject
];

private static $indexes = [
'ApiKeyIdx' => ['type' => 'unique', 'columns' => ['ApiKey'] ],
'ApiKeyIdx' => ['type' => 'unique', 'columns' => ['ApiKey']],
];

private static $has_one = [
Expand Down Expand Up @@ -90,7 +90,7 @@ public static function findByKey($key)
*/
public function markUsed()
{
$this->LastUsed = DBDatetime::now();
$this->LastUsed = DBDatetime::now()->Rfc2822();
$this->TimesUsed++;
$this->write();
}
Expand All @@ -105,7 +105,7 @@ protected static function randKey()
$keyLength = Config::inst()->get(self::class, 'key_length');

for ($i = 0; $i < $keyLength; $i++) {
$key .= $src[rand(0, strlen($src)-1)];
$key .= $src[rand(0, strlen($src) - 1)];
}

return $key;
Expand Down

0 comments on commit 34f6d78

Please sign in to comment.