Skip to content

Commit

Permalink
cr remark
Browse files Browse the repository at this point in the history
  • Loading branch information
konradoboza committed Jun 26, 2024
1 parent 18233e6 commit 83413ce
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/lib/Mutation/AuthenticationMutation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, ?string>
*/
private function getWrongCredentialsErrorMessage(): array
{
return [
'message' => 'Wrong username or password',
'token' => null,
];
}
}

0 comments on commit 83413ce

Please sign in to comment.