Skip to content

Commit b63c27f

Browse files
committed
refactor: remove $this->tableIdentities
1 parent 1adcb5c commit b63c27f

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

src/Models/UserModel.php

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use CodeIgniter\I18n\Time;
99
use CodeIgniter\Model;
1010
use CodeIgniter\Shield\Authentication\Authenticators\Session;
11-
use CodeIgniter\Shield\Config\Auth;
1211
use CodeIgniter\Shield\Entities\User;
1312
use CodeIgniter\Shield\Entities\UserIdentity;
1413
use CodeIgniter\Shield\Exceptions\InvalidArgumentException;
@@ -18,7 +17,7 @@
1817
/**
1918
* @phpstan-consistent-constructor
2019
*/
21-
class UserModel extends Model
20+
class UserModel extends BaseModel
2221
{
2322
use CheckQueryReturnTrait;
2423

@@ -49,18 +48,11 @@ class UserModel extends Model
4948
*/
5049
protected ?User $tempUser = null;
5150

52-
/**
53-
* Auth Identities table name
54-
*/
55-
private string $tableIdentities;
56-
5751
protected function initialize(): void
5852
{
59-
/** @var Auth $authConfig */
60-
$authConfig = config('Auth');
53+
parent::initialize();
6154

62-
$this->table = $authConfig->tables['users'];
63-
$this->tableIdentities = $authConfig->tables['identities'];
55+
$this->table = $this->tables['users'];
6456
}
6557

6658
/**
@@ -205,12 +197,12 @@ public function findByCredentials(array $credentials): ?User
205197

206198
if ($email !== null) {
207199
$data = $this->select(
208-
sprintf('%1$s.*, %2$s.secret as email, %2$s.secret2 as password_hash', $this->table, $this->tableIdentities)
200+
sprintf('%1$s.*, %2$s.secret as email, %2$s.secret2 as password_hash', $this->table, $this->tables['identities'])
209201
)
210-
->join($this->tableIdentities, sprintf('%1$s.user_id = %2$s.id', $this->tableIdentities, $this->table))
211-
->where($this->tableIdentities . '.type', Session::ID_TYPE_EMAIL_PASSWORD)
202+
->join($this->tables['identities'], sprintf('%1$s.user_id = %2$s.id', $this->tables['identities'], $this->table))
203+
->where($this->tables['identities'] . '.type', Session::ID_TYPE_EMAIL_PASSWORD)
212204
->where(
213-
'LOWER(' . $this->db->protectIdentifiers($this->tableIdentities . '.secret') . ')',
205+
'LOWER(' . $this->db->protectIdentifiers($this->tables['identities'] . '.secret') . ')',
214206
strtolower($email)
215207
)
216208
->asArray()

0 commit comments

Comments
 (0)