| @@ 11-34 (lines=24) @@ | ||
| 8 | use Socialite; |
|
| 9 | use App\Services\SocialFacebookAccountService; |
|
| 10 | ||
| 11 | class SocialAuthFacebookController extends Controller |
|
| 12 | { |
|
| 13 | /** |
|
| 14 | * Create a redirect method to twitter api. |
|
| 15 | * |
|
| 16 | * @return void |
|
| 17 | */ |
|
| 18 | public function redirect() |
|
| 19 | { |
|
| 20 | return Socialite::driver('facebook')->redirect(); |
|
| 21 | } |
|
| 22 | ||
| 23 | /** |
|
| 24 | * Return a callback method from twitter api. |
|
| 25 | * |
|
| 26 | * @return callback URL from twitter |
|
| 27 | */ |
|
| 28 | public function callback(SocialFacebookAccountService $service) |
|
| 29 | { |
|
| 30 | $user = $service->createOrGetUser(Socialite::driver('facebook')->user()); |
|
| 31 | auth()->login($user); |
|
| 32 | return redirect()->to('/home'); |
|
| 33 | } |
|
| 34 | } |
|
| 35 | ||
| @@ 11-34 (lines=24) @@ | ||
| 8 | use Socialite; |
|
| 9 | use App\Services\SocialTwitterAccountService; |
|
| 10 | ||
| 11 | class SocialAuthTwitterController extends Controller |
|
| 12 | { |
|
| 13 | /** |
|
| 14 | * Create a redirect method to twitter api. |
|
| 15 | * |
|
| 16 | * @return void |
|
| 17 | */ |
|
| 18 | public function redirect() |
|
| 19 | { |
|
| 20 | return Socialite::driver('twitter')->redirect(); |
|
| 21 | } |
|
| 22 | ||
| 23 | /** |
|
| 24 | * Return a callback method from twitter api. |
|
| 25 | * |
|
| 26 | * @return callback URL from twitter |
|
| 27 | */ |
|
| 28 | public function callback(SocialTwitterAccountService $service) |
|
| 29 | { |
|
| 30 | $user = $service->createOrGetUser(Socialite::driver('twitter')->user()); |
|
| 31 | auth()->login($user); |
|
| 32 | return redirect()->to('/home'); |
|
| 33 | } |
|
| 34 | } |
|
| 35 | ||