Skip to content

Commit 9d674b0

Browse files
committed
cleaning and formatting
1 parent 7e1a230 commit 9d674b0

File tree

1 file changed

+29
-27
lines changed

1 file changed

+29
-27
lines changed

src/Illuminate/Auth/Passwords/DatabaseTokenRepository.php

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ class DatabaseTokenRepository implements TokenRepositoryInterface
1717
*/
1818
protected $connection;
1919

20+
/**
21+
* The Hasher implementation.
22+
*
23+
* @var \Illuminate\Contracts\Hashing\Hasher
24+
*/
25+
protected $hasher;
26+
2027
/**
2128
* The token database table.
2229
*
@@ -38,29 +45,24 @@ class DatabaseTokenRepository implements TokenRepositoryInterface
3845
*/
3946
protected $expires;
4047

41-
/**
42-
* The hasher implementation.
43-
*
44-
* @var \Illuminate\Contracts\Hashing\Hasher
45-
*/
46-
protected $hasher;
47-
4848
/**
4949
* Create a new token repository instance.
5050
*
5151
* @param \Illuminate\Database\ConnectionInterface $connection
52+
* @param \Illuminate\Contracts\Hashing\Hasher $hasher
5253
* @param string $table
5354
* @param string $hashKey
5455
* @param int $expires
5556
* @return void
5657
*/
57-
public function __construct(ConnectionInterface $connection, HasherContract $hasher, $table, $hashKey, $expires = 60)
58+
public function __construct(ConnectionInterface $connection, HasherContract $hasher,
59+
$table, $hashKey, $expires = 60)
5860
{
5961
$this->table = $table;
62+
$this->hasher = $hasher;
6063
$this->hashKey = $hashKey;
6164
$this->expires = $expires * 60;
6265
$this->connection = $connection;
63-
$this->hasher = $hasher;
6466
}
6567

6668
/**
@@ -115,26 +117,26 @@ protected function getPayload($email, $token)
115117
* @param string $token
116118
* @return bool
117119
*/
118-
public function exists(CanResetPasswordContract $user, $userToken)
120+
public function exists(CanResetPasswordContract $user, $token)
119121
{
120-
$email = $user->getEmailForPasswordReset();
122+
$record = (array) $this->getTable()->where(
123+
'email', $user->getEmailForPasswordReset()
124+
)->first();
121125

122-
$token = (array) $this->getTable()->where('email', $email)->first();
123-
124-
return $token && ! $this->tokenExpired($token) && $this->hasher->check($userToken, $token['token']);
126+
return $record &&
127+
! $this->tokenExpired($record['created_at']) &&
128+
$this->hasher->check($token, $record['token']);
125129
}
126130

127131
/**
128132
* Determine if the token has expired.
129133
*
130-
* @param array $token
134+
* @param string $createdAt
131135
* @return bool
132136
*/
133-
protected function tokenExpired($token)
137+
protected function tokenExpired($createdAt)
134138
{
135-
$expiresAt = Carbon::parse($token['created_at'])->addSeconds($this->expires);
136-
137-
return $expiresAt->isPast();
139+
return Carbon::parse($createdAt)->addSeconds($this->expires)->isPast();
138140
}
139141

140142
/**
@@ -171,23 +173,23 @@ public function createNewToken()
171173
}
172174

173175
/**
174-
* Begin a new database query against the table.
176+
* Get the database connection instance.
175177
*
176-
* @return \Illuminate\Database\Query\Builder
178+
* @return \Illuminate\Database\ConnectionInterface
177179
*/
178-
protected function getTable()
180+
public function getConnection()
179181
{
180-
return $this->connection->table($this->table);
182+
return $this->connection;
181183
}
182184

183185
/**
184-
* Get the database connection instance.
186+
* Begin a new database query against the table.
185187
*
186-
* @return \Illuminate\Database\ConnectionInterface
188+
* @return \Illuminate\Database\Query\Builder
187189
*/
188-
public function getConnection()
190+
protected function getTable()
189191
{
190-
return $this->connection;
192+
return $this->connection->table($this->table);
191193
}
192194

193195
/**

0 commit comments

Comments
 (0)