当前位置: 首页>>代码示例>>PHP>>正文


PHP Application::redirect方法代码示例

本文整理汇总了PHP中Pagekit\Application::redirect方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::redirect方法的具体用法?PHP Application::redirect怎么用?PHP Application::redirect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Pagekit\Application的用法示例。


在下文中一共展示了Application::redirect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: loginAction

 /**
  * @Route("/admin/login", defaults={"_maintenance"=true})
  * @Request({"redirect": "string", "message": "string"})
  */
 public function loginAction($redirect = '', $message = '')
 {
     if (App::user()->isAuthenticated()) {
         return App::redirect('@system');
     }
     return ['$view' => ['title' => __('Login'), 'name' => 'system/theme:views/login.php', 'layout' => false], 'last_username' => App::session()->get(Auth::LAST_USERNAME), 'redirect' => $redirect ?: App::url('@system'), 'message' => $message];
 }
开发者ID:pagekit,项目名称:pagekit,代码行数:11,代码来源:AdminController.php

示例2: indexAction

 /**
  * @Route("site/page", name="page")
  * @Access("site: manage site", admin=true)
  */
 public function indexAction()
 {
     if ($test = Node::fixOrphanedNodes()) {
         return App::redirect('@site/page');
     }
     return ['$view' => ['title' => __('Pages'), 'name' => 'system/site/admin/index.php'], '$data' => ['config' => ['menus' => App::menu()->getPositions()], 'types' => array_values($this->site->getTypes())]];
 }
开发者ID:nstaeger,项目名称:pagekit,代码行数:11,代码来源:NodeController.php

示例3: authenticateAction

 /**
  * @Route(methods="POST", defaults={"_maintenance" = true})
  * @Request({"credentials": "array", "remember_me": "boolean", "redirect": "string"})
  */
 public function authenticateAction($credentials, $remember = false, $redirect = '')
 {
     try {
         if (!App::csrf()->validate()) {
             throw new CsrfException(__('Invalid token. Please try again.'));
         }
         App::auth()->authorize($user = App::auth()->authenticate($credentials, false));
         if (($event = App::auth()->login($user, $remember)) && $event->hasResponse()) {
             return $event->getResponse();
         }
         if (App::request()->isXmlHttpRequest()) {
             return App::response()->json(['csrf' => App::csrf()->generate()]);
         } else {
             return App::redirect(preg_replace('#(https?:)?//[^/]+#', '', $redirect));
         }
     } catch (CsrfException $e) {
         if (App::request()->isXmlHttpRequest()) {
             return App::response()->json(['csrf' => App::csrf()->generate()], 401);
         }
         $error = $e->getMessage();
     } catch (BadCredentialsException $e) {
         $error = __('Invalid username or password.');
     } catch (AuthException $e) {
         $error = $e->getMessage();
     }
     if (App::request()->isXmlHttpRequest()) {
         App::abort(401, $error);
     } else {
         App::message()->error($error);
         return App::redirect(preg_replace('#(https?:)?//[^/]+#', '', App::url()->previous()));
     }
 }
开发者ID:nstaeger,项目名称:pagekit,代码行数:36,代码来源:AuthController.php

示例4: confirmAction

 /**
  * @Request({"user", "key"})
  */
 public function confirmAction($username = "", $activation = "")
 {
     if (empty($username) || empty($activation) || !($user = User::where(compact('username', 'activation'))->first())) {
         return $this->messageView(__('Invalid key.'), $success = false);
     }
     if ($user->isBlocked()) {
         return $this->messageView(__('Your account has not been activated or is blocked.'), $success = false);
     }
     $error = '';
     if ('POST' === App::request()->getMethod()) {
         try {
             if (!App::csrf()->validate()) {
                 throw new Exception(__('Invalid token. Please try again.'));
             }
             $password = App::request()->request->get('password');
             if (empty($password)) {
                 throw new Exception(__('Enter password.'));
             }
             if ($password != trim($password)) {
                 throw new Exception(__('Invalid password.'));
             }
             $user->password = App::get('auth.password')->hash($password);
             $user->activation = null;
             $user->save();
             App::message()->success(__('Your password has been reset.'));
             return App::redirect('@user/login');
         } catch (Exception $e) {
             $error = $e->getMessage();
         }
     }
     return ['$view' => ['title' => __('Reset Confirm'), 'name' => 'system/user/reset-confirm.php'], 'username' => $username, 'activation' => $activation, 'error' => $error];
 }
开发者ID:nstaeger,项目名称:pagekit,代码行数:35,代码来源:ResetPasswordController.php

示例5: loginAction

 /**
  * @Route("/admin/login", defaults={"_maintenance"=true})
  */
 public function loginAction()
 {
     if (App::user()->isAuthenticated()) {
         return App::redirect('@system');
     }
     return ['$view' => ['title' => __('Login'), 'name' => 'system/theme:views/login.php', 'layout' => false], 'last_username' => App::session()->get(Auth::LAST_USERNAME), 'redirect' => App::request()->get('redirect') ?: App::url('@system', [], true), 'remember_me_param' => Auth::REMEMBER_ME_PARAM];
 }
开发者ID:LibraryOfLawrence,项目名称:pagekit,代码行数:10,代码来源:AdminController.php

示例6: categoriesAction

 /**
  * @Route("categories", name="admin/categories")
  * @Access("download: manage categories")
  */
 public function categoriesAction()
 {
     if ($test = Category::fixOrphanedCategories()) {
         return App::redirect('@download/categories');
     }
     return ['$view' => ['title' => __('Categories'), 'name' => 'bixie/download/admin/categories.php'], '$data' => []];
 }
开发者ID:Bixie,项目名称:pagekit-download,代码行数:11,代码来源:DownloadController.php

示例7: authenticateAction

 /**
  * @Route(methods="POST", defaults={"_maintenance" = true})
  * @Request({"credentials": "array", "_remember_me": "boolean"})
  */
 public function authenticateAction($credentials, $remember = false)
 {
     $isXml = App::request()->isXmlHttpRequest();
     try {
         if (!App::csrf()->validate()) {
             throw new AuthException(__('Invalid token. Please try again.'));
         }
         App::auth()->authorize($user = App::auth()->authenticate($credentials, false));
         if (!$isXml) {
             return App::auth()->login($user, $remember);
         } else {
             App::auth()->setUser($user, $remember);
             return ['success' => true];
         }
     } catch (BadCredentialsException $e) {
         $error = __('Invalid username or password.');
     } catch (AuthException $e) {
         $error = $e->getMessage();
     }
     if (!$isXml) {
         App::message()->error($error);
         return App::redirect(App::url()->previous());
     } else {
         App::abort(400, $error);
     }
 }
开发者ID:aqnouch,项目名称:rimbo,代码行数:30,代码来源:AuthController.php

示例8: indexAction

 public function indexAction()
 {
     $user = App::user();
     if (!$user->isAuthenticated()) {
         return App::redirect('@user/login', ['redirect' => App::url()->current()]);
     }
     return ['$view' => ['title' => __('Your Profile'), 'name' => 'system/user/profile.php'], '$data' => ['user' => ['name' => $user->name, 'email' => $user->email]]];
 }
开发者ID:LibraryOfLawrence,项目名称:pagekit,代码行数:8,代码来源:ProfileController.php

示例9: registrationAction

 /**
  * registration override page
  * @Route("/registration")
  */
 public function registrationAction()
 {
     $user = App::user();
     $userprofile = App::module('bixie/userprofile');
     if ($user->isAuthenticated()) {
         return App::redirect('@userprofile');
     }
     return ['$view' => ['title' => __('User registration'), 'name' => 'bixie/userprofile/registration.php'], '$data' => ['config' => $userprofile->config(), 'user' => ['id' => null, 'username' => '', 'name' => '', 'email' => '']]];
 }
开发者ID:Bixie,项目名称:pagekit-userprofile,代码行数:13,代码来源:ProfileController.php

示例10: migrateAction

 /**
  * @Request({"redirect": "string"}, csrf=true)
  */
 public function migrateAction($redirect = null)
 {
     if ($updates = $this->scripts->hasUpdates()) {
         $this->scripts->update();
         $message = __('Your Pagekit database has been updated successfully.');
     } else {
         $message = __('Your database is up to date.');
     }
     App::config('system')->set('version', App::version());
     if ($redirect) {
         App::message()->success($message);
         return App::redirect($redirect);
     }
     return App::response()->json(compact('status', 'message'));
 }
开发者ID:LibraryOfLawrence,项目名称:pagekit,代码行数:18,代码来源:MigrationController.php

示例11: authenticateAction

 /**
  * @Route(methods="POST", defaults={"_maintenance" = true})
  * @Request({"credentials": "array"})
  */
 public function authenticateAction($credentials)
 {
     try {
         if (!App::csrf()->validate()) {
             throw new AuthException(__('Invalid token. Please try again.'));
         }
         App::auth()->authorize($user = App::auth()->authenticate($credentials, false));
         return App::auth()->login($user, App::request()->get(Auth::REMEMBER_ME_PARAM));
     } catch (BadCredentialsException $e) {
         App::message()->error(__('Invalid username or password.'));
     } catch (AuthException $e) {
         App::message()->error($e->getMessage());
     }
     return App::redirect(App::url()->previous());
 }
开发者ID:LibraryOfLawrence,项目名称:pagekit,代码行数:19,代码来源:AuthController.php

示例12: migrateAction

 /**
  * @Request({"redirect": "string"}, csrf=true)
  */
 public function migrateAction($redirect = null)
 {
     $config = App::config('system');
     $manager = new PackageManager();
     $scripts = $manager->loadScripts(null, __DIR__ . '/../../scripts.php');
     if (isset($scripts['updates'])) {
         $updates = $manager->filterUpdates($scripts['updates'], $config->get('version'));
         $manager->execute($updates);
     }
     $config->set('version', App::version());
     $message = __('Your Pagekit database has been updated successfully.');
     if ($redirect) {
         App::message()->success($message);
         return App::redirect($redirect);
     }
     return App::response()->json(compact('status', 'message'));
 }
开发者ID:4nxiety,项目名称:pagekit,代码行数:20,代码来源:MigrationController.php

示例13: editAction

 /**
  * @Route("/project/edit", name="project/edit")
  * @Access("portfolio: manage portfolio")
  * @Request({"id": "int"})
  */
 public function editAction($id = 0)
 {
     try {
         if (!($project = Project::where(compact('id'))->first())) {
             if ($id) {
                 App::abort(404, __('Invalid project id.'));
             }
             $module = App::module('bixie/portfolio');
             $project = Project::create(['data' => [], 'tags' => [], 'date' => new \DateTime()]);
             $project->set('markdown', $module->config('markdown'));
         }
         return ['$view' => ['title' => $id ? __('Edit Project') : __('Add Project'), 'name' => 'bixie/portfolio/admin/project.php'], '$data' => ['config' => App::module('bixie/portfolio')->config(), 'project' => $project, 'tags' => Project::allTags()], 'project' => $project];
     } catch (\Exception $e) {
         App::message()->error($e->getMessage());
         return App::redirect('@portfolio/post');
     }
 }
开发者ID:4nxiety,项目名称:pagekit-portfolio,代码行数:22,代码来源:PortfolioController.php

示例14: editAction

 /**
  * @Route("/post/edit", name="post/edit")
  * @Access("blog: manage own posts || blog: manage all posts")
  * @Request({"id": "int"})
  */
 public function editAction($id = 0)
 {
     try {
         if (!($post = Post::where(compact('id'))->related('user')->first())) {
             if ($id) {
                 App::abort(404, __('Invalid post id.'));
             }
             $module = App::module('blog');
             $post = Post::create(['user_id' => App::user()->id, 'status' => Post::STATUS_DRAFT, 'date' => new \DateTime(), 'comment_status' => (bool) $module->config('posts.comments_enabled')]);
             $post->set('title', $module->config('posts.show_title'));
             $post->set('markdown', $module->config('posts.markdown_enabled'));
         }
         $user = App::user();
         if (!$user->hasAccess('blog: manage all posts') && $post->user_id !== $user->id) {
             App::abort(403, __('Insufficient User Rights.'));
         }
         $roles = App::db()->createQueryBuilder()->from('@system_role')->where(['id' => Role::ROLE_ADMINISTRATOR])->whereInSet('permissions', ['blog: manage all posts', 'blog: manage own posts'], false, 'OR')->execute('id')->fetchAll(\PDO::FETCH_COLUMN);
         $authors = App::db()->createQueryBuilder()->from('@system_user')->whereInSet('roles', $roles)->execute('id, username')->fetchAll();
         return ['$view' => ['title' => $id ? __('Edit Post') : __('Add Post'), 'name' => 'blog/admin/post-edit.php'], '$data' => ['post' => $post, 'statuses' => Post::getStatuses(), 'roles' => array_values(Role::findAll()), 'canEditAll' => $user->hasAccess('blog: manage all posts'), 'authors' => $authors], 'post' => $post];
     } catch (\Exception $e) {
         App::message()->error($e->getMessage());
         return App::redirect('@blog/post');
     }
 }
开发者ID:pagekit,项目名称:extension-blog,代码行数:29,代码来源:BlogController.php

示例15: activateAction

 /**
  * @Request({"user", "key"})
  */
 public function activateAction($username, $activation)
 {
     if (empty($username) || empty($activation) || !($user = User::where(['username' => $username, 'activation' => $activation, 'status' => User::STATUS_BLOCKED, 'access IS NULL'])->first())) {
         App::message()->error(__('Invalid key.'));
         return App::redirect();
     }
     if ($admin = $this->module->config('registration') == 'approval' and !$user->get('verified')) {
         $user->activation = App::get('auth.random')->generateString(32);
         $this->sendApproveMail($user);
         App::message()->success(__('Your email has been verified. Once an administrator approves your account, you will be notified by email.'));
     } else {
         $user->set('verified', true);
         $user->status = User::STATUS_ACTIVE;
         $user->activation = '';
         $this->sendWelcomeEmail($user);
         if ($admin) {
             App::message()->success(__('The user\'s account has been activated and the user has been notified about it.'));
         } else {
             App::message()->success(__('Your account has been activated.'));
         }
     }
     $user->save();
     return App::redirect('@user/login');
 }
开发者ID:4nxiety,项目名称:pagekit,代码行数:27,代码来源:RegistrationController.php


注:本文中的Pagekit\Application::redirect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。