Skip to content

Commit 72047b7

Browse files
committed
docs: use JSON request
1 parent 3117c17 commit 72047b7

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

docs/addons/jwt.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,17 +134,17 @@ class LoginController extends BaseController
134134
$rules = $this->getValidationRules();
135135

136136
// Validate credentials
137-
if (! $this->validateData($this->request->getPost(), $rules)) {
137+
if (! $this->validateData($this->request->getJSON(true), $rules)) {
138138
return $this->fail(
139139
['errors' => $this->validator->getErrors()],
140140
$this->codes['unauthorized']
141141
);
142142
}
143143

144144
// Get the credentials for login
145-
$credentials = $this->request->getPost(setting('Auth.validFields'));
145+
$credentials = $this->request->getJsonVar(setting('Auth.validFields'));
146146
$credentials = array_filter($credentials);
147-
$credentials['password'] = $this->request->getPost('password');
147+
$credentials['password'] = $this->request->getJsonVar('password');
148148

149149
/** @var Session $authenticator */
150150
$authenticator = auth('session')->getAuthenticator();
@@ -203,10 +203,9 @@ class LoginController extends BaseController
203203
You could send a request with the existing user's credentials by curl like this:
204204

205205
```console
206-
curl --location 'http://localhost:8080/auth/jwt' \
207-
--header 'Content-Type: application/x-www-form-urlencoded' \
208-
--data-urlencode 'email=user1@example.jp' \
209-
--data-urlencode 'password=passw0rd!'
206+
$ curl --location 'http://localhost:8080/auth/jwt' \
207+
--header 'Content-Type: application/json' \
208+
--data-raw '{"email" : "admin@example.jp" , "password" : "passw0rd!"}'
210209
```
211210

212211
When making all future requests to the API, the client should send the JWT in

0 commit comments

Comments
 (0)