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


PHP Auth::login方法代码示例

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


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

示例1: handleProviderCallback

 public function handleProviderCallback()
 {
     //$user = Socialite::with('facebook')->user();
     //dd($user);
     try {
         $user = Socialite::with('facebook')->user();
     } catch (Exception $e) {
         return redirect('/login/facebook');
     }
     dd($user);
     $authUser = $this->findOrCreateUser($user);
     Auth::login($authUser, true);
     return redirect('/home');
     //        // OAuth Two Providers
     //        $token = $user->token;
     //
     //// OAuth One Providers
     //        $token = $user->token;
     //        $tokenSecret = $user->tokenSecret;
     //
     //// All Providers
     //        $user->getId();
     //        $user->getNickname();
     //        $user->getName();
     //        $user->getEmail();
     //        $user->getAvatar();
     //
 }
开发者ID:yoannamiteva,项目名称:it_talents,代码行数:28,代码来源:AuthController.php

示例2: __construct

 /**
  * Create a new authentication controller instance.
  *
  * @return void
  */
 public function __construct()
 {
     //        http://fallout.dev/home?autologin
     $user = User::where('email', 'test@example.com')->get();
     if (!empty($user[0])) {
         \Auth::login($user[0]);
     }
     $this->middleware('guest', ['except' => 'getLogout']);
 }
开发者ID:Ravaelles,项目名称:Elder,代码行数:14,代码来源:AuthController.php

示例3: getFacebookCallback

 public function getFacebookCallback()
 {
     $user = \Socialize::with('facebook')->user();
     // All Providers
     $user->provider = "facebook";
     $user = User::findByUserNameOrCreate($user);
     \Auth::login($user);
     return redirect()->intended('home');
 }
开发者ID:resourcemode,项目名称:LaravelRatchetChat,代码行数:9,代码来源:AuthController.php

示例4: providerLogin

 public function providerLogin($provider)
 {
     // ユーザー情報取得
     $userData = \Socialite::with($provider)->user();
     // ユーザー作成
     $user = App\Models\User::firstOrCreate(['name' => $userData->nickname, 'email' => $userData->email, 'avatar' => $userData->avatar]);
     \Auth::login($user);
     return redirect('/');
 }
开发者ID:kotamat,项目名称:laravel-plugins,代码行数:9,代码来源:AuthController.php

示例5: postRegister

 /**
  * Handle a registration request for the application.
  *
  * @param  \Illuminate\Http\Request $request
  * @return \Illuminate\Http\Response
  */
 public function postRegister(Request $request)
 {
     $validator = $this->validator($request->all());
     if ($validator->fails()) {
         $this->throwValidationException($request, $validator);
     }
     \Auth::login($this->create($request->all()));
     flash()->success('Register successful');
     return redirect($this->redirectPath());
 }
开发者ID:psiskova,项目名称:blog-academy,代码行数:16,代码来源:AuthController.php

示例6: postRegister

 public function postRegister(Request $request)
 {
     $validator = $this->validator($request->all());
     if ($validator->fails()) {
         $this->throwValidationException($request, $validator);
     }
     $user = $this->create($request->all());
     \Auth::login($user);
     return ['key' => $user->key->key, 'admin' => $user->admin == '1' ? true : false];
 }
开发者ID:Tweety-FER,项目名称:guestlist,代码行数:10,代码来源:AuthController.php

示例7: postRegister

 public function postRegister(Request $request)
 {
     $validator = $this->validator($request->all());
     if ($validator->fails()) {
         $request->session()->flash('loginTab', 'register');
         $this->throwValidationException($request, $validator);
     }
     \Auth::login($this->create($request->all()));
     return redirect($this->redirectPath());
 }
开发者ID:RenzoCCH,项目名称:base6094275,代码行数:10,代码来源:AuthController.php

示例8: handleProviderCallback

 /**
  * Obtain the user information from GitHub.
  *
  * @return Response
  */
 public function handleProviderCallback()
 {
     /*
     Sample of what LinkedIn returns
     ---------------------
     User {#149 ▼
       +token: "AQUmcn8FTAYmj_-IkAPzcqCxhZRNR-woIX9-fH4JEvCzb7xICTy2uY3JXXiq1co8MFUxxiBsk3IJIeE2kTlH5mP6fRtBnQConCaX2F2BB6fOtbswLmcSio8M1lEo67Nrt7yXbjJueAlz4wPt4T5knXZjV95uPcP0q2XEQG5Jw0zRUhNLcKY"
       +id: "nZmvBPf-nh"
       +nickname: null
       +name: "Ben Allfree"
       +email: "ben@benallfree.com"
       +avatar: "https://media.licdn.com/mpr/mprx/0_NFyu8TZPvM4g9_tqnbS18GglvUyPN_tqn5e18GxTEZe_wF5N43u8aCI7U1puckP4vXYt75Tc0GEr"
       +"user": array:11 [▼
         "emailAddress" => "ben@benallfree.com"
         "firstName" => "Ben"
         "formattedName" => "Ben Allfree"
         "headline" => "I turn ideas into working software."
         "id" => "nZmvBPf-nh"
         "industry" => "Computer Software"
         "lastName" => "Allfree"
         "location" => array:2 [▼
           "country" => array:1 [▼
             "code" => "us"
           ]
           "name" => "Reno, Nevada Area"
         ]
         "pictureUrl" => "https://media.licdn.com/mpr/mprx/0_NFyu8TZPvM4g9_tqnbS18GglvUyPN_tqn5e18GxTEZe_wF5N43u8aCI7U1puckP4vXYt75Tc0GEr"
         "pictureUrls" => array:2 [▼
           "_total" => 1
           "values" => array:1 [▼
             0 => "https://media.licdn.com/mpr/mprx/0_Y7yIKlXzoK8T6SZtx7PLnrvBolli3aZtxmGQnKEMXzr86fopjxjFqnbjkJ-"
           ]
         ]
         "publicProfileUrl" => "https://www.linkedin.com/in/benallfree"
       ]
       +"avatar_original": "https://media.licdn.com/mpr/mprx/0_Y7yIKlXzoK8T6SZtx7PLnrvBolli3aZtxmGQnKEMXzr86fopjxjFqnbjkJ-"
     }      
     */
     $data = Socialite::driver('linkedin')->user();
     $user = User::whereLinkedinId($data->id)->first();
     if (!$user) {
         $user = new User();
         $user->linkedin_id = $data->id;
     }
     $user->email = $data->email;
     $user->firstname = $data->user['firstName'];
     $user->lastname = $data->user['lastName'];
     $user->country = $data->user['location']['country']['code'];
     $user->location = $data->user['location']['name'];
     $user->tagline = $data->user['headline'];
     $user->avatar_url = $data->avatar_original;
     $user->save();
     \Auth::login($user);
     return redirect()->route('home')->with('success', "Welcome back, {$user->firstname}");
 }
开发者ID:john-shipp,项目名称:builtbyfreelancers,代码行数:60,代码来源:AuthController.php

示例9: postRegister

 /**
  * Handle a registration request for the application.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function postRegister(Request $request)
 {
     $validator = $this->validator($request->all());
     if ($validator->fails()) {
         $this->throwValidationException($request, $validator);
     }
     \Auth::login($this->create($request->all()));
     // save the hashtag terms stored in the global session to the database
     $this->saveStoredHashtags();
     return redirect($this->redirectPath());
 }
开发者ID:jasonjyu,项目名称:cscie15-p4,代码行数:17,代码来源:AuthController.php

示例10: handleProviderCallback

 /**
  * Obtain the user information from GitHub.
  *
  * @return Response
  */
 public function handleProviderCallback()
 {
     try {
         $user = Socialite::driver('facebook')->user();
     } catch (Exception $e) {
         return \Redirect::to('auth/facebook');
     }
     $authUser = $this->findOrCreateUser($user);
     \Auth::login($authUser, true);
     return \Redirect::to('/');
 }
开发者ID:xnum,项目名称:Calorie-Recorder,代码行数:16,代码来源:AuthController.php

示例11: getSocialAuthCallback

 public function getSocialAuthCallback($provider = null)
 {
     try {
         $user = $this->socialite->with($provider)->user();
     } catch (Exception $e) {
         return redirect(null, 404);
     }
     $authUser = $this->findOrCreateUser($user);
     \Auth::login($authUser, true);
     return redirect()->route('home');
     //TODO : redirect to error page
 }
开发者ID:Koroeskohr,项目名称:bdi,代码行数:12,代码来源:AuthController.php

示例12: getSocialAuthCallback

 public function getSocialAuthCallback($provider = null)
 {
     if ($user = $this->socialite->with($provider)->user()) {
         $authUser = $this->findOrCreateUser($user, $provider);
         // Log in
         \Auth::login($authUser, true);
         // Return
         return \Redirect::intended();
     } else {
         return 'something went wrong';
     }
 }
开发者ID:NineWorldsKindred,项目名称:site,代码行数:12,代码来源:AuthController.php

示例13: postRegister

 /**
  * Overriding from E:\Wamp\wamp\www\tagoal\vendor\laravel\framework\src\Illuminate\Foundation\Auth\RegistersUsers
  */
 public function postRegister(Request $request, AppMailer $mailer)
 {
     $validator = $this->validator($request->all());
     if ($validator->fails()) {
         $this->throwValidationException($request, $validator);
     }
     // $user = $this->create($request->all());
     // $mailer -> sendEmailConfirmationTo($user);
     // return 1;
     \Auth::login($this->create($request->all()));
     return redirect($this->redirectPath());
 }
开发者ID:NaiqiWang,项目名称:FirstLaravelProject,代码行数:15,代码来源:AuthController.php

示例14: postRegister

 /**
  * Handle a registration request for the application.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function postRegister(Request $request)
 {
     try {
         $validator = $this->validator($request->all());
         if ($validator->fails()) {
             $this->throwValidationException($request, $validator);
         }
         \Auth::login($this->create($request->all()));
         return redirect($this->redirectPath());
     } catch (FailedPasswordValidationException $e) {
         dd($e);
     }
 }
开发者ID:RCAbney,项目名称:L5-Doctrine-Base,代码行数:19,代码来源:AuthController.php

示例15: postRegister

 /**
  * Handle a registration request for the application.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function postRegister(Request $request)
 {
     $fields = $request->only(['name', 'email', 'country', 'password', 'password_confirmation']);
     $validator = $this->validator($fields);
     if ($validator->fails()) {
         return \Response::json(['success' => false, 'errors' => $validator->errors()]);
     }
     $user = $this->create($request->all());
     \Auth::login($user);
     if (!$request->ajax()) {
         return redirect($this->redirectPath())->with(['message' => "You're finally registered, {$user->name}"]);
     }
     return \Response::json(['success' => true]);
 }
开发者ID:asvae,项目名称:Snippets,代码行数:20,代码来源:AuthController.php


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