hryvinskyi / magento2-customer-sign-in-login-as-customer
Bridge of the customer sign-in suite and Login as Customer: an administrator signed in as a customer who owes a second sign-in step is not sent to Sign-in & Security.
Package info
github.com/hryvinskyi/magento2-customer-sign-in-login-as-customer
Type:magento2-module
pkg:composer/hryvinskyi/magento2-customer-sign-in-login-as-customer
Requires
- php: ~8.1.0||~8.2.0||~8.3.0||~8.4.0||~8.5.0
- hryvinskyi/magento2-customer-sign-in-frontend: ^1.0
- magento/framework: *
- magento/module-login-as-customer: *
- magento/module-login-as-customer-api: *
Requires (Dev)
- hryvinskyi/magento2-customer-sign-in: ^1.0
- hryvinskyi/magento2-customer-sign-in-api: ^1.0
- magento/module-customer: *
Suggests
- hryvinskyi/magento2-customer-sign-in: needed only to run this package's integration tests
- magento/module-customer: needed only to run this package's integration tests
Provides
None
Conflicts
None
Replaces
None
README
The bridge between the customer sign-in suite and the platform's Login as Customer. A store can require a second sign-in step from the customers of chosen groups, and the suite's storefront package sends a customer who owes one to Sign-in & Security until they set it up. An administrator who signs in as such a customer, to help them with an order or their account, is not that customer and cannot set up the customer's second step. This package lets the administrator through. It adds no page, setting or table.
What it does for a store
- An administrator signed in as a customer is not held back. While Login as Customer is active in the storefront session, a customer's missing second step sends nobody to Sign-in & Security: My Account and every other page that holds such a customer back, the checkout page included, open for the administrator.
- The customer is still held back. When the customer signs in by themselves, the requirement applies to them.
- The notice still shows. Sign-in & Security shows the administrator
Your store requires a second sign-in step for your account. Set one up below to continue.while the customer owes one, so they can tell the customer.
Who owes a second step, and the settings that decide it, are described in the README of hryvinskyi/magento2-customer-sign-in.
Requirements
- Magento Open Source or Adobe Commerce 2.4.x. The suite is built and tested on 2.4.9.
- PHP 8.1 to 8.5.
hryvinskyi/magento2-customer-sign-in-frontend^1.0, which brings the sign-in engine and its contracts.- The platform's Login as Customer modules:
magento/module-login-as-customer-api, whose contract this package reads, andmagento/module-login-as-customer, which implements it. Composer installs both with this package; both must be enabled.
Installation
Run from the Magento root. hryvinskyi/magento2-customer-sign-in-pack installs this package with the rest of the suite.
composer require hryvinskyi/magento2-customer-sign-in-login-as-customer
bin/magento module:enable Hryvinskyi_Clock Hryvinskyi_RateLimit Hryvinskyi_VerificationCode Hryvinskyi_CustomerSignInApi Hryvinskyi_CustomerSignIn Hryvinskyi_CustomerSignInFrontend Hryvinskyi_CustomerSignInLoginAsCustomer
bin/magento setup:upgrade
bin/magento setup:di:compile # production mode only
bin/magento cache:flush
A store that disabled the platform's Login as Customer modules adds Magento_LoginAsCustomerApi and Magento_LoginAsCustomer to the module:enable line: Magento refuses to enable a module while one it requires is disabled, and the storefront needs the implementation (see Requirements).
Verify: bin/magento module:status Hryvinskyi_CustomerSignInLoginAsCustomer prints Hryvinskyi_CustomerSignInLoginAsCustomer : Module is enabled.
Configuration
None of its own. It has an effect only while the platform's Login as Customer is switched on, so an administrator can sign in as a customer, and while the store requires a second step (Stores > Settings > Configuration > Customers > Sign-in Methods > General, Require a Second Step).
Stored data
None.
Registrations
| Where | What |
|---|---|
Argument exemptions of Hryvinskyi\CustomerSignInFrontend\Model\SecondStepSetUpGate (etc/frontend/di.xml) |
Item administrator_acting_as_customer: Model\AdministratorActingAsCustomer, which applies while Magento\LoginAsCustomerApi\Api\GetLoggedAsCustomerAdminIdInterface::execute() returns an administrator id above zero. |
The package registers no route, plugin, table, setting, ACL resource, cron job or command.
Versioning
The package follows Semantic Versioning. What changed in each version is in CHANGELOG.md.
Tests
Run from the Magento root.
- Integration: the platform's harness in
dev/tests/integration, one run at a time against its own database.cd dev/tests/integration && php -d memory_limit=4G ../../../vendor/bin/phpunit -c phpunit.xml ../../../app/code/Hryvinskyi/CustomerSignInLoginAsCustomer/Test/Integration. The tests use the test fixtures ofhryvinskyi/magento2-customer-sign-in-frontend, and also needhryvinskyi/magento2-customer-sign-inand the platform's Customer and Login as Customer modules. - Static analysis: PHPStan 2.x at level 10 with the package's
phpstan.neon.dist(phpstan analyse -c app/code/Hryvinskyi/CustomerSignInLoginAsCustomer/phpstan.neon.dist --level=10), andvendor/bin/phpcs --standard=app/code/Hryvinskyi/CustomerSignInLoginAsCustomer/phpcs.xml.dist app/code/Hryvinskyi/CustomerSignInLoginAsCustomer.