當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Auth::guest方法代碼示例

本文整理匯總了PHP中Auth::guest方法的典型用法代碼示例。如果您正苦於以下問題:PHP Auth::guest方法的具體用法?PHP Auth::guest怎麽用?PHP Auth::guest使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Auth的用法示例。


在下文中一共展示了Auth::guest方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getLogin

 public function getLogin()
 {
     if (!Auth::guest()) {
         return Redirect::action('HomeController@getIndex');
     }
     try {
         # Change 'localhost' to your domain name.
         $openid = new LightOpenID($_SERVER['HTTP_HOST']);
         if (!$openid->mode) {
             $openid->identity = 'http://steamcommunity.com/openid';
             return Redirect::to($openid->authUrl());
         } elseif ($openid->mode == 'cancel') {
             echo 'User has canceled authentication!';
         } else {
             if ($openid->validate()) {
                 $id = $openid->identity;
                 // identity is something like: http://steamcommunity.com/openid/id/76561197994761333
                 // we only care about the unique account ID at the end of the URL.
                 $ptn = "/^http:\\/\\/steamcommunity\\.com\\/openid\\/id\\/(7[0-9]{15,25}+)\$/";
                 preg_match($ptn, $id, $matches);
                 $steamid = $matches[1];
                 $this->fetch_username($steamid);
                 $this->fetch_backpack($steamid);
                 Auth::loginUsingId($steamid, true);
                 return Redirect::action('HomeController@getIndex');
             } else {
                 echo "User is not logged in.\n";
             }
         }
     } catch (ErrorException $e) {
         echo $e->getMessage();
     }
 }
開發者ID:TsunamiNori,項目名稱:Raffles,代碼行數:33,代碼來源:SteamLoginController.php

示例2: getIndex

 public function getIndex()
 {
     if (Auth::guest() || Auth::user()->isAdmin == 0) {
         return Redirect::secure('/');
     }
     // layouts variables
     $this->layout->title = 'Админ панел | Нещо Шантаво';
     $this->layout->canonical = 'https://neshto.shantavo.com/admin/';
     $this->layout->robots = 'noindex,nofollow,noodp,noydir';
     $users = count(User::all());
     $admins = count(User::where('isAdmin', ">", 0)->get());
     $categories = count(Category::all());
     $albums = count(Album::all());
     $votes = count(DB::table('votes')->get());
     $pictures = count(Picture::all());
     $pictureSize = 0;
     foreach (Picture::all() as $p) {
         $pictureSize += $p->size;
     }
     // get disqus stats
     include app_path() . '/config/_disqus.php';
     $disqus = new DisqusAPI(getDisqusKey());
     $disqus->setSecure(false);
     $comments = $disqus->posts->list(array('forum' => 'shantavo'));
     // nesting the view into the layout
     $this->layout->nest('content', 'admin.index', array('users' => $users, 'admins' => $admins, 'votes' => $votes, 'categories' => $categories, 'albums' => $albums, 'pictures' => $pictures, 'pictureSize' => $pictureSize, 'comments' => $comments));
 }
開發者ID:straho99,項目名稱:NeshtoShantavo,代碼行數:27,代碼來源:AdminController.php

示例3: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!$request->is('login') && \Auth::guest()) {
         return redirect()->action('LoginController@form');
     }
     return $next($request);
 }
開發者ID:rafaelschn,項目名稱:laravel5lab,代碼行數:14,代碼來源:Autorizador.php

示例4: get_index

 function get_index()
 {
     if (Auth::guest()) {
         return View::make('login');
     }
     return Redirect::to('admin');
 }
開發者ID:gischen,項目名稱:PHP-CMS,代碼行數:7,代碼來源:login.php

示例5: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string|null  $guard
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     if (Auth::guard($guard)->guest()) {
         if ($request->ajax()) {
             dd('Unauthorized');
             return response('Unauthorized.', 401);
         } else {
             session_start();
             if (isset($_SESSION['cart'])) {
                 if (\Request::all()) {
                     array_push($_SESSION['cart'], \Request::all());
                 }
             } else {
                 $_SESSION['cart'] = [];
                 array_push($_SESSION['cart'], \Request::all());
             }
             if (\Auth::guest()) {
                 \Session::flash('need_to_login_message', 'You need to log in');
             }
             // dd($_SESSION['cart']);
             return redirect()->guest('login');
         }
     }
     return $next($request);
 }
開發者ID:aleximillers,項目名稱:estore-laravel-angular,代碼行數:33,代碼來源:Authenticate.php

示例6: getLogin

 /**
  * Display the Login Page.
  *
  * @return Response
  */
 public function getLogin()
 {
     if (Auth::guest()) {
         return View::make('auth.login');
     }
     return Redirect::to('dashboard');
 }
開發者ID:nmkr,項目名稱:basic-starter,代碼行數:12,代碼來源:AuthController.php

示例7: create

 public function create()
 {
     $dc_name = Input::get('dc-name');
     $dc_desc = Input::get('dc-desc');
     $dc_donation_url = Input::get('dc-donation-url');
     $dc_instructions = Input::get('dc-instructions');
     if (Auth::guest()) {
         /////// Create User of type donationcause_adder
         $dcadder_first_name = Input::get('dcadder-first-name');
         $dcadder_last_name = Input::get('dcadder-last-name');
         $dcadder_mobile = Input::get('dcadder-mobile');
         $dcadder_obj = User::createDCAdderAndSave($dcadder_first_name, $dcadder_last_name, $dcadder_mobile);
         // =====[start]================================================
         // Manually logging in user and 'Remember me' = true.
         // So no need to use Auth::attempt
         Auth::login($dcadder_obj, true);
         // =====[end]================================================
     }
     if (Auth::guest()) {
         dd('why is there no Authenticated User here');
     }
     if (!Auth::user()->donationcause_adder) {
         Auth::user()->makeDonationCauseAdder();
     }
     // Storing the image
     $dc_img_file = Input::file('dc-img-file');
     DonationCause::createNewForPosterFromImgFile($dc_name, $dc_desc, $dc_img_file, $dc_donation_url, $dc_instructions, Auth::user()->id);
     return Redirect::route('donate');
 }
開發者ID:riddhi1212,項目名稱:Laravel-app-1,代碼行數:29,代碼來源:DonationCauseController.php

示例8: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!$request->is('auth/login') && \Auth::guest()) {
         return redirect('/auth/login');
     }
     return $next($request);
 }
開發者ID:antoniocsilva,項目名稱:estoque-linux,代碼行數:14,代碼來源:AutorizacaoMiddleware.php

示例9: index

 public function index()
 {
     if (!Auth::guest()) {
         return $this->redirectStatus();
     }
     return View::make('session.login');
 }
開發者ID:rizqon,項目名稱:ta,代碼行數:7,代碼來源:SessionController.php

示例10: addContributor

 public function addContributor()
 {
     $contributor_first_name = Input::get('contributor-first-name');
     $contributor_last_name = Input::get('contributor-last-name');
     $contributor_mobile = Input::get('contributor-mobile');
     $contributor_obj = NULL;
     if (Auth::guest()) {
         $contributor_obj = User::createContributorAndSave($contributor_first_name, $contributor_last_name, $contributor_mobile);
         Auth::login($contributor_obj, true);
     } else {
         // A user is logged in already. The contributor name and mobile can be same or different
         // ONLY checking by mobile right now. TODO : check if this is OK
         if ($contributor_mobile != Auth::user()->mobile) {
             Log::info("mobile num not equal. MAKE NEW CONTRIB USER !!");
             // Using same contributor twice. Or uses existing user as contributor without knowing that they exist on this platform
             $contributor_obj = User::createContributorIfNotExists($contributor_first_name, $contributor_last_name, $contributor_mobile);
         } else {
             Log::info("mobile num equal. Auth is Contributor !! ");
             $contributor_obj = Auth::user();
             $contributor_obj->makeContributor();
         }
     }
     $au_file = Input::file('au-file');
     $upload_number = Auth::user()->incrementUploadNumber();
     $new_file_name = $contributor_first_name . $contributor_mobile . '_uploaded_by_' . Auth::user()->fname . $upload_number . '.csv';
     $new_file_location = app_path() . '/database/seedAfterReview/';
     $au_file->move($new_file_location, $new_file_name);
     // I will review. No automatic upload
     //$file_full_path = $new_file_location . $new_file_name;
     //Helper::createArmyUpdatesFromFileForContributor($file_full_path, $contributor_obj->id);
     return Redirect::to('dashboard');
 }
開發者ID:riddhi1212,項目名稱:Laravel-app-1,代碼行數:32,代碼來源:ArmyUpdatesController.php

示例11: _isUnread

 private function _isUnread()
 {
     if (Auth::guest()) {
         return false;
     }
     $markAsReadAfter = value(Config::get('forums::forums.mark_as_read_after'));
     if (!IoC::registered('topicsview')) {
         IoC::singleton('topicsview', function () use($markAsReadAfter) {
             return Forumview::where('updated_at', '>=', date('Y-m-d H:i:s', $markAsReadAfter))->where('user_id', '=', Auth::user()->id)->lists('topic_id');
         });
     }
     $tv = IoC::resolve('topicsview');
     $nb = count($tv);
     $view = Forumtopic::where('forumcategory_id', '=', $this->id)->where('updated_at', '>=', date('Y-m-d H:i:s', $markAsReadAfter));
     if ($nb > 0) {
         $view = $view->where_not_in('id', $tv);
     }
     $view = $view->count();
     if ($nb == 0 && $view > 0) {
         return true;
     }
     if ($view > 0) {
         return true;
     }
     return false;
 }
開發者ID:marmaray,項目名稱:OLD-laravel-France-website,代碼行數:26,代碼來源:forumcategory.php

示例12: bootCreation

 /**
  * Boot the creation trait for a model.
  *
  * @return void
  */
 public static function bootCreation()
 {
     // create a event to happen on deleting
     static::deleting(function ($table) {
         if (class_exists('Cartalyst\\Sentinel\\Laravel\\Facades\\Sentinel')) {
             $table->deleted_by = Sentinel::getUser()->id;
         } else {
             $table->deleted_by = Auth::user()->id;
         }
         $table->update(['deleted_by' => $table->deleted_by]);
     });
     // create a event to happen on saving
     static::saving(function ($table) {
         if (class_exists('Cartalyst\\Sentinel\\Laravel\\Facades\\Sentinel')) {
             if (Sentinel::check()) {
                 $table->modified_by = Sentinel::getUser()->id;
             }
             if (Sentinel::check() && ($table->created_by == null || !($table->created_by > 0))) {
                 $table->created_by = Sentinel::getUser()->id;
             }
         } else {
             if (!Auth::guest()) {
                 $table->modified_by = Auth::user()->id;
             }
             if (!Auth::guest() && ($table->created_by == null || !($table->created_by > 0))) {
                 $table->created_by = Auth::user()->id;
             }
         }
     });
 }
開發者ID:joaogl,項目名稱:support,代碼行數:35,代碼來源:Creation.php

示例13: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     if (\Auth::guest()) {
         return redirect('auth/login');
     }
     return view('admin/register');
 }
開發者ID:viliguravlad,項目名稱:tokarevsg,代碼行數:12,代碼來源:RegisterController.php

示例14: handleNotFound

 public function handleNotFound()
 {
     if (\Auth::guest()) {
         return redirect('/auth/login');
     }
     return response(view('index')->render());
 }
開發者ID:ndrx-io,項目名稱:elude,代碼行數:7,代碼來源:Handler.php

示例15: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (\Auth::guest()) {
         return redirect('/login');
     }
     return $next($request);
 }
開發者ID:ProTrickster,項目名稱:Estoque-com-Laravel,代碼行數:14,代碼來源:AutorizacaoMiddleware.php


注:本文中的Auth::guest方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。