/** * Стартовая страница * * @param array &$Controller объект контроллера * * @return &array объект отображения */ function &indexAction(array &$Controller) { $View =& View\construct(); View\setTemplateName($View, 'customer\\index'); View\setVariables($View, ['ActiveUser' => ServiceManager\get(getServiceManager($Controller), 'ActiveUser')]); return $View; }
/** * Стартовая страница сервиса * * @param array &$Controller объект контроллера * * @return &array объект отображения */ function &indexAction(array &$Controller) { $Request =& getRequest($Controller); $errorMsg = ''; if (Request\isPost($Request)) { // Auth $login = Request\getPostParam($Request, 'login'); $password = Request\getPostParam($Request, 'password'); $loginAs = Request\getPostParam($Request, 'loginAs'); if ($loginAs !== 'customer' && $loginAs !== 'executor' || is_null($login) || is_null($password)) { $errorMsg = 'Неверные данные'; } else { $ServiceManager =& getServiceManager($Controller); if ($loginAs == 'customer') { // Заказчик $CustomerRepository =& ServiceManager\get($ServiceManager, 'CustomerRepository'); if (!CustomerRepository\validateAuth($CustomerRepository, $login, $password)) { $errorMsg = 'Неверный логин/пароль'; } else { ServiceManager\set($ServiceManager, 'ActiveUser', CustomerRepository\fetch($CustomerRepository, $login)); Session\setActiveUserData($login, 'customer'); header('Location: /customer', true, 307); exit; } } else { // Исполнитель $ExecutorRepository =& ServiceManager\get($ServiceManager, 'ExecutorRepository'); if (!ExecutorRepository\validateAuth($ExecutorRepository, $login, $password)) { $errorMsg = 'Неверный логин/пароль'; } else { ServiceManager\set($ServiceManager, 'ActiveUser', ExecutorRepository\fetch($ExecutorRepository, $login)); Session\setActiveUserData($login, 'executor'); header('Location: /executor', true, 307); exit; } } } } else { $loginAs = 'customer'; } $View =& View\construct(); View\setTemplateName($View, 'index\\index'); View\setVariables($View, ['errorMsg' => $errorMsg, 'loginAs' => $loginAs]); return $View; }