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


PHP Auth::login方法代码示例

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


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

示例1: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     //dd($request->name);
     $fb_user = FacebookUser::find($request->id);
     //Create FB User if not exists
     if (is_null($fb_user)) {
         $fb_user = new FacebookUser();
         $fb_user->id = $request->id;
         $fb_user->name = $request->name;
         $fb_user->email = $request->email;
         $fb_user->token = $request->access_token;
         $fb_user->save();
     }
     // if fb user found in accounts link, retrieve user and authenticate
     $link = $fb_user->user();
     if (!is_null($link)) {
         $user = User::find($link->id);
     } else {
         $user = User::where('email', '=', $fb_user->email)->first();
         if (is_null($user)) {
             // fb user not in accounts link, nor user table, so create a new account
             $user = new User();
             $user->first_name = $request->name;
             $user->email = $request->email;
             $user->save();
         }
         //Create an Account link fb <-> user
         $link = new AccountLink();
         $link->user_id = $user->id;
         $link->app_type_id = 2;
         // from table acount_types;
         $link->app_user_id = $fb_user->id;
         $link->save();
     }
     // Authenticate
     \Auth::login($user);
     // Go to  user's landing page
     return "/scores/" . $user->id . "/show";
     //return new RedirectResponse(route('scores.user.show', array($user->id)));
     //$user = User::find($user_id);
     //$user = Auth::loginUsingId($userID);
     //return new RedirectResponse(route('scores.user.show', array($user->id)));
     //$user = \Auth::login($user);
     //return new RedirectResponse(route('scores.user.show', array($user->id)));
     ////If player go to Player Profile page
     //if ($user->player_id > 0){
     //	return new RedirectResponse(action('PlayersJournalController@index', array($user->player_id)));
     //}elseif ($lastLogin->diff($today)->days > 7){
     //	/* Remind user to link their account to USAR */
     //	return new RedirectResponse(action('Users\UserInfoController@show_linkUsar', array($user->id)));
     //}else {
     //	return new RedirectResponse(url('/home'));
     //}
     //return $next($request);
 }
开发者ID:jenidarnold,项目名称:racquetball,代码行数:62,代码来源:AuthenticateWithFacebook.php

示例2: handle

 public function handle($request, Closure $next, $guard = null)
 {
     \App::setLocale(config('gtcmslang.defaultAdminLocale'));
     $showLoginMessage = true;
     if (config('gtcms.adminAutoLogin') && \Auth::guest()) {
         $user = User::where('role', 'admin')->first();
         \Auth::login($user);
         $showLoginMessage = false;
     }
     $allowedUserRoles = config('gtcms.allowedUserRoles');
     if (\Auth::guest() || !in_array(\Auth::user()->role, $allowedUserRoles)) {
         if (\Route::current()->uri() != "admin/login") {
             if (\Request::ajax() && \Request::get('getIgnore_isAjax')) {
                 $data = array('success' => false, 'message' => "Session timeout", 'redirectToLogin' => true);
                 return \Response::json($data);
             } else {
                 return \Redirect::to('/admin/login');
             }
         }
     } else {
         if (\Route::current()->uri() == "admin/login") {
             if ($showLoginMessage) {
                 MessageManager::setError(trans('gtcms.alreadyLoggedIn'));
             }
             return \Redirect::to("/admin");
         }
     }
     if (\Session::get('accessDenied')) {
         if (\Route::currentRouteName() != "restricted") {
             \Session::put('accessDenied', true);
             return \Redirect::to('/access-denied');
         }
     } else {
         if (\Route::currentRouteName() == "restricted") {
             MessageManager::setError(trans('gtcms.accessGranted'));
             \Session::put('accessDenied', false);
             return \Redirect::to("/admin");
         }
     }
     return $next($request);
 }
开发者ID:gtcrais,项目名称:gtcms,代码行数:41,代码来源:AdminAuth.php


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