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


PHP ResponseFactory::redirectGuest方法代码示例

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


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

示例1: authorize

 /**
  * Authorize the page.
  *
  * @param PageInterface $page
  */
 public function authorize(PageInterface $page)
 {
     /* @var UserInterface $user */
     $user = $this->guard->user();
     /**
      * If the page is not enabled and we
      * are not logged in then 404.
      */
     if (!$page->isEnabled() && !$user) {
         abort(404);
     }
     /**
      * If the page is not enabled and we are
      * logged in then make sure we have permission.
      */
     if (!$page->isEnabled()) {
         $this->authorizer->authorize('anomaly.module.pages::view_drafts');
     }
     /**
      * If the page is restricted to specific
      * roles then make sure our user is one of them.
      */
     $allowed = $page->getAllowedRoles();
     if (!$allowed->isEmpty() && (!$user || !$user->hasAnyRole($allowed))) {
         $page->setResponse($this->response->redirectGuest($this->config->get('anomaly.module.users::paths.login', 'login')));
     }
 }
开发者ID:AkibaTech,项目名称:pages-module,代码行数:32,代码来源:PageAuthorizer.php

示例2: authorize

 /**
  * Authorize the page.
  *
  * @param PageInterface $page
  */
 public function authorize(PageInterface $page)
 {
     /* @var UserInterface $user */
     $user = $this->guard->user();
     /**
      * If the page is not enabled and we
      * are not logged in then 404.
      */
     if (!$page->isEnabled() && !$user) {
         abort(404);
     }
     /**
      * If the page is not enabled and we are
      * logged in then make sure we have permission.
      */
     if (!$page->isEnabled() && !$this->authorizer->authorize('anomaly.module.pages::view_drafts')) {
         abort(403);
     }
     /**
      * If the page is restricted to specific
      * roles then make sure our user is one of them.
      */
     $allowed = $page->getAllowedRoles();
     /**
      * If there is a guest role and
      * there IS a user then this
      * page can NOT display.
      */
     if ($allowed->has('guest') && $user && !$user->isAdmin()) {
         abort(403);
     }
     // No longer needed.
     $allowed->forget('guest');
     /**
      * Check the roles against the
      * user if there are any.
      */
     if (!$allowed->isEmpty() && (!$user || !$user->hasAnyRole($allowed) && !$user->isAdmin())) {
         $page->setResponse($this->response->redirectGuest('login'));
     }
 }
开发者ID:jacksun101,项目名称:pages-module,代码行数:46,代码来源:PageAuthorizer.php

示例3: redirectGuest

 /**
  * Create a new redirect response, while putting the current URL in the session.
  *
  * @param string $path
  * @param int $status
  * @param array $headers
  * @param bool|null $secure
  * @return \Illuminate\Http\RedirectResponse 
  * @static 
  */
 public static function redirectGuest($path, $status = 302, $headers = array(), $secure = null)
 {
     return \Illuminate\Routing\ResponseFactory::redirectGuest($path, $status, $headers, $secure);
 }
开发者ID:satriashp,项目名称:tour,代码行数:14,代码来源:_ide_helper.php


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