Commit 6e9b5f4f authored by Jens Segers's avatar Jens Segers

Fix auth for L5.2

parent d425493b
<?php namespace Jenssegers\Mongodb\Auth; <?php namespace Jenssegers\Mongodb\Auth;
use DateTime; use DateTime;
use Illuminate\Auth\Passwords\DatabaseTokenRepository as BaseDatabaseTokenRepository;
use MongoDate; use MongoDate;
class DatabaseTokenRepository extends \Illuminate\Auth\Passwords\DatabaseTokenRepository class DatabaseTokenRepository extends BaseDatabaseTokenRepository
{ {
/** /**
* Build the record payload for the table. * Build the record payload for the table.
...@@ -28,9 +29,7 @@ class DatabaseTokenRepository extends \Illuminate\Auth\Passwords\DatabaseTokenRe ...@@ -28,9 +29,7 @@ class DatabaseTokenRepository extends \Illuminate\Auth\Passwords\DatabaseTokenRe
// Convert MongoDate to a date string. // Convert MongoDate to a date string.
if ($token['created_at'] instanceof MongoDate) { if ($token['created_at'] instanceof MongoDate) {
$date = new DateTime; $date = new DateTime;
$date->setTimestamp($token['created_at']->sec); $date->setTimestamp($token['created_at']->sec);
$token['created_at'] = $date->format('Y-m-d H:i:s'); $token['created_at'] = $date->format('Y-m-d H:i:s');
} elseif (is_array($token['created_at']) and isset($token['created_at']['date'])) { } elseif (is_array($token['created_at']) and isset($token['created_at']['date'])) {
$token['created_at'] = $token['created_at']['date']; $token['created_at'] = $token['created_at']['date'];
......
<?php namespace Jenssegers\Mongodb\Auth;
use Illuminate\Auth\Passwords\PasswordBrokerManager as BasePasswordBrokerManager;
class PasswordBrokerManager extends BasePasswordBrokerManager
{
/**
* Create a token repository instance based on the given configuration.
*
* @param array $config
* @return \Illuminate\Auth\Passwords\TokenRepositoryInterface
*/
protected function createTokenRepository(array $config)
{
return new DatabaseTokenRepository(
$this->app['db']->connection(),
$config['table'],
$this->app['config']['app.key'],
$config['expire']
);
}
}
<?php namespace Jenssegers\Mongodb\Auth; <?php namespace Jenssegers\Mongodb\Auth;
use Jenssegers\Mongodb\Auth\DatabaseTokenRepository as DbRepository; use Illuminate\Auth\Passwords\PasswordResetServiceProvider as BasePasswordResetServiceProvider;
class PasswordResetServiceProvider extends \Illuminate\Auth\Passwords\PasswordResetServiceProvider class PasswordResetServiceProvider extends BasePasswordResetServiceProvider
{ {
/** /**
* Register the token repository implementation. * Register the token repository implementation.
...@@ -18,10 +18,28 @@ class PasswordResetServiceProvider extends \Illuminate\Auth\Passwords\PasswordRe ...@@ -18,10 +18,28 @@ class PasswordResetServiceProvider extends \Illuminate\Auth\Passwords\PasswordRe
// interface, and is responsible for the actual storing of auth tokens and // interface, and is responsible for the actual storing of auth tokens and
// their e-mail addresses. We will inject this table and hash key to it. // their e-mail addresses. We will inject this table and hash key to it.
$table = $app['config']['auth.password.table']; $table = $app['config']['auth.password.table'];
$key = $app['config']['app.key']; $key = $app['config']['app.key'];
$expire = $app['config']->get('auth.password.expire', 60); $expire = $app['config']->get('auth.password.expire', 60);
return new DbRepository($connection, $table, $key, $expire); return new DatabaseTokenRepository($connection, $table, $key, $expire);
});
}
/**
* Register the password broker instance.
*
* @return void
*/
protected function registerPasswordBroker()
{
$this->app->singleton('auth.password', function ($app) {
return new PasswordBrokerManager($app);
});
$this->app->bind('auth.password.broker', function ($app) {
return $app->make('auth.password')->broker();
}); });
} }
} }
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