-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '2.4-develop' into PR-03-11-2024
- Loading branch information
Showing
29 changed files
with
923 additions
and
18 deletions.
There are no files selected for viewing
81 changes: 81 additions & 0 deletions
81
app/code/Magento/CustomerGraphQl/Model/Resolver/ConfirmEmail.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?php | ||
/** | ||
* Copyright 2024 Adobe | ||
* All Rights Reserved. | ||
* | ||
* NOTICE: All information contained herein is, and remains | ||
* the property of Adobe and its suppliers, if any. The intellectual | ||
* and technical concepts contained herein are proprietary to Adobe | ||
* and its suppliers and are protected by all applicable intellectual | ||
* property laws, including trade secret and copyright laws. | ||
* Dissemination of this information or reproduction of this material | ||
* is strictly forbidden unless prior written permission is obtained from | ||
* Adobe. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\CustomerGraphQl\Model\Resolver; | ||
|
||
use Magento\Customer\Api\AccountManagementInterface; | ||
use Magento\CustomerGraphQl\Model\Customer\ExtractCustomerData; | ||
use Magento\Framework\Exception\State\InputMismatchException; | ||
use Magento\Framework\Exception\State\InvalidTransitionException; | ||
use Magento\Framework\Exception\StateException; | ||
use Magento\Framework\GraphQl\Config\Element\Field; | ||
use Magento\Framework\GraphQl\Exception\GraphQlInputException; | ||
use Magento\Framework\GraphQl\Query\Resolver\Value; | ||
use Magento\Framework\GraphQl\Query\ResolverInterface; | ||
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; | ||
use Magento\Framework\Validator\EmailAddress as EmailValidator; | ||
|
||
/** | ||
* Customer email confirmation, used for GraphQL request processing | ||
*/ | ||
class ConfirmEmail implements ResolverInterface | ||
{ | ||
/** | ||
* @param AccountManagementInterface $accountManagement | ||
* @param EmailValidator $emailValidator | ||
* @param ExtractCustomerData $extractCustomerData | ||
*/ | ||
public function __construct( | ||
private readonly AccountManagementInterface $accountManagement, | ||
private readonly EmailValidator $emailValidator, | ||
private readonly ExtractCustomerData $extractCustomerData | ||
) { | ||
} | ||
|
||
/** | ||
* Confirm customer email mutation | ||
* | ||
* @param \Magento\Framework\GraphQl\Config\Element\Field $field | ||
* @param \Magento\Framework\GraphQl\Query\Resolver\ContextInterface $context | ||
* @param ResolveInfo $info | ||
* @param array|null $value | ||
* @param array|null $args | ||
* @return array|Value | ||
* @throws \Exception | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function resolve( | ||
Field $field, | ||
$context, | ||
ResolveInfo $info, | ||
array $value = null, | ||
array $args = null | ||
) { | ||
if (!$this->emailValidator->isValid($args['input']['email'])) { | ||
throw new GraphQlInputException(__('Email is invalid')); | ||
} | ||
try { | ||
$customer = $this->accountManagement->activate($args['input']['email'], $args['input']['confirmation_key']); | ||
} catch (InvalidTransitionException | InputMismatchException $e) { | ||
throw new GraphQlInputException(__($e->getRawMessage())); | ||
} catch (StateException) { | ||
throw new GraphQlInputException(__('This confirmation key is invalid or has expired.')); | ||
} catch (\Exception) { | ||
throw new GraphQlInputException(__('There was an error confirming the account')); | ||
} | ||
return ['customer' => $this->extractCustomerData->execute($customer)]; | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
app/code/Magento/CustomerGraphQl/Model/Resolver/ConfirmationStatus.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
/************************************************************************ | ||
* | ||
* Copyright 2024 Adobe | ||
* All Rights Reserved. | ||
* | ||
* NOTICE: All information contained herein is, and remains | ||
* the property of Adobe and its suppliers, if any. The intellectual | ||
* and technical concepts contained herein are proprietary to Adobe | ||
* and its suppliers and are protected by all applicable intellectual | ||
* property laws, including trade secret and copyright laws. | ||
* Dissemination of this information or reproduction of this material | ||
* is strictly forbidden unless prior written permission is obtained | ||
* from Adobe. | ||
* ************************************************************************ | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\CustomerGraphQl\Model\Resolver; | ||
|
||
use Magento\Customer\Api\AccountManagementInterface; | ||
use Magento\Framework\Exception\LocalizedException; | ||
use Magento\Framework\GraphQl\Config\Element\Field; | ||
use Magento\Framework\GraphQl\Exception\GraphQlInputException; | ||
use Magento\Framework\GraphQl\Query\ResolverInterface; | ||
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; | ||
|
||
/** | ||
* Confirmation status resolver | ||
*/ | ||
class ConfirmationStatus implements ResolverInterface | ||
{ | ||
/** | ||
* @param AccountManagementInterface $accountManagement | ||
*/ | ||
public function __construct( | ||
private readonly AccountManagementInterface $accountManagement | ||
) { | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function resolve( | ||
Field $field, | ||
$context, | ||
ResolveInfo $info, | ||
array $value = null, | ||
array $args = null | ||
) { | ||
try { | ||
$confirmationStatus = $this->accountManagement->getConfirmationStatus($context->getUserId()); | ||
} catch (LocalizedException $e) { | ||
throw new GraphQlInputException(__($e->getMessage()), $e); | ||
} | ||
return strtoupper($confirmationStatus); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Magento_IntegrationGraphQl module | ||
|
||
This module provides GraphQl resolvers for Integartion module. | ||
|
||
## Installation | ||
|
||
Before installing this module, note that the Magento_IntegrationGraphQl is dependent on the following modules: | ||
|
||
- `Magento_GraphQl` | ||
- `Magento_Integration` | ||
|
||
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). | ||
|
||
## Extensibility | ||
|
||
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/). | ||
|
||
[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. | ||
|
||
## Additional information | ||
|
||
You can get more information about [GraphQl In Magento 2](https://developer.adobe.com/commerce/webapi/graphql/). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "magento/module-integration-graph-ql", | ||
"description": "N/A", | ||
"type": "magento2-module", | ||
"require": { | ||
"php": "~8.1.0||~8.2.0||~8.3.0", | ||
"magento/framework": "*" | ||
}, | ||
"license": [ | ||
"OSL-3.0", | ||
"AFL-3.0" | ||
], | ||
"autoload": { | ||
"files": [ | ||
"registration.php" | ||
], | ||
"psr-4": { | ||
"Magento\\IntegrationGraphQl\\": "" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
/************************************************************************ | ||
* | ||
* Copyright 2024 Adobe | ||
* All Rights Reserved. | ||
* | ||
* NOTICE: All information contained herein is, and remains | ||
* the property of Adobe and its suppliers, if any. The intellectual | ||
* and technical concepts contained herein are proprietary to Adobe | ||
* and its suppliers and are protected by all applicable intellectual | ||
* property laws, including trade secret and copyright laws. | ||
* Dissemination of this information or reproduction of this material | ||
* is strictly forbidden unless prior written permission is obtained | ||
* from Adobe. | ||
* ************************************************************************ | ||
*/ | ||
--> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> | ||
<type name="Magento\StoreGraphQl\Model\Resolver\Store\StoreConfigDataProvider"> | ||
<arguments> | ||
<argument name="extendedConfigData" xsi:type="array"> | ||
<item name="customer_access_token_lifetime" xsi:type="string">oauth/access_token_lifetime/customer</item> | ||
</argument> | ||
</arguments> | ||
</type> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
/************************************************************************ | ||
* | ||
* Copyright 2024 Adobe | ||
* All Rights Reserved. | ||
* | ||
* NOTICE: All information contained herein is, and remains | ||
* the property of Adobe and its suppliers, if any. The intellectual | ||
* and technical concepts contained herein are proprietary to Adobe | ||
* and its suppliers and are protected by all applicable intellectual | ||
* property laws, including trade secret and copyright laws. | ||
* Dissemination of this information or reproduction of this material | ||
* is strictly forbidden unless prior written permission is obtained | ||
* from Adobe. | ||
* ************************************************************************ | ||
*/ | ||
--> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> | ||
<module name="Magento_IntegrationGraphQl" > | ||
</module> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# ADOBE CONFIDENTIAL | ||
# ___________________ | ||
# | ||
# Copyright 2024 Adobe | ||
# All Rights Reserved. | ||
# | ||
# NOTICE: All information contained herein is, and remains | ||
# the property of Adobe and its suppliers, if any. The intellectual | ||
# and technical concepts contained herein are proprietary to Adobe | ||
# and its suppliers and are protected by all applicable intellectual | ||
# property laws, including trade secret and copyright laws. | ||
# Dissemination of this information or reproduction of this material | ||
# is strictly forbidden unless prior written permission is obtained | ||
# from Adobe. | ||
|
||
type StoreConfig { | ||
customer_access_token_lifetime: Float @doc(description: "Customer access token lifetime.") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
/** | ||
* Copyright 2024 Adobe | ||
* All Rights Reserved. | ||
* | ||
* NOTICE: All information contained herein is, and remains | ||
* the property of Adobe and its suppliers, if any. The intellectual | ||
* and technical concepts contained herein are proprietary to Adobe | ||
* and its suppliers and are protected by all applicable intellectual | ||
* property laws, including trade secret and copyright laws. | ||
* Dissemination of this information or reproduction of this material | ||
* is strictly forbidden unless prior written permission is obtained from | ||
* Adobe. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
use Magento\Framework\Component\ComponentRegistrar; | ||
|
||
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_IntegrationGraphQl', __DIR__); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.