Skip to content

Commit 6a65d58

Browse files
committed
LYNX-361: Implemented GraphQL email confirmation
1 parent f7f4436 commit 6a65d58

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

app/code/Magento/CustomerGraphQl/Model/Resolver/ConfirmEmail.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Magento\CustomerGraphQl\Model\Customer\ExtractCustomerData;
2121
use Magento\Framework\Exception\State\InputMismatchException;
2222
use Magento\Framework\Exception\State\InvalidTransitionException;
23+
use Magento\Framework\Exception\StateException;
2324
use Magento\Framework\GraphQl\Config\Element\Field;
2425
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
2526
use Magento\Framework\GraphQl\Query\Resolver\Value;
@@ -66,13 +67,15 @@ public function resolve(
6667
if (!$this->emailValidator->isValid($args['input']['email'])) {
6768
throw new GraphQlInputException(__('Email is invalid'));
6869
}
69-
7070
try {
7171
$customer = $this->accountManagement->activate($args['input']['email'], $args['input']['confirmation_key']);
7272
} catch (InvalidTransitionException | InputMismatchException $e) {
73-
throw new GraphQlInputException(__($e->getMessage()));
73+
throw new GraphQlInputException(__($e->getRawMessage()));
74+
} catch (StateException) {
75+
throw new GraphQlInputException(__('This confirmation key is invalid or has expired.'));
76+
} catch (\Exception) {
77+
throw new GraphQlInputException(__('There was an error confirming the account'));
7478
}
75-
7679
return ['customer' => $this->extractCustomerData->execute($customer)];
7780
}
7881
}

dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/ConfirmEmailTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ public function testConfirmEmail()
106106
public function testConfirmEmailWrongEmail()
107107
{
108108
$this->expectException(\Exception::class);
109+
$this->expectExceptionMessage('Email is invalid');
109110

110111
$this->graphQlMutation(
111112
sprintf(
@@ -126,6 +127,7 @@ public function testConfirmEmailWrongEmail()
126127
public function testConfirmEmailWrongConfirmation()
127128
{
128129
$this->expectException(\Exception::class);
130+
$this->expectExceptionMessage('The confirmation token is invalid. Verify the token and try again.');
129131

130132
$this->graphQlMutation(
131133
sprintf(

0 commit comments

Comments
 (0)