From 83413ce5032b4f61ac4003d239ada87dfa826182 Mon Sep 17 00:00:00 2001 From: konradoboza Date: Wed, 26 Jun 2024 13:06:38 +0200 Subject: [PATCH] cr remark --- src/lib/Mutation/AuthenticationMutation.php | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/lib/Mutation/AuthenticationMutation.php b/src/lib/Mutation/AuthenticationMutation.php index 94e7878..eabb351 100644 --- a/src/lib/Mutation/AuthenticationMutation.php +++ b/src/lib/Mutation/AuthenticationMutation.php @@ -39,21 +39,26 @@ public function createToken(Argument $args): array try { $user = $this->userService->loadUserByLogin($args['username']); } catch (NotFoundException) { - return [ - 'message' => 'Wrong username', - 'token' => null, - ]; + return $this->getWrongCredentialsErrorMessage(); } if (!$this->userService->checkUserCredentials($user, $args['password'])) { - return [ - 'message' => 'Wrong password', - 'token' => null, - ]; + return $this->getWrongCredentialsErrorMessage(); } return [ 'token' => $this->tokenManager->create(new User($user)), ]; } + + /** + * @return array + */ + private function getWrongCredentialsErrorMessage(): array + { + return [ + 'message' => 'Wrong username or password', + 'token' => null, + ]; + } }