Skip to content

Commit 6e9b5f4

Browse files
committed
Fix auth for L5.2
1 parent d425493 commit 6e9b5f4

File tree

3 files changed

+45
-6
lines changed

3 files changed

+45
-6
lines changed

src/Jenssegers/Mongodb/Auth/DatabaseTokenRepository.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<?php namespace Jenssegers\Mongodb\Auth;
22

33
use DateTime;
4+
use Illuminate\Auth\Passwords\DatabaseTokenRepository as BaseDatabaseTokenRepository;
45
use MongoDate;
56

6-
class DatabaseTokenRepository extends \Illuminate\Auth\Passwords\DatabaseTokenRepository
7+
class DatabaseTokenRepository extends BaseDatabaseTokenRepository
78
{
89
/**
910
* Build the record payload for the table.
@@ -28,9 +29,7 @@ protected function tokenExpired($token)
2829
// Convert MongoDate to a date string.
2930
if ($token['created_at'] instanceof MongoDate) {
3031
$date = new DateTime;
31-
3232
$date->setTimestamp($token['created_at']->sec);
33-
3433
$token['created_at'] = $date->format('Y-m-d H:i:s');
3534
} elseif (is_array($token['created_at']) and isset($token['created_at']['date'])) {
3635
$token['created_at'] = $token['created_at']['date'];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php namespace Jenssegers\Mongodb\Auth;
2+
3+
use Illuminate\Auth\Passwords\PasswordBrokerManager as BasePasswordBrokerManager;
4+
5+
class PasswordBrokerManager extends BasePasswordBrokerManager
6+
{
7+
/**
8+
* Create a token repository instance based on the given configuration.
9+
*
10+
* @param array $config
11+
* @return \Illuminate\Auth\Passwords\TokenRepositoryInterface
12+
*/
13+
protected function createTokenRepository(array $config)
14+
{
15+
return new DatabaseTokenRepository(
16+
$this->app['db']->connection(),
17+
$config['table'],
18+
$this->app['config']['app.key'],
19+
$config['expire']
20+
);
21+
}
22+
}

src/Jenssegers/Mongodb/Auth/PasswordResetServiceProvider.php

+21-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php namespace Jenssegers\Mongodb\Auth;
22

3-
use Jenssegers\Mongodb\Auth\DatabaseTokenRepository as DbRepository;
3+
use Illuminate\Auth\Passwords\PasswordResetServiceProvider as BasePasswordResetServiceProvider;
44

5-
class PasswordResetServiceProvider extends \Illuminate\Auth\Passwords\PasswordResetServiceProvider
5+
class PasswordResetServiceProvider extends BasePasswordResetServiceProvider
66
{
77
/**
88
* Register the token repository implementation.
@@ -18,10 +18,28 @@ protected function registerTokenRepository()
1818
// interface, and is responsible for the actual storing of auth tokens and
1919
// their e-mail addresses. We will inject this table and hash key to it.
2020
$table = $app['config']['auth.password.table'];
21+
2122
$key = $app['config']['app.key'];
23+
2224
$expire = $app['config']->get('auth.password.expire', 60);
2325

24-
return new DbRepository($connection, $table, $key, $expire);
26+
return new DatabaseTokenRepository($connection, $table, $key, $expire);
27+
});
28+
}
29+
30+
/**
31+
* Register the password broker instance.
32+
*
33+
* @return void
34+
*/
35+
protected function registerPasswordBroker()
36+
{
37+
$this->app->singleton('auth.password', function ($app) {
38+
return new PasswordBrokerManager($app);
39+
});
40+
41+
$this->app->bind('auth.password.broker', function ($app) {
42+
return $app->make('auth.password')->broker();
2543
});
2644
}
2745
}

0 commit comments

Comments
 (0)