Skip to content

Commit f2ddb6f

Browse files
committed
docs: use JSON request
1 parent 200c5ea commit f2ddb6f

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
@@ -163,17 +163,17 @@ class LoginController extends BaseController
163163
$rules = $this->getValidationRules();
164164

165165
// Validate credentials
166-
if (! $this->validateData($this->request->getPost(), $rules)) {
166+
if (! $this->validateData($this->request->getJSON(true), $rules)) {
167167
return $this->fail(
168168
['errors' => $this->validator->getErrors()],
169169
$this->codes['unauthorized']
170170
);
171171
}
172172

173173
// Get the credentials for login
174-
$credentials = $this->request->getPost(setting('Auth.validFields'));
174+
$credentials = $this->request->getJsonVar(setting('Auth.validFields'));
175175
$credentials = array_filter($credentials);
176-
$credentials['password'] = $this->request->getPost('password');
176+
$credentials['password'] = $this->request->getJsonVar('password');
177177

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

234234
```console
235-
curl --location 'http://localhost:8080/auth/jwt' \
236-
--header 'Content-Type: application/x-www-form-urlencoded' \
237-
--data-urlencode '[email protected]' \
238-
--data-urlencode 'password=passw0rd!'
235+
$ curl --location 'http://localhost:8080/auth/jwt' \
236+
--header 'Content-Type: application/json' \
237+
--data-raw '{"email" : "[email protected]" , "password" : "passw0rd!"}'
239238
```
240239

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

0 commit comments

Comments
 (0)