Вход в систему Facebook с помощью Sentry, для пользователя требуется пароль.

Я пытаюсь разрешить пользователям входить в систему с помощью 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'); 

});

Я смотрю на что-то подобное, и думал о том, как использовать facebook uid в качестве пароля. Не будет ли это работать?

Изменить: я могу подтвердить следующие работы для меня:

 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 ), чтобы указать связь с профилями

Я думаю, что когда вы создаете пользователя, вам нужно использовать Sentry :: createUser ()

 $user = Sentry::createUser(array( 'name' => $me['first_name'].' '.$me['last_name'], 'email' => $me['email'], 'password' => 'test', 'photo' => 'https://graph.facebook.com/'.$me['username'].'/picture?type=large', )); 

А затем используйте Sentry :: login ($ user, false); для принудительного входа для пользователя без пароля.

Вероятно, вы также хотите поместить что-то в поле пароля, кроме теста, если у вас также есть обычный вход в систему без facebook.

Кроме того, вам может потребоваться активировать пользователя в зависимости от ваших планов с этим электронным адресом:

 //You could email this to the user from here. $activationCode = $user->getActivationCode(); //OR just activate immediately. $user->attemptActivation($activationCode);