|
8 | 8 | use CodeIgniter\I18n\Time; |
9 | 9 | use CodeIgniter\Model; |
10 | 10 | use CodeIgniter\Shield\Authentication\Authenticators\Session; |
11 | | -use CodeIgniter\Shield\Config\Auth; |
12 | 11 | use CodeIgniter\Shield\Entities\User; |
13 | 12 | use CodeIgniter\Shield\Entities\UserIdentity; |
14 | 13 | use CodeIgniter\Shield\Exceptions\InvalidArgumentException; |
|
18 | 17 | /** |
19 | 18 | * @phpstan-consistent-constructor |
20 | 19 | */ |
21 | | -class UserModel extends Model |
| 20 | +class UserModel extends BaseModel |
22 | 21 | { |
23 | 22 | use CheckQueryReturnTrait; |
24 | 23 |
|
@@ -49,18 +48,11 @@ class UserModel extends Model |
49 | 48 | */ |
50 | 49 | protected ?User $tempUser = null; |
51 | 50 |
|
52 | | - /** |
53 | | - * Auth Identities table name |
54 | | - */ |
55 | | - private string $tableIdentities; |
56 | | - |
57 | 51 | protected function initialize(): void |
58 | 52 | { |
59 | | - /** @var Auth $authConfig */ |
60 | | - $authConfig = config('Auth'); |
| 53 | + parent::initialize(); |
61 | 54 |
|
62 | | - $this->table = $authConfig->tables['users']; |
63 | | - $this->tableIdentities = $authConfig->tables['identities']; |
| 55 | + $this->table = $this->tables['users']; |
64 | 56 | } |
65 | 57 |
|
66 | 58 | /** |
@@ -205,12 +197,12 @@ public function findByCredentials(array $credentials): ?User |
205 | 197 |
|
206 | 198 | if ($email !== null) { |
207 | 199 | $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']) |
209 | 201 | ) |
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) |
212 | 204 | ->where( |
213 | | - 'LOWER(' . $this->db->protectIdentifiers($this->tableIdentities . '.secret') . ')', |
| 205 | + 'LOWER(' . $this->db->protectIdentifiers($this->tables['identities'] . '.secret') . ')', |
214 | 206 | strtolower($email) |
215 | 207 | ) |
216 | 208 | ->asArray() |
|
0 commit comments