X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/c429cf78187e80deb63982a282a1c6889f30291a..refs/pull/3850/head:/app/Http/Controllers/Auth/SocialController.php diff --git a/app/Http/Controllers/Auth/SocialController.php b/app/Http/Controllers/Auth/SocialController.php index 1d1468698..9ba4028ec 100644 --- a/app/Http/Controllers/Auth/SocialController.php +++ b/app/Http/Controllers/Auth/SocialController.php @@ -2,33 +2,36 @@ namespace BookStack\Http\Controllers\Auth; -use BookStack\Actions\ActivityType; +use BookStack\Auth\Access\LoginService; use BookStack\Auth\Access\RegistrationService; use BookStack\Auth\Access\SocialAuthService; use BookStack\Exceptions\SocialDriverNotConfigured; use BookStack\Exceptions\SocialSignInAccountNotUsed; use BookStack\Exceptions\SocialSignInException; use BookStack\Exceptions\UserRegistrationException; -use BookStack\Facades\Theme; use BookStack\Http\Controllers\Controller; -use BookStack\Theming\ThemeEvents; use Illuminate\Http\Request; use Illuminate\Support\Str; use Laravel\Socialite\Contracts\User as SocialUser; class SocialController extends Controller { - protected $socialAuthService; - protected $registrationService; + protected SocialAuthService $socialAuthService; + protected RegistrationService $registrationService; + protected LoginService $loginService; /** * SocialController constructor. */ - public function __construct(SocialAuthService $socialAuthService, RegistrationService $registrationService) - { - $this->middleware('guest')->only(['getRegister', 'postRegister']); + public function __construct( + SocialAuthService $socialAuthService, + RegistrationService $registrationService, + LoginService $loginService + ) { + $this->middleware('guest')->only(['register']); $this->socialAuthService = $socialAuthService; $this->registrationService = $registrationService; + $this->loginService = $loginService; } /** @@ -136,11 +139,8 @@ class SocialController extends Controller } $user = $this->registrationService->registerUser($userData, $socialAccount, $emailVerified); - auth()->login($user); - Theme::dispatch(ThemeEvents::AUTH_LOGIN, $socialDriver, $user); - $this->logActivity(ActivityType::AUTH_LOGIN, $user); - $this->showSuccessNotification(trans('auth.register_success')); + $this->loginService->login($user, $socialDriver); return redirect('/'); }