Skip to content

Commit

Permalink
Add checks for input arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
TomashKhamlai committed Sep 14, 2018
1 parent ad388f6 commit 277fe08
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class GenerateCustomerToken implements ResolverInterface
*/
public function __construct(
CustomerTokenServiceInterface $customerTokenService

) {
$this->customerTokenService = $customerTokenService;
}
Expand All @@ -45,6 +44,12 @@ public function resolve(
array $args = null
) {
try {
if (!isset($args['email'])) {
throw new GraphQlInputException(__('"email" value should be specified'));
}
if (!isset($args['password'])) {
throw new GraphQlInputException(__('"password" value should be specified'));
}
$token = $this->customerTokenService->createCustomerAccessToken($args['email'], $args['password']);
return ['token' => $token];
} catch (AuthenticationException $e) {
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/CustomerGraphQl/etc/schema.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type Mutation {
}

type CustomerToken {
token: String @doc(description: "The new customer token")
token: String @doc(description: "The customer token")
}

type Customer @doc(description: "Customer defines the customer name and address and other details") {
Expand Down

0 comments on commit 277fe08

Please sign in to comment.