質問編集履歴
1
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,14 +1,40 @@
|
|
1
|
+
>
|
2
|
+
|
3
|
+
$authenticationService->loadIdentifier('Authentication.Password', [
|
4
|
+
|
1
|
-
|
5
|
+
'resolver'=>[
|
2
|
-
|
3
|
-
|
4
|
-
|
6
|
+
|
5
|
-
|
7
|
+
'className' => 'Authentication.Orm',
|
8
|
+
|
6
|
-
|
9
|
+
'userModel' => 'Contacts'
|
10
|
+
|
7
|
-
|
11
|
+
],
|
12
|
+
|
8
|
-
|
13
|
+
'fields' => [
|
14
|
+
|
9
|
-
|
15
|
+
'username' => 'mail',
|
16
|
+
|
10
|
-
|
17
|
+
'password' => 'password',
|
18
|
+
|
19
|
+
]
|
20
|
+
|
21
|
+
]);
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
の'fields'の中の'username' => 'mail'と私は記載したのですが、ほとんどのサイトではmailではなく、'email'と記載しております。これはテーブルのカラムのことを指しているのでしょうか???
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
```php
|
32
|
+
|
33
|
+
<?php
|
34
|
+
|
35
|
+
|
36
|
+
|
11
|
-
public function getAuthenticationService(ServerRequestInterface $request): AuthenticationServiceInterface
|
37
|
+
public function getAuthenticationService(ServerRequestInterface $request): AuthenticationServiceInterface
|
12
38
|
|
13
39
|
{
|
14
40
|
|
@@ -80,30 +106,266 @@
|
|
80
106
|
|
81
107
|
|
82
108
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
109
|
+
```php
|
110
|
+
|
111
|
+
<?php
|
112
|
+
|
113
|
+
declare(strict_types=1);
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
namespace App\Model\Table;
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
use Cake\ORM\Query;
|
122
|
+
|
123
|
+
use Cake\ORM\RulesChecker;
|
124
|
+
|
125
|
+
use Cake\ORM\Table;
|
126
|
+
|
127
|
+
use Cake\Validation\Validator;
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
/**
|
132
|
+
|
133
|
+
* Contacts Model
|
134
|
+
|
135
|
+
*
|
136
|
+
|
137
|
+
* @method \App\Model\Entity\Contact newEmptyEntity()
|
138
|
+
|
139
|
+
* @method \App\Model\Entity\Contact newEntity(array $data, array $options = [])
|
140
|
+
|
141
|
+
* @method \App\Model\Entity\Contact[] newEntities(array $data, array $options = [])
|
142
|
+
|
143
|
+
* @method \App\Model\Entity\Contact get($primaryKey, $options = [])
|
144
|
+
|
145
|
+
* @method \App\Model\Entity\Contact findOrCreate($search, ?callable $callback = null, $options = [])
|
146
|
+
|
147
|
+
* @method \App\Model\Entity\Contact patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
|
148
|
+
|
149
|
+
* @method \App\Model\Entity\Contact[] patchEntities(iterable $entities, array $data, array $options = [])
|
150
|
+
|
151
|
+
* @method \App\Model\Entity\Contact|false save(\Cake\Datasource\EntityInterface $entity, $options = [])
|
152
|
+
|
153
|
+
* @method \App\Model\Entity\Contact saveOrFail(\Cake\Datasource\EntityInterface $entity, $options = [])
|
154
|
+
|
155
|
+
* @method \App\Model\Entity\Contact[]|\Cake\Datasource\ResultSetInterface|false saveMany(iterable $entities, $options = [])
|
156
|
+
|
157
|
+
* @method \App\Model\Entity\Contact[]|\Cake\Datasource\ResultSetInterface saveManyOrFail(iterable $entities, $options = [])
|
158
|
+
|
159
|
+
* @method \App\Model\Entity\Contact[]|\Cake\Datasource\ResultSetInterface|false deleteMany(iterable $entities, $options = [])
|
160
|
+
|
161
|
+
* @method \App\Model\Entity\Contact[]|\Cake\Datasource\ResultSetInterface deleteManyOrFail(iterable $entities, $options = [])
|
162
|
+
|
163
|
+
*
|
164
|
+
|
165
|
+
* @mixin \Cake\ORM\Behavior\TimestampBehavior
|
166
|
+
|
167
|
+
*/
|
168
|
+
|
169
|
+
class ContactsTable extends Table
|
170
|
+
|
171
|
+
{
|
172
|
+
|
173
|
+
/**
|
174
|
+
|
175
|
+
* Initialize method
|
176
|
+
|
177
|
+
*
|
178
|
+
|
179
|
+
* @param array $config The configuration for the Table.
|
180
|
+
|
181
|
+
* @return void
|
182
|
+
|
183
|
+
*/
|
184
|
+
|
185
|
+
public function initialize(array $config): void
|
186
|
+
|
187
|
+
{
|
188
|
+
|
189
|
+
parent::initialize($config);
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
$this->setTable('contacts');
|
194
|
+
|
195
|
+
$this->setDisplayField('name');
|
196
|
+
|
197
|
+
$this->setPrimaryKey('id');
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
$this->addBehavior('Timestamp');
|
202
|
+
|
203
|
+
}
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
/**
|
208
|
+
|
209
|
+
* Default validation rules.
|
210
|
+
|
211
|
+
*
|
212
|
+
|
213
|
+
* @param \Cake\Validation\Validator $validator Validator instance.
|
214
|
+
|
215
|
+
* @return \Cake\Validation\Validator
|
216
|
+
|
217
|
+
*/
|
218
|
+
|
219
|
+
public function validationDefault(Validator $validator): Validator
|
220
|
+
|
221
|
+
{
|
222
|
+
|
223
|
+
$validator
|
224
|
+
|
225
|
+
->integer('id')
|
226
|
+
|
227
|
+
->allowEmptyString('id', null, 'create');
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
$validator
|
232
|
+
|
233
|
+
->scalar('name')
|
234
|
+
|
235
|
+
->maxLength('name', 10)
|
236
|
+
|
237
|
+
->requirePresence('name', 'create')
|
238
|
+
|
239
|
+
->notEmptyString('name');
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
$validator
|
244
|
+
|
245
|
+
->scalar('katakana')
|
246
|
+
|
247
|
+
->maxLength('katakana', 10)
|
248
|
+
|
249
|
+
->requirePresence('katakana', 'create')
|
250
|
+
|
251
|
+
->notEmptyString('katakana');
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
$validator
|
256
|
+
|
257
|
+
->integer('tel')
|
258
|
+
|
259
|
+
->requirePresence('tel', 'create')
|
260
|
+
|
261
|
+
->notEmptyString('tel');
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
$validator
|
266
|
+
|
267
|
+
->scalar('mail')
|
268
|
+
|
269
|
+
->maxLength('mail', 255)
|
270
|
+
|
271
|
+
->requirePresence('mail', 'create')
|
272
|
+
|
273
|
+
->notEmptyString('mail');
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
$validator
|
278
|
+
|
279
|
+
->scalar('textarea')
|
280
|
+
|
281
|
+
->maxLength('textarea', 255)
|
282
|
+
|
283
|
+
->requirePresence('textarea', 'create')
|
284
|
+
|
285
|
+
->notEmptyString('textarea');
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
$validator
|
290
|
+
|
291
|
+
->scalar('password')
|
292
|
+
|
293
|
+
->maxLength('password', 255)
|
294
|
+
|
295
|
+
->requirePresence('password', 'create')
|
296
|
+
|
297
|
+
->notEmptyString('password');
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
$validator
|
302
|
+
|
303
|
+
->scalar('role')
|
304
|
+
|
305
|
+
->maxLength('role', 20)
|
306
|
+
|
307
|
+
->requirePresence('role', 'create')
|
308
|
+
|
309
|
+
->notEmptyString('role');
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
return $validator;
|
314
|
+
|
315
|
+
}
|
316
|
+
|
317
|
+
}
|
318
|
+
|
319
|
+
```
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
```php
|
324
|
+
|
325
|
+
<?php
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
protected $_accessible = [
|
330
|
+
|
331
|
+
'id' => false,
|
332
|
+
|
333
|
+
'name' => true,
|
334
|
+
|
335
|
+
'katakana' => true,
|
336
|
+
|
337
|
+
'tel' => true,
|
338
|
+
|
339
|
+
'mail' => true,
|
340
|
+
|
341
|
+
'textarea' => true,
|
342
|
+
|
343
|
+
'password' => true,
|
344
|
+
|
345
|
+
'role' => true,
|
346
|
+
|
347
|
+
'created' => true,
|
348
|
+
|
349
|
+
'modified' => true,
|
350
|
+
|
351
|
+
];
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
protected function _setPassword($password)
|
356
|
+
|
357
|
+
{
|
358
|
+
|
359
|
+
if (strlen($password) > 0) {
|
360
|
+
|
361
|
+
return (new DefaultPasswordHasher)->hash($password);
|
362
|
+
|
363
|
+
}
|
364
|
+
|
365
|
+
}
|
366
|
+
|
367
|
+
}
|
368
|
+
|
369
|
+
|
370
|
+
|
371
|
+
```
|