Unverified Commit c33fc4e1 authored by Jens Segers's avatar Jens Segers Committed by GitHub

Merge pull request #1352 from nolanle/master

Fixed Error "Cannot use object of type MongoDB\BSON\UTCDateTime as array"
parents e1c6e53e 5c2b99ee
......@@ -14,25 +14,25 @@ class DatabaseTokenRepository extends BaseDatabaseTokenRepository
*/
protected function getPayload($email, $token)
{
return ['email' => $email, 'token' => $token, 'created_at' => new UTCDateTime(time() * 1000)];
return ['email' => $email, 'token' => $this->hasher->make($token), 'created_at' => new UTCDateTime(time() * 1000)];
}
/**
* @inheritdoc
*/
protected function tokenExpired($token)
protected function tokenExpired($createdAt)
{
// Convert UTCDateTime to a date string.
if ($token['created_at'] instanceof UTCDateTime) {
$date = $token['created_at']->toDateTime();
if ($createdAt instanceof UTCDateTime) {
$date = $createdAt->toDateTime();
$date->setTimezone(new DateTimeZone(date_default_timezone_get()));
$token['created_at'] = $date->format('Y-m-d H:i:s');
} elseif (is_array($token['created_at']) && isset($token['created_at']['date'])) {
$date = new DateTime($token['created_at']['date'], new DateTimeZone(isset($token['created_at']['timezone']) ? $token['created_at']['timezone'] : 'UTC'));
$createdAt = $date->format('Y-m-d H:i:s');
} elseif (is_array($createdAt) and isset($createdAt['date'])) {
$date = new DateTime($createdAt['date'], new DateTimeZone(isset($createdAt['timezone']) ? $createdAt['timezone'] : 'UTC'));
$date->setTimezone(new DateTimeZone(date_default_timezone_get()));
$token['created_at'] = $date->format('Y-m-d H:i:s');
$createdAt = $date->format('Y-m-d H:i:s');
}
return parent::tokenExpired($token);
return parent::tokenExpired($createdAt);
}
}
......@@ -11,23 +11,21 @@ class PasswordBrokerManager extends BasePasswordBrokerManager
*/
protected function createTokenRepository(array $config)
{
$laravel = app();
if (version_compare($laravel::VERSION, '5.4', '>=')) {
return new DatabaseTokenRepository(
$this->app['db']->connection(),
$this->app['hash'],
$config['table'],
$this->app['config']['app.key'],
$config['expire']
);
} else {
return new DatabaseTokenRepository(
$this->app['db']->connection(),
$config['table'],
$this->app['config']['app.key'],
$config['expire']
);
$key = $this->app['config']['app.key'];
if (\Illuminate\Support\Str::startsWith($key, 'base64:')) {
$key = base64_decode(substr($key, 7));
}
$connection = isset($config['connection']) ? $config['connection'] : null;
return new DatabaseTokenRepository(
$this->app['db']->connection(),
$this->app['hash'],
$config['table'],
$this->app['config']['app.key'],
$config['expire']
);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment