/** * doExecute * * @return string */ protected function doExecute() { $view = new ProfileHtmlView($this->data); $model = new ProfileModel(); $session = Ioc::getSession(); $user = $session->get('profile.edit.data') ?: User::get(); $view['item'] = $user; $view['form'] = $model->getForm($user); return $view->setLayout('edit')->render(); }
/** * onUserAfterLogin * * @param Event $event * * @return void */ public function onUserAfterLogin(Event $event) { $options = $event['options']; $remember = $options['remember']; if ($remember) { $session = Ioc::getSession(); $uri = Ioc::get('uri'); setcookie(session_name(), $_COOKIE[session_name()], time() + 60 * 60 * 24 * 100, $session->getOption('cookie_path', $uri['base.path']), $session->getOption('cookie_domain')); } }
/** * 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 RegistrationModel(); $view = new RegistrationHtmlView(); $session = Ioc::getSession(); $view['item'] = $session['register.form.data'] ?: array(); $view['item'] = new Data($view['item']); 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; }
/** * Execute the controller. * * @return mixed Return executed result. * * @throws \LogicException * @throws \RuntimeException */ public function execute() { $id = $this->input->get('id'); $return = $this->input->get('return'); $return = $return ? base64_decode($return) : Router::build('admin:dashboard'); $user = User::get(); $blogModel = new BlogModel(); $blogModel['user.isAdmin'] = false; $blog = $blogModel->getCurrentBlog($user->id, $id); $session = Ioc::getSession(); if (!$blog->isNull()) { $session->set('current.blog', $blog->id); } $this->setRedirect($return); return true; }
/** * logout * * @param UserDataInterface|UserData $user * * @return bool */ public function logout(UserDataInterface $user) { $session = Ioc::getSession(); $session->remove('user'); return true; }