Facebook Login with Sentry, A password is required for user [email], none given

匿名 (未验证) 提交于 2019-12-03 01:10:02

问题:

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.

Any advice on this?

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');

});

回答1:

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

Edit: 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        
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!