Skip to content

Instantly share code, notes, and snippets.

@jacobshenning
Created April 24, 2020 19:23
Show Gist options
  • Save jacobshenning/1cb5acf0b87407e00a28457e2a3b066f to your computer and use it in GitHub Desktop.
Save jacobshenning/1cb5acf0b87407e00a28457e2a3b066f to your computer and use it in GitHub Desktop.
A dynamic social auth system
<?php
namespace App\Http\Controllers\Frontend;
use App\Http\Controllers\Controller;
use App\Services\SocialAccountService;
use Laravel\Socialite\Facades\Socialite;
class SocialAuthController extends Controller
{
public function redirect($social)
{
return Socialite::driver($social)->redirect();
}
public function callback($social)
{
$user = SocialAccountService::createOrGetUser(Socialite::driver($social)->stateless()->user(), $social);
auth()->login($user);
return redirect()->to('/');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment