Skip to content

Commit 606fe57

Browse files
authored
modernize DatabaseTokenRepository and make consistent with CacheTokenRepository (#53746)
- use promoted properties - require the `expires` property to be passed in as seconds, rather than taking it as minutes and converting it. shift responsibility to calling code.
1 parent d654523 commit 606fe57

File tree

2 files changed

+8
-64
lines changed

2 files changed

+8
-64
lines changed

src/Illuminate/Auth/Passwords/DatabaseTokenRepository.php

Lines changed: 6 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -10,73 +10,17 @@
1010

1111
class DatabaseTokenRepository implements TokenRepositoryInterface
1212
{
13-
/**
14-
* The database connection instance.
15-
*
16-
* @var \Illuminate\Database\ConnectionInterface
17-
*/
18-
protected $connection;
19-
20-
/**
21-
* The Hasher implementation.
22-
*
23-
* @var \Illuminate\Contracts\Hashing\Hasher
24-
*/
25-
protected $hasher;
26-
27-
/**
28-
* The token database table.
29-
*
30-
* @var string
31-
*/
32-
protected $table;
33-
34-
/**
35-
* The hashing key.
36-
*
37-
* @var string
38-
*/
39-
protected $hashKey;
40-
41-
/**
42-
* The number of seconds a token should last.
43-
*
44-
* @var int
45-
*/
46-
protected $expires;
47-
48-
/**
49-
* Minimum number of seconds before re-redefining the token.
50-
*
51-
* @var int
52-
*/
53-
protected $throttle;
54-
5513
/**
5614
* Create a new token repository instance.
57-
*
58-
* @param \Illuminate\Database\ConnectionInterface $connection
59-
* @param \Illuminate\Contracts\Hashing\Hasher $hasher
60-
* @param string $table
61-
* @param string $hashKey
62-
* @param int $expires
63-
* @param int $throttle
64-
* @return void
6515
*/
6616
public function __construct(
67-
ConnectionInterface $connection,
68-
HasherContract $hasher,
69-
$table,
70-
$hashKey,
71-
$expires = 60,
72-
$throttle = 60,
17+
protected ConnectionInterface $connection,
18+
protected HasherContract $hasher,
19+
protected string $table,
20+
protected string $hashKey,
21+
protected int $expires = 3600,
22+
protected int $throttle = 60,
7323
) {
74-
$this->table = $table;
75-
$this->hasher = $hasher;
76-
$this->hashKey = $hashKey;
77-
$this->expires = $expires * 60;
78-
$this->connection = $connection;
79-
$this->throttle = $throttle;
8024
}
8125

8226
/**

src/Illuminate/Auth/Passwords/PasswordBrokerManager.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ protected function createTokenRepository(array $config)
104104
$this->app['hash'],
105105
$config['table'],
106106
$key,
107-
$config['expire'],
108-
$config['throttle'] ?? 0
107+
($config['expire'] ?? 60) * 60,
108+
$config['throttle'] ?? 0,
109109
);
110110
}
111111

0 commit comments

Comments
 (0)