/** * Login action handler */ public function loginAction() { $contentBlock = \Magelight\Auth\Blocks\User\Login::forge(); $form = $contentBlock->getLoginForm(); if (!$form->isEmptyRequest() && $form->validate()) { /* @var $user \Magelight\Auth\Models\User */ if (!($user = \Magelight\Auth\Models\User::orm()->whereEq('email', $form->getFieldValue('email'))->whereEq('password', md5($form->getFieldValue('password')))->fetchModel())) { $form->addResult(__('Incorrect password or user with specified email is not registered')); } else { $this->session()->set('user_id', $user->id); $this->redirect($this->url(\Magelight\Config::getInstance()->getConfig('global/auth/urls/success_url'))); } } $this->view->sectionAppend('content', $contentBlock); $this->view->sectionReplace('login-user-main-form', $form); $this->renderView(); }