Skip to content

Commit 63b9a67

Browse files
Merge branch 'magento-commerce:2.4-develop' into L3-PR-2024-02-16
2 parents b56215e + 3e685e0 commit 63b9a67

File tree

29 files changed

+923
-18
lines changed

29 files changed

+923
-18
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<?php
2+
/**
3+
* Copyright 2024 Adobe
4+
* All Rights Reserved.
5+
*
6+
* NOTICE: All information contained herein is, and remains
7+
* the property of Adobe and its suppliers, if any. The intellectual
8+
* and technical concepts contained herein are proprietary to Adobe
9+
* and its suppliers and are protected by all applicable intellectual
10+
* property laws, including trade secret and copyright laws.
11+
* Dissemination of this information or reproduction of this material
12+
* is strictly forbidden unless prior written permission is obtained from
13+
* Adobe.
14+
*/
15+
declare(strict_types=1);
16+
17+
namespace Magento\CustomerGraphQl\Model\Resolver;
18+
19+
use Magento\Customer\Api\AccountManagementInterface;
20+
use Magento\CustomerGraphQl\Model\Customer\ExtractCustomerData;
21+
use Magento\Framework\Exception\State\InputMismatchException;
22+
use Magento\Framework\Exception\State\InvalidTransitionException;
23+
use Magento\Framework\Exception\StateException;
24+
use Magento\Framework\GraphQl\Config\Element\Field;
25+
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
26+
use Magento\Framework\GraphQl\Query\Resolver\Value;
27+
use Magento\Framework\GraphQl\Query\ResolverInterface;
28+
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
29+
use Magento\Framework\Validator\EmailAddress as EmailValidator;
30+
31+
/**
32+
* Customer email confirmation, used for GraphQL request processing
33+
*/
34+
class ConfirmEmail implements ResolverInterface
35+
{
36+
/**
37+
* @param AccountManagementInterface $accountManagement
38+
* @param EmailValidator $emailValidator
39+
* @param ExtractCustomerData $extractCustomerData
40+
*/
41+
public function __construct(
42+
private readonly AccountManagementInterface $accountManagement,
43+
private readonly EmailValidator $emailValidator,
44+
private readonly ExtractCustomerData $extractCustomerData
45+
) {
46+
}
47+
48+
/**
49+
* Confirm customer email mutation
50+
*
51+
* @param \Magento\Framework\GraphQl\Config\Element\Field $field
52+
* @param \Magento\Framework\GraphQl\Query\Resolver\ContextInterface $context
53+
* @param ResolveInfo $info
54+
* @param array|null $value
55+
* @param array|null $args
56+
* @return array|Value
57+
* @throws \Exception
58+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
59+
*/
60+
public function resolve(
61+
Field $field,
62+
$context,
63+
ResolveInfo $info,
64+
array $value = null,
65+
array $args = null
66+
) {
67+
if (!$this->emailValidator->isValid($args['input']['email'])) {
68+
throw new GraphQlInputException(__('Email is invalid'));
69+
}
70+
try {
71+
$customer = $this->accountManagement->activate($args['input']['email'], $args['input']['confirmation_key']);
72+
} catch (InvalidTransitionException | InputMismatchException $e) {
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'));
78+
}
79+
return ['customer' => $this->extractCustomerData->execute($customer)];
80+
}
81+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
/************************************************************************
3+
*
4+
* Copyright 2024 Adobe
5+
* All Rights Reserved.
6+
*
7+
* NOTICE: All information contained herein is, and remains
8+
* the property of Adobe and its suppliers, if any. The intellectual
9+
* and technical concepts contained herein are proprietary to Adobe
10+
* and its suppliers and are protected by all applicable intellectual
11+
* property laws, including trade secret and copyright laws.
12+
* Dissemination of this information or reproduction of this material
13+
* is strictly forbidden unless prior written permission is obtained
14+
* from Adobe.
15+
* ************************************************************************
16+
*/
17+
declare(strict_types=1);
18+
19+
namespace Magento\CustomerGraphQl\Model\Resolver;
20+
21+
use Magento\Customer\Api\AccountManagementInterface;
22+
use Magento\Framework\Exception\LocalizedException;
23+
use Magento\Framework\GraphQl\Config\Element\Field;
24+
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
25+
use Magento\Framework\GraphQl\Query\ResolverInterface;
26+
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
27+
28+
/**
29+
* Confirmation status resolver
30+
*/
31+
class ConfirmationStatus implements ResolverInterface
32+
{
33+
/**
34+
* @param AccountManagementInterface $accountManagement
35+
*/
36+
public function __construct(
37+
private readonly AccountManagementInterface $accountManagement
38+
) {
39+
}
40+
41+
/**
42+
* @inheritdoc
43+
*/
44+
public function resolve(
45+
Field $field,
46+
$context,
47+
ResolveInfo $info,
48+
array $value = null,
49+
array $args = null
50+
) {
51+
try {
52+
$confirmationStatus = $this->accountManagement->getConfirmationStatus($context->getUserId());
53+
} catch (LocalizedException $e) {
54+
throw new GraphQlInputException(__($e->getMessage()), $e);
55+
}
56+
return strtoupper($confirmationStatus);
57+
}
58+
}

app/code/Magento/CustomerGraphQl/etc/graphql/di.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
<item name="required_character_classes_number" xsi:type="string">customer/password/required_character_classes_number</item>
3838
<item name="minimum_password_length" xsi:type="string">customer/password/minimum_password_length</item>
3939
<item name="autocomplete_on_storefront" xsi:type="string">customer/password/autocomplete_on_storefront</item>
40+
<item name="create_account_confirmation" xsi:type="string">customer/create_account/confirm</item>
4041
</argument>
4142
</arguments>
4243
</type>

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ type StoreConfig {
55
required_character_classes_number : String @doc(description: "The number of different character classes (lowercase, uppercase, digits, special characters) required in a password.")
66
minimum_password_length : String @doc(description: "The minimum number of characters required for a valid password.")
77
autocomplete_on_storefront : Boolean @doc(description: "Indicates whether to enable autocomplete on login and forgot password forms.")
8+
create_account_confirmation: Boolean @doc(description: "Indicates if the new accounts need confirmation.")
89
}
910

1011
type Query {
@@ -29,6 +30,12 @@ type Mutation {
2930
requestPasswordResetEmail(email: String! @doc(description: "The customer's email address.")): Boolean @resolver(class: "\\Magento\\CustomerGraphQl\\Model\\Resolver\\RequestPasswordResetEmail") @doc(description: "Request an email with a reset password token for the registered customer identified by the specified email.")
3031
resetPassword(email: String! @doc(description: "The customer's email address."), resetPasswordToken: String! @doc(description: "A runtime token generated by the `requestPasswordResetEmail` mutation."), newPassword: String! @doc(description: "The customer's new password.")): Boolean @resolver(class: "\\Magento\\CustomerGraphQl\\Model\\Resolver\\ResetPassword") @doc(description: "Reset a customer's password using the reset password token that the customer received in an email after requesting it using `requestPasswordResetEmail`.")
3132
updateCustomerEmail(email: String! @doc(description: "The customer's email address."), password: String! @doc(description: "The customer's password.")): CustomerOutput @resolver(class: "\\Magento\\CustomerGraphQl\\Model\\Resolver\\UpdateCustomerEmail") @doc(description: "Change the email address for the logged-in customer.")
33+
confirmEmail(input: ConfirmEmailInput! @doc(description: "An input object to identify the customer to confirm the email.")): CustomerOutput @resolver(class: "\\Magento\\CustomerGraphQl\\Model\\Resolver\\ConfirmEmail") @doc(description: "Confirms the email address for a customer.")
34+
}
35+
36+
input ConfirmEmailInput @doc(description: "Contains details about a customer email address to confirm.") {
37+
email: String! @doc(description: "The email address to be confirmed.")
38+
confirmation_key: String! @doc(description: "The key to confirm the email address.")
3239
}
3340

3441
input CustomerAddressInput @doc(description: "Contains details about a billing or shipping address."){
@@ -140,6 +147,7 @@ type Customer @doc(description: "Defines the customer name, addresses, and other
140147
addresses: [CustomerAddress] @doc(description: "An array containing the customer's shipping and billing addresses.") @resolver(class: "\\Magento\\CustomerGraphQl\\Model\\Resolver\\CustomerAddresses")
141148
gender: Int @doc(description: "The customer's gender (Male - 1, Female - 2).")
142149
custom_attributes(attributeCodes: [ID!]): [AttributeValueInterface] @doc(description: "Customer's custom attributes.") @resolver(class: "Magento\\CustomerGraphQl\\Model\\Resolver\\CustomAttributeFilter")
150+
confirmation_status: ConfirmationStatusEnum! @doc(description: "The customer's confirmation status.") @resolver(class: "Magento\\CustomerGraphQl\\Model\\Resolver\\ConfirmationStatus")
143151
}
144152

145153
type CustomerAddress @doc(description: "Contains detailed information about a customer's billing or shipping address."){
@@ -467,3 +475,8 @@ enum ValidationRuleEnum @doc(description: "List of validation rule names applied
467475
MAX_IMAGE_HEIGHT
468476
MAX_IMAGE_WIDTH
469477
}
478+
479+
enum ConfirmationStatusEnum @doc(description: "List of account confirmation statuses.") {
480+
ACCOUNT_CONFIRMED @doc(description: "Account confirmed")
481+
ACCOUNT_CONFIRMATION_NOT_REQUIRED @doc(description: "Account confirmation not required")
482+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Magento_IntegrationGraphQl module
2+
3+
This module provides GraphQl resolvers for Integartion module.
4+
5+
## Installation
6+
7+
Before installing this module, note that the Magento_IntegrationGraphQl is dependent on the following modules:
8+
9+
- `Magento_GraphQl`
10+
- `Magento_Integration`
11+
12+
For information about a module installation in Magento 2, see [Enable or disable modules](https://experienceleague.adobe.com/docs/commerce-operations/installation-guide/tutorials/manage-modules.html).
13+
14+
## Extensibility
15+
16+
Extension developers can interact with the Magento_IntegrationGraphQl module. For more information about the Magento extension mechanism, see [Magento plugins](https://developer.adobe.com/commerce/php/development/components/plugins/).
17+
18+
[The Magento dependency injection mechanism](https://developer.adobe.com/commerce/php/development/components/dependency-injection/) enables you to override the functionality of the Magento_IntegrationGraphQl module.
19+
20+
## Additional information
21+
22+
You can get more information about [GraphQl In Magento 2](https://developer.adobe.com/commerce/webapi/graphql/).
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "magento/module-integration-graph-ql",
3+
"description": "N/A",
4+
"type": "magento2-module",
5+
"require": {
6+
"php": "~8.1.0||~8.2.0||~8.3.0",
7+
"magento/framework": "*"
8+
},
9+
"license": [
10+
"OSL-3.0",
11+
"AFL-3.0"
12+
],
13+
"autoload": {
14+
"files": [
15+
"registration.php"
16+
],
17+
"psr-4": {
18+
"Magento\\IntegrationGraphQl\\": ""
19+
}
20+
}
21+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/************************************************************************
4+
*
5+
* Copyright 2024 Adobe
6+
* All Rights Reserved.
7+
*
8+
* NOTICE: All information contained herein is, and remains
9+
* the property of Adobe and its suppliers, if any. The intellectual
10+
* and technical concepts contained herein are proprietary to Adobe
11+
* and its suppliers and are protected by all applicable intellectual
12+
* property laws, including trade secret and copyright laws.
13+
* Dissemination of this information or reproduction of this material
14+
* is strictly forbidden unless prior written permission is obtained
15+
* from Adobe.
16+
* ************************************************************************
17+
*/
18+
-->
19+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
20+
<type name="Magento\StoreGraphQl\Model\Resolver\Store\StoreConfigDataProvider">
21+
<arguments>
22+
<argument name="extendedConfigData" xsi:type="array">
23+
<item name="customer_access_token_lifetime" xsi:type="string">oauth/access_token_lifetime/customer</item>
24+
</argument>
25+
</arguments>
26+
</type>
27+
</config>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/************************************************************************
4+
*
5+
* Copyright 2024 Adobe
6+
* All Rights Reserved.
7+
*
8+
* NOTICE: All information contained herein is, and remains
9+
* the property of Adobe and its suppliers, if any. The intellectual
10+
* and technical concepts contained herein are proprietary to Adobe
11+
* and its suppliers and are protected by all applicable intellectual
12+
* property laws, including trade secret and copyright laws.
13+
* Dissemination of this information or reproduction of this material
14+
* is strictly forbidden unless prior written permission is obtained
15+
* from Adobe.
16+
* ************************************************************************
17+
*/
18+
-->
19+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
20+
<module name="Magento_IntegrationGraphQl" >
21+
</module>
22+
</config>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# ADOBE CONFIDENTIAL
2+
# ___________________
3+
#
4+
# Copyright 2024 Adobe
5+
# All Rights Reserved.
6+
#
7+
# NOTICE: All information contained herein is, and remains
8+
# the property of Adobe and its suppliers, if any. The intellectual
9+
# and technical concepts contained herein are proprietary to Adobe
10+
# and its suppliers and are protected by all applicable intellectual
11+
# property laws, including trade secret and copyright laws.
12+
# Dissemination of this information or reproduction of this material
13+
# is strictly forbidden unless prior written permission is obtained
14+
# from Adobe.
15+
16+
type StoreConfig {
17+
customer_access_token_lifetime: Float @doc(description: "Customer access token lifetime.")
18+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
/**
3+
* Copyright 2024 Adobe
4+
* All Rights Reserved.
5+
*
6+
* NOTICE: All information contained herein is, and remains
7+
* the property of Adobe and its suppliers, if any. The intellectual
8+
* and technical concepts contained herein are proprietary to Adobe
9+
* and its suppliers and are protected by all applicable intellectual
10+
* property laws, including trade secret and copyright laws.
11+
* Dissemination of this information or reproduction of this material
12+
* is strictly forbidden unless prior written permission is obtained from
13+
* Adobe.
14+
*/
15+
declare(strict_types=1);
16+
17+
use Magento\Framework\Component\ComponentRegistrar;
18+
19+
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_IntegrationGraphQl', __DIR__);

0 commit comments

Comments
 (0)