質問編集履歴
4
追記2
title
CHANGED
File without changes
|
body
CHANGED
@@ -118,4 +118,18 @@
|
|
118
118
|
die;
|
119
119
|
```
|
120
120
|
|
121
|
-
としてもまだfalse
|
121
|
+
としてもまだfalse
|
122
|
+
|
123
|
+
|
124
|
+
# 追記2
|
125
|
+
|
126
|
+
```php
|
127
|
+
$this->Auth->setUser(['id' => 1, 'username' => 'mymail@example.com', 'password' => 'mypassword', 'role' => 'normal']);
|
128
|
+
|
129
|
+
$user = $this->Auth->user()
|
130
|
+
```
|
131
|
+
|
132
|
+
とすれば取れるのか……
|
133
|
+
え?でもなんで、
|
134
|
+
`$user = $this->Auth->identify();`
|
135
|
+
だとfalseになるん…?
|
3
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -105,4 +105,17 @@
|
|
105
105
|
この様に、POST通信やBASIC認証などがない場合、
|
106
106
|
どのようにしてCakephpの認証を利用するのでしょうか。
|
107
107
|
|
108
|
-
ご存じの方がいらっしゃいましたら、ご教示いただけますと幸いです。
|
108
|
+
ご存じの方がいらっしゃいましたら、ご教示いただけますと幸いです。
|
109
|
+
|
110
|
+
|
111
|
+
# 追記
|
112
|
+
|
113
|
+
```php
|
114
|
+
$this->Auth->setUser(['id' => 1, 'username' => 'mymail@example.com', 'password' => 'mypassword', 'role' => 'normal']);
|
115
|
+
|
116
|
+
$user = $this->Auth->identify();
|
117
|
+
var_dump($user);
|
118
|
+
die;
|
119
|
+
```
|
120
|
+
|
121
|
+
としてもまだfalse
|
2
ちょっと進捗
title
CHANGED
File without changes
|
body
CHANGED
@@ -44,8 +44,8 @@
|
|
44
44
|
```php
|
45
45
|
public function index()
|
46
46
|
{
|
47
|
-
$this->request->withData('
|
47
|
+
$this->request = $this->request->withData('username', 'mymail@example.com');
|
48
|
-
$this->request->withData('password', 'mypassword');
|
48
|
+
$this->request = $this->request->withData('password', 'mypassword');
|
49
49
|
|
50
50
|
$user = $this->Auth->identify();
|
51
51
|
var_dump($user);
|
@@ -77,7 +77,7 @@
|
|
77
77
|
```php
|
78
78
|
$this->loadComponent('Auth', [
|
79
79
|
'authorize' => ['Controller'],
|
80
|
-
'authenticate' => ['Form' => ['
|
80
|
+
'authenticate' => ['Form' => ['finder' => 'auth', 'username' => 'email', 'password' => 'password']]],
|
81
81
|
'loginRedirect' => ['controller' => 'Users', 'action' => 'index'],
|
82
82
|
'logoutRedirect' => ['controller' => 'Users', 'action' => 'login'],
|
83
83
|
'loginAction' => '/login',
|
@@ -85,6 +85,21 @@
|
|
85
85
|
]);
|
86
86
|
```
|
87
87
|
|
88
|
+
UsersTable.php
|
89
|
+
|
90
|
+
```php
|
91
|
+
public function findAuth(Query $query, array $options)
|
92
|
+
{
|
93
|
+
$query
|
94
|
+
->select(['id', 'username', 'password'])
|
95
|
+
->where(['Users.username' => $options['username']]);
|
96
|
+
|
97
|
+
var_dump($query->toArray());
|
98
|
+
|
99
|
+
return $query;
|
100
|
+
}
|
101
|
+
```
|
102
|
+
|
88
103
|
としています。
|
89
104
|
|
90
105
|
この様に、POST通信やBASIC認証などがない場合、
|
1
miss
title
CHANGED
File without changes
|
body
CHANGED
File without changes
|