Skip to content

Commit 277fe08

Browse files
committed
Add checks for input arguments
1 parent ad388f6 commit 277fe08

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

app/code/Magento/CustomerGraphQl/Model/Resolver/Customer/Account/GenerateCustomerToken.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ class GenerateCustomerToken implements ResolverInterface
2929
*/
3030
public function __construct(
3131
CustomerTokenServiceInterface $customerTokenService
32-
3332
) {
3433
$this->customerTokenService = $customerTokenService;
3534
}
@@ -45,6 +44,12 @@ public function resolve(
4544
array $args = null
4645
) {
4746
try {
47+
if (!isset($args['email'])) {
48+
throw new GraphQlInputException(__('"email" value should be specified'));
49+
}
50+
if (!isset($args['password'])) {
51+
throw new GraphQlInputException(__('"password" value should be specified'));
52+
}
4853
$token = $this->customerTokenService->createCustomerAccessToken($args['email'], $args['password']);
4954
return ['token' => $token];
5055
} catch (AuthenticationException $e) {

app/code/Magento/CustomerGraphQl/etc/schema.graphqls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ type Mutation {
1010
}
1111

1212
type CustomerToken {
13-
token: String @doc(description: "The new customer token")
13+
token: String @doc(description: "The customer token")
1414
}
1515

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

0 commit comments

Comments
 (0)