我正在尝试允许用户使用 facebook 登录,但我的用户管理基于哨兵,因为您知道如果您从 facebook 连接,除非您正常创建帐户,否则您不需要密码。有没有办法告诉哨兵(http://docs.cartalyst.com/sentry-2/installation/laravel-4)这是一个facebook登录,它不需要“密码”
我尝试为该帐户提供临时密码,但我收到未为用户提供散列器,即使我对其进行散列也是如此。
对此有何建议?
我还使用http://maxoffsky.com/code-blog/integrating-facebook-login-into-laravel-application/作为指南
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');
});