Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace MageplazaHelloWorldControllerIndex;
- class Display extends MagentoFrameworkAppActionAction
- {
- protected $accountManagement;
- protected $session;
- public function __construct(
- MagentoFrameworkAppActionContext $context,
- MagentoCustomerModelAccountManagement $acm,
- MagentoCustomerModelSession $ses
- )
- {
- $this->accountManagement = $acm;
- $this->session = $ses;
- return parent::__construct($context);
- }
- public function execute()
- {
- //se la richiesta avviene in post
- if($_SERVER['REQUEST_METHOD'] == "POST") {
- //recupero i campi della richiesta
- $username = $_POST['username'];
- $password = $_POST['password'];
- //autentico l'utente
- try {
- $customer = $this->accountManagement->authenticate($username, $password);
- }
- catch(Exception $e) {
- echo "Credenziali errate";
- return;
- }
- //log in del cliente
- echo $customer->getId();
- $this->session->loginById($customer->getId());
- die;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement