koel/app/Http/Controllers/SSO/GoogleCallbackController.php

24 lines
668 B
PHP
Raw Normal View History

2024-03-30 16:49:25 +00:00
<?php
namespace App\Http\Controllers\SSO;
use App\Facades\License;
use App\Http\Controllers\Controller;
use App\Services\AuthenticationService;
use App\Services\UserService;
use App\Values\SSOUser;
2024-03-30 16:49:25 +00:00
use Laravel\Socialite\Facades\Socialite;
class GoogleCallbackController extends Controller
{
public function __invoke(AuthenticationService $auth, UserService $userService)
{
assert(License::isPlus());
$user = Socialite::driver('google')->user();
$user = $userService->createOrUpdateUserFromSSO(SSOUser::fromSocialite($user, 'Google'));
2024-03-30 16:49:25 +00:00
return view('sso-callback')->with('token', $auth->logUserIn($user)->toArray());
}
}