/** * Execute the controller. * * @return mixed Return executed result. * * @throws \LogicException * @throws \RuntimeException */ public function execute() { if (UserHelper::isLogin()) { Ioc::getApplication()->redirect(Router::build('admin:dashboard')); } $model = new LoginModel(); $session = Ioc::getSession(); $user = $this->input->getVar('user'); $result = $model->login($user['username'], $user['password']); $package = $this->getPackage(); $redirect = $session->get('login.redirect.url'); if ($result) { $url = $redirect ? base64_decode($redirect) : $package->get('redirect.login'); $msg = Language::translate('Login Success'); } else { $router = Ioc::getRouter(); $url = $router->build($this->package->getRoutingPrefix() . ':login'); $msg = Language::translate('Login Fail'); } $uri = new Uri($url); if (!$uri->getScheme()) { $url = $this->app->get('uri.base.full') . $url; } $session->remove('login.redirect.url'); $this->setRedirect($url, $msg); return true; }
/** * Execute the controller. * * @return mixed Return executed result. * * @throws \LogicException * @throws \RuntimeException */ public function execute() { if (UserHelper::isLogin()) { Ioc::getApplication()->redirect(Router::build('admin:dashboard')); } $model = new LoginModel(); $view = new LoginHtmlView(); $view['form'] = $model->getForm(); return $view->render(); }
/** * Execute the controller. * * @return mixed Return executed result. * * @throws \LogicException * @throws \RuntimeException */ public function execute() { $model = new LoginModel(); $user = User::get(); if ($user->isNull()) { $this->setRedirect('login', 'Already logout', 'success'); } $model->logout($user->username); // Session $session = Ioc::getSession(); $session->remove('current.blog'); $this->setRedirect(Router::buildHttp('front:home'), 'Logout success', 'success'); return true; }