- $driver = trim(strtolower($socialDriver));
-
- if (!in_array($driver, $this->validSocialDrivers)) {
- abort(404, trans('errors.social_driver_not_found'));
- }
-
- if (!$this->checkDriverConfigured($driver)) {
- throw new SocialDriverNotConfigured(trans('errors.social_driver_not_configured', ['socialAccount' => Str::title($socialDriver)]));
- }
-
- return $driver;
- }
-
- /**
- * Check a social driver has been configured correctly.
- */
- protected function checkDriverConfigured(string $driver): bool
- {
- $lowerName = strtolower($driver);
- $configPrefix = 'services.' . $lowerName . '.';
- $config = [config($configPrefix . 'client_id'), config($configPrefix . 'client_secret'), config('services.callback_url')];
-
- return !in_array(false, $config) && !in_array(null, $config);
- }
-
- /**
- * Gets the names of the active social drivers.
- * @returns array<string, string>
- */
- public function getActiveDrivers(): array
- {
- $activeDrivers = [];
-
- foreach ($this->validSocialDrivers as $driverKey) {
- if ($this->checkDriverConfigured($driverKey)) {
- $activeDrivers[$driverKey] = $this->getDriverName($driverKey);
- }
- }
-
- return $activeDrivers;
- }
-
- /**
- * Get the presentational name for a driver.
- */
- public function getDriverName(string $driver): string
- {
- return config('services.' . strtolower($driver) . '.name');
- }
-
- /**
- * Check if the current config for the given driver allows auto-registration.
- */
- public function driverAutoRegisterEnabled(string $driver): bool
- {
- return config('services.' . strtolower($driver) . '.auto_register') === true;
- }
-
- /**
- * Check if the current config for the given driver allow email address auto-confirmation.
- */
- public function driverAutoConfirmEmailEnabled(string $driver): bool
- {
- return config('services.' . strtolower($driver) . '.auto_confirm') === true;