<bdo id='6DGyu'></bdo><ul id='6DGyu'></ul>
  • <tfoot id='6DGyu'></tfoot>

        <i id='6DGyu'><tr id='6DGyu'><dt id='6DGyu'><q id='6DGyu'><span id='6DGyu'><b id='6DGyu'><form id='6DGyu'><ins id='6DGyu'></ins><ul id='6DGyu'></ul><sub id='6DGyu'></sub></form><legend id='6DGyu'></legend><bdo id='6DGyu'><pre id='6DGyu'><center id='6DGyu'></center></pre></bdo></b><th id='6DGyu'></th></span></q></dt></tr></i><div id='6DGyu'><tfoot id='6DGyu'></tfoot><dl id='6DGyu'><fieldset id='6DGyu'></fieldset></dl></div>

        <small id='6DGyu'></small><noframes id='6DGyu'>

        <legend id='6DGyu'><style id='6DGyu'><dir id='6DGyu'><q id='6DGyu'></q></dir></style></legend>

        Facebook 使用 Sentry 登录,用户 [email] 需要密码,没有给出

        时间:2023-10-31
      1. <tfoot id='VLaYL'></tfoot>

        <small id='VLaYL'></small><noframes id='VLaYL'>

        <legend id='VLaYL'><style id='VLaYL'><dir id='VLaYL'><q id='VLaYL'></q></dir></style></legend>

            <bdo id='VLaYL'></bdo><ul id='VLaYL'></ul>
            <i id='VLaYL'><tr id='VLaYL'><dt id='VLaYL'><q id='VLaYL'><span id='VLaYL'><b id='VLaYL'><form id='VLaYL'><ins id='VLaYL'></ins><ul id='VLaYL'></ul><sub id='VLaYL'></sub></form><legend id='VLaYL'></legend><bdo id='VLaYL'><pre id='VLaYL'><center id='VLaYL'></center></pre></bdo></b><th id='VLaYL'></th></span></q></dt></tr></i><div id='VLaYL'><tfoot id='VLaYL'></tfoot><dl id='VLaYL'><fieldset id='VLaYL'></fieldset></dl></div>
                  <tbody id='VLaYL'></tbody>
                1. 本文介绍了Facebook 使用 Sentry 登录,用户 [email] 需要密码,没有给出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试允许用户使用 facebook 登录,但我的用户管理基于哨兵如您所知,如果您从 facebook 连接,除非您正常创建帐户,否则您不需要密码.有没有办法告诉哨兵(http://docs.cartalyst.com/sentry-2/installation/laravel-4)这是一个 facebook 登录,它不需要密码"

                  I'm trying to allow users to login using facebook but my user management is based on sentry as you know if you connect from facebook, you wont need a password unless you are creating a account normally. Is there a way to tell sentry(http://docs.cartalyst.com/sentry-2/installation/laravel-4) that this is a facebook login and it doesnt require a "password"

                  我尝试给帐户一个临时密码,但我收到了没有为用户提供散列器,即使我散列它.

                  I tried giving the account a temp password but i receive A hasher has not been provided for the user , even when i hash it.

                  对此有何建议?

                  我也在使用 http://maxoffsky.com/code-blog/integrating-facebook-login-into-laravel-application/ 作为指南

                  I'm also using http://maxoffsky.com/code-blog/integrating-facebook-login-into-laravel-application/ as a guide

                  Route::get('login/fb/callback', function() {
                  $code = Input::get('code');
                  if (strlen($code) == 0) return Redirect::to('/')->with('message', 'There was an error communicating with Facebook');
                  
                  $facebook = new Facebook(Config::get('facebook'));
                  $uid = $facebook->getUser();
                  
                  if ($uid == 0) return Redirect::to('/')->with('message', 'There was an error');
                  
                  $me = $facebook->api('/me');
                  
                  $profile = Profile::whereUid($uid)->first();
                  if (empty($profile)) {
                  
                      $user = new User;
                      $user->name = $me['first_name'].' '.$me['last_name'];
                      $user->email = $me['email'];
                      $user->photo = 'https://graph.facebook.com/'.$me['username'].'/picture?type=large';
                  
                      $user->save();
                  
                      $profile = new Profile();
                      $profile->uid = $uid;
                      $profile->username = $me['username'];
                      $profile = $user->profiles()->save($profile);
                  }
                  
                  $profile->access_token = $facebook->getAccessToken();
                  $profile->save();
                  
                  $user = $profile->user;
                  
                  Auth::login($user);
                  
                  return Redirect::to('/')->with('message', 'Logged in with Facebook');
                  

                  });

                  推荐答案

                  我正在考虑做类似的事情,并且正在考虑使用 facebook uid 作为密码.这不行吗?

                  I'm looking at doing something similar, and was thinking of using the facebook uid as the password. Would this not work?

                  我可以为我确认以下工作:

                  I can confirm the following works for me:

                  function callback()
                  {
                      $code = Input::get('code');
                      if (strlen($code) == 0) return Redirect::to('/')->with('message', 'There was an error communicating with Facebook');
                  
                      $facebook = new Facebook(Config::get('facebook'));
                      $uid = $facebook->getUser();
                  
                      if ($uid == 0) return Redirect::to('/')->with('message', 'There was an error');
                  
                      $me = $facebook->api('/me');
                      //dd($me);
                  
                      //Check if user profile exists
                      $profile = Profile::whereUid($uid)->first();
                      if (empty($profile)) {
                  
                          // Create the user
                          $user = Sentry::createUser(array(
                              'email'      => $me['email'],
                              'password'   => $uid,
                              'first_name' => $me['first_name'],
                              'last_name'  => $me['last_name'],
                              'photo'      =>  'https://graph.facebook.com/'.$me['username'].'/picture?type=large',
                              'activated'  => 1
                          ));
                  
                          // Find the group using the group id
                          $registered = Sentry::findGroupById(2);
                          // Assign the group to the user
                          $user->addGroup($registered);
                  
                          $profile = new Profile();
                          $profile->uid = $uid;
                          $profile->username = $me['username'];
                          $profile = $user->profiles()->save($profile);
                      }
                  
                      $profile->access_token = $facebook->getAccessToken();
                      $profile->save();
                  
                      $user = $profile->user;
                      Sentry::login($user, false);
                      $user = Sentry::getUser();
                  
                      echo $user->first_name . " logged in.";
                      //return Redirect::to('/')->with('message', 'Logged in with Facebook');
                  }
                  

                  另请注意,您需要使用此方法自定义哨兵使用的模型 (http://forums.laravel.io/viewtopic.php?pid=48274#p48274) 以指定与配置文件的关系

                  Also note that you'll need customize the model sentry uses using this method (http://forums.laravel.io/viewtopic.php?pid=48274#p48274) in order to specify the relationship with profiles

                  这篇关于Facebook 使用 Sentry 登录,用户 [email] 需要密码,没有给出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:无法通过 cron 作业使用自定义 Laravel Artisan 命令 下一篇:Laravel Ajax 调用控制器中的函数

                  相关文章

                2. <legend id='qBjFD'><style id='qBjFD'><dir id='qBjFD'><q id='qBjFD'></q></dir></style></legend>
                  1. <small id='qBjFD'></small><noframes id='qBjFD'>

                  2. <tfoot id='qBjFD'></tfoot>
                        <bdo id='qBjFD'></bdo><ul id='qBjFD'></ul>

                    1. <i id='qBjFD'><tr id='qBjFD'><dt id='qBjFD'><q id='qBjFD'><span id='qBjFD'><b id='qBjFD'><form id='qBjFD'><ins id='qBjFD'></ins><ul id='qBjFD'></ul><sub id='qBjFD'></sub></form><legend id='qBjFD'></legend><bdo id='qBjFD'><pre id='qBjFD'><center id='qBjFD'></center></pre></bdo></b><th id='qBjFD'></th></span></q></dt></tr></i><div id='qBjFD'><tfoot id='qBjFD'></tfoot><dl id='qBjFD'><fieldset id='qBjFD'></fieldset></dl></div>