From d1b67007ba8dc66a4d37a75906b2708ee3fd939a Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 21 Apr 2023 18:24:08 +0900 Subject: [PATCH] docs: change 422 to 401 There is no need to change the status code since a validation error is still an authentication failure. See https://github.com/codeigniter4/shield/pull/195#discussion_r1173193039 --- docs/guides/mobile_apps.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/guides/mobile_apps.md b/docs/guides/mobile_apps.md index 4a22b81d5..237eeeafd 100644 --- a/docs/guides/mobile_apps.md +++ b/docs/guides/mobile_apps.md @@ -41,14 +41,14 @@ class LoginController extends BaseController if (! $this->validateData($this->request->getPost(), $rules)) { return $this->response ->setJSON(['errors' => $this->validator->getErrors()]) - ->setStatusCode(422); + ->setStatusCode(401); } // Get the credentials for login $credentials = $this->request->getPost(setting('Auth.validFields')); $credentials = array_filter($credentials); $credentials['password'] = $this->request->getPost('password'); - + // Attempt to login $result = auth()->attempt($credentials); if (! $result->isOK()) {