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


PHP Auth::loginUsingId方法代码示例

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


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

示例1: handleFacebookCallback

 public function handleFacebookCallback()
 {
     //Since its the same callback function for registration & login. Check prev url and handle appropriately
     $prevUrl = session()->previousUrl();
     $facebookUser = Socialize::with('facebook')->user();
     $appUser = User::whereEmail($facebookUser->getEmail())->get();
     if (strpos($prevUrl, "register")) {
         //If user is not already registered, register and login
         if ($appUser->count() == 0) {
             $user = User::create(['name' => $facebookUser->getName(), 'email' => $facebookUser->getEmail(), 'password' => str_random(8)]);
             $user->verified = true;
             $user->token = null;
             $user->save();
             session()->flash('message', 'You are now registered. Please update your account details.');
             \Auth::loginUsingId($user->id);
             return redirect('/myAccount');
         } else {
             return redirect()->back()->withErrors('User already exists');
         }
     } else {
         if ($appUser->count() == 0) {
             return redirect()->back()->withErrors('User not found');
         }
         $user = $appUser[0];
     }
     \Auth::loginUsingId($user->id);
     return redirect()->intended('/dashboard');
 }
开发者ID:abada,项目名称:SettleUp-Laravel,代码行数:28,代码来源:RegistrationController.php

示例2: handleCallback

 public function handleCallback($driver, Request $req)
 {
     $socialuser = \Socialize::with($driver)->user();
     $user = User::where('email', $socialuser->email)->first();
     if (count($user) < 1) {
         $user = new User();
         $user->id = (string) Uuid::generate();
         $user->email = $socialuser->email;
         $user->name = $socialuser->name;
         $user->avatar = $socialuser->avatar;
         $user->save();
     }
     $user = \Auth::loginUsingId($user->id);
     $authcookie = \Cookie::queue('authenticated', true, 20, null, "www.thinkmerit.in", false, false);
     $username = \Cookie::queue('name', $user->name, 20, null, "www.thinkmerit.in", false, false);
     $avatar = \Cookie::queue('avatar', $user->avatar, 20, null, "www.thinkmerit.in", false, false);
     $email = \Cookie::queue('email', $user->email, 20, null, "www.thinkmerit.in", false, false);
     if (app()->environment() == "production") {
         return \Redirect::to("http://www.thinkmerit.in");
     } else {
         return \Redirect::to("http://www.dev.thinkmerit.in");
     }
     /* ->withCookie($authcookie)
        ->withCookie($username)
        ->withCookie($avatar)
        ->withCookie($email);*/
     // ;
 }
开发者ID:Dreamerpro,项目名称:thinkmerit.api,代码行数:28,代码来源:SocialController.php

示例3: manualregister

 public function manualregister(Request $request)
 {
     $validator = $this->validator($request->all());
     if ($validator->fails()) {
         $this->throwValidationException($request, $validator);
     }
     $arr = $request->all();
     $arr['id'] = (string) Uuid::generate();
     $arr['password'] = bcrypt($arr['password']);
     $user = new User($arr);
     $user->save();
     \Auth::loginUsingId($user->id);
     return Response::json(['msg' => 'Succsfully registered!'], 200);
 }
开发者ID:Dreamerpro,项目名称:thinkmerit.api,代码行数:14,代码来源:ManualAuthController.php

示例4: authajax

 public function authajax(Request $request)
 {
     $rules = array('email' => 'required|email', 'password' => 'required');
     $validator = \Validator::make($request->all(), $rules);
     if ($validator->fails()) {
         return Response::json(array('result' => false, 'data' => $validator->errors()->all()));
     }
     $email = $request->input('email');
     $password = $request->input('password');
     $member = Member::whereRaw('email = ? and password = ? ', [$email, md5($password)])->first();
     if ($member == null) {
         return Response::json(array('result' => false, 'data' => 'กรุณาลองใหม่อีกครั้ง.'));
     }
     $result = \Auth::loginUsingId($member->id);
     return Response::json(array('result' => true, 'data' => 'login success.'));
 }
开发者ID:snookerjirayut,项目名称:unotoon-member,代码行数:16,代码来源:AuthCustomController.php

示例5: oauthCallback

 public function oauthCallback(Request $request)
 {
     if ($request->get('state') == session('state')) {
         $auth = new Auth(config('wechat.appid'), config('wechat.secret'));
         $ouser = $auth->user();
         if (!$ouser) {
             abort('微信授权错误 #13101');
         }
         $sa = SocialAccount::where('openid', $ouser->get('openid'))->where('platform', 'wechat')->first();
         if ($sa) {
             \Auth::loginUsingId($ouser->user_id);
         } else {
             \DB::transaction(function () use($ouser, $auth) {
                 $user = User::create(['name' => $ouser->get('nickname', ''), 'username' => $ouser->get('platform') . '_' . $ouser->get('openid', ''), 'avatar' => $ouser->get('headimgurl')]);
                 SocialAccount::create(['user_id' => $user->id, 'access_token' => $auth->access_token, 'refresh_token' => $auth->refresh_token, 'platform' => 'wechat', 'openid' => $ouser->get('openid'), 'user_info' => json_encode($ouser), 'union_id' => $ouser->get('union_id', '')]);
                 \Auth::loginUsingId($user->id);
             });
         }
         return redirect(route('home'));
     } else {
         abort('403', '服务器授权state不正确');
     }
 }
开发者ID:xuetumaster,项目名称:tpartner,代码行数:23,代码来源:WechatController.php


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