Skip to content

Commit 6ed08e7

Browse files
datamwebkenjis
authored andcommitted
rename $authTables to $tables and delete auth_ from array keys
1 parent 433f196 commit 6ed08e7

22 files changed

Lines changed: 96 additions & 96 deletions

docs/customization.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ Shield has the following rules for registration:
154154
],
155155
'email' => [
156156
'label' => 'Auth.email',
157-
'rules' => 'required|max_length[254]|valid_email|is_unique[' . SHIELD_TABLES['auth_identities'] . '.secret]',
157+
'rules' => 'required|max_length[254]|valid_email|is_unique[' . SHIELD_TABLES['identities'] . '.secret]',
158158
],
159159
'password' => [
160160
'label' => 'Auth.password',
@@ -180,7 +180,7 @@ If you need a different set of rules for registration, you can specify them in y
180180
],
181181
'email' => [
182182
'label' => 'Auth.email',
183-
'rules' => 'required|max_length[254]|valid_email|is_unique[' . SHIELD_TABLES['auth_identities'] . '.secret]',
183+
'rules' => 'required|max_length[254]|valid_email|is_unique[' . SHIELD_TABLES['identities'] . '.secret]',
184184
],
185185
'password' => [
186186
'label' => 'Auth.password',

src/Config/Auth.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class Auth extends BaseConfig
5757
*
5858
* @var array<string, string>
5959
*/
60-
public array $authTables = [
60+
public array $tables = [
6161
'users' => 'users',
6262
'auth_identities' => 'auth_identities',
6363
'auth_logins' => 'auth_logins',

src/Config/Constants.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
/**
66
* Constants Name of Shield Tables
77
*/
8-
define('SHIELD_TABLES', config('Auth')->authTables);
8+
define('SHIELD_TABLES', config('Auth')->tables);

src/Controllers/RegisterController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ protected function getValidationRules(): array
157157
);
158158
$registrationEmailRules = array_merge(
159159
config('AuthSession')->emailValidationRules,
160-
[sprintf('is_unique[%s.secret]', SHIELD_TABLES['auth_identities'])]
160+
[sprintf('is_unique[%s.secret]', SHIELD_TABLES['identities'])]
161161
);
162162

163163
return setting('Validation.registration') ?? [

src/Database/Migrations/2020-12-28-223112_create_auth_tables.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function up(): void
4848
$this->forge->addUniqueKey(['type', 'secret']);
4949
$this->forge->addKey('user_id');
5050
$this->forge->addForeignKey('user_id', SHIELD_TABLES['users'], 'id', '', 'CASCADE');
51-
$this->forge->createTable(SHIELD_TABLES['auth_identities']);
51+
$this->forge->createTable(SHIELD_TABLES['identities']);
5252

5353
/**
5454
* Auth Login Attempts Table
@@ -69,7 +69,7 @@ public function up(): void
6969
$this->forge->addKey(['id_type', 'identifier']);
7070
$this->forge->addKey('user_id');
7171
// NOTE: Do NOT delete the user_id or identifier when the user is deleted for security audits
72-
$this->forge->createTable(SHIELD_TABLES['auth_logins']);
72+
$this->forge->createTable(SHIELD_TABLES['logins']);
7373

7474
/*
7575
* Auth Token Login Attempts Table
@@ -89,7 +89,7 @@ public function up(): void
8989
$this->forge->addKey(['id_type', 'identifier']);
9090
$this->forge->addKey('user_id');
9191
// NOTE: Do NOT delete the user_id or identifier when the user is deleted for security audits
92-
$this->forge->createTable(SHIELD_TABLES['auth_token_logins']);
92+
$this->forge->createTable(SHIELD_TABLES['token_logins']);
9393

9494
/*
9595
* Auth Remember Tokens (remember-me) Table
@@ -107,7 +107,7 @@ public function up(): void
107107
$this->forge->addPrimaryKey('id');
108108
$this->forge->addUniqueKey('selector');
109109
$this->forge->addForeignKey('user_id', SHIELD_TABLES['users'], 'id', '', 'CASCADE');
110-
$this->forge->createTable(SHIELD_TABLES['auth_remember_tokens']);
110+
$this->forge->createTable(SHIELD_TABLES['remember_tokens']);
111111

112112
// Groups Users Table
113113
$this->forge->addField([
@@ -118,7 +118,7 @@ public function up(): void
118118
]);
119119
$this->forge->addPrimaryKey('id');
120120
$this->forge->addForeignKey('user_id', SHIELD_TABLES['users'], 'id', '', 'CASCADE');
121-
$this->forge->createTable(SHIELD_TABLES['auth_groups_users']);
121+
$this->forge->createTable(SHIELD_TABLES['groups_users']);
122122

123123
// Users Permissions Table
124124
$this->forge->addField([
@@ -129,7 +129,7 @@ public function up(): void
129129
]);
130130
$this->forge->addPrimaryKey('id');
131131
$this->forge->addForeignKey('user_id', SHIELD_TABLES['users'], 'id', '', 'CASCADE');
132-
$this->forge->createTable(SHIELD_TABLES['auth_permissions_users']);
132+
$this->forge->createTable(SHIELD_TABLES['permissions_users']);
133133
}
134134

135135
// --------------------------------------------------------------------
@@ -138,12 +138,12 @@ public function down(): void
138138
{
139139
$this->db->disableForeignKeyChecks();
140140

141-
$this->forge->dropTable(SHIELD_TABLES['auth_logins'], true);
142-
$this->forge->dropTable(SHIELD_TABLES['auth_token_logins'], true);
143-
$this->forge->dropTable(SHIELD_TABLES['auth_remember_tokens'], true);
144-
$this->forge->dropTable(SHIELD_TABLES['auth_identities'], true);
145-
$this->forge->dropTable(SHIELD_TABLES['auth_groups_users'], true);
146-
$this->forge->dropTable(SHIELD_TABLES['auth_permissions_users'], true);
141+
$this->forge->dropTable(SHIELD_TABLES['logins'], true);
142+
$this->forge->dropTable(SHIELD_TABLES['token_logins'], true);
143+
$this->forge->dropTable(SHIELD_TABLES['remember_tokens'], true);
144+
$this->forge->dropTable(SHIELD_TABLES['identities'], true);
145+
$this->forge->dropTable(SHIELD_TABLES['groups_users'], true);
146+
$this->forge->dropTable(SHIELD_TABLES['permissions_users'], true);
147147
$this->forge->dropTable(SHIELD_TABLES['users'], true);
148148

149149
$this->db->enableForeignKeyChecks();

src/Models/GroupModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class GroupModel extends Model
1111
{
1212
use CheckQueryReturnTrait;
1313

14-
protected $table = SHIELD_TABLES['auth_groups_users'];
14+
protected $table = SHIELD_TABLES['groups_users'];
1515
protected $primaryKey = 'id';
1616
protected $returnType = 'array';
1717
protected $useSoftDeletes = false;

src/Models/LoginModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class LoginModel extends Model
1515
{
1616
use CheckQueryReturnTrait;
1717

18-
protected $table = SHIELD_TABLES['auth_logins'];
18+
protected $table = SHIELD_TABLES['logins'];
1919
protected $primaryKey = 'id';
2020
protected $returnType = Login::class;
2121
protected $useSoftDeletes = false;

src/Models/PermissionModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class PermissionModel extends Model
1111
{
1212
use CheckQueryReturnTrait;
1313

14-
protected $table = SHIELD_TABLES['auth_permissions_users'];
14+
protected $table = SHIELD_TABLES['permissions_users'];
1515
protected $primaryKey = 'id';
1616
protected $returnType = 'array';
1717
protected $useSoftDeletes = false;

src/Models/RememberModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class RememberModel extends Model
1515
{
1616
use CheckQueryReturnTrait;
1717

18-
protected $table = SHIELD_TABLES['auth_remember_tokens'];
18+
protected $table = SHIELD_TABLES['remember_tokens'];
1919
protected $primaryKey = 'id';
2020
protected $returnType = 'object';
2121
protected $useSoftDeletes = false;

src/Models/TokenLoginModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
class TokenLoginModel extends LoginModel
1212
{
13-
protected $table = SHIELD_TABLES['auth_token_logins'];
13+
protected $table = SHIELD_TABLES['token_logins'];
1414

1515
/**
1616
* Generate a fake login for testing

0 commit comments

Comments
 (0)