Facebook, Google and Twitter SSO app credentials are now migrated to the new services section when running under v2.2.0-beta.2. Providers no longer appear on the login/register page unless they are enabled AND a service has been selected. Added a link to amend services in the settings section. closes #152
This commit is contained in:
parent
4dc4ce1517
commit
3655c28c73
@ -16,7 +16,7 @@ class ExternalService extends Model
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $fillable = ['name', 'service_type'];
|
protected $fillable = ['name', 'service_type', 'app_id', 'app_secret'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets all possible service configurations for the given service type.
|
* Gets all possible service configurations for the given service type.
|
||||||
|
@ -113,8 +113,8 @@ class ConfigHelper
|
|||||||
'date_format' => $this->allowedDateFormats()[0],
|
'date_format' => $this->allowedDateFormats()[0],
|
||||||
'default_album_view' => $this->allowedAlbumViews()[0],
|
'default_album_view' => $this->allowedAlbumViews()[0],
|
||||||
'enable_visitor_hits' => false,
|
'enable_visitor_hits' => false,
|
||||||
'facebook_external_service_id' => null,
|
'facebook_external_service_id' => 0,
|
||||||
'google_external_service_id' => null,
|
'google_external_service_id' => 0,
|
||||||
'hotlink_protection' => false,
|
'hotlink_protection' => false,
|
||||||
'items_per_page' => 12,
|
'items_per_page' => 12,
|
||||||
'items_per_page_admin' => 10,
|
'items_per_page_admin' => 10,
|
||||||
@ -149,7 +149,7 @@ class ConfigHelper
|
|||||||
'social_user_feeds' => false,
|
'social_user_feeds' => false,
|
||||||
'social_user_profiles' => false,
|
'social_user_profiles' => false,
|
||||||
'theme' => 'default',
|
'theme' => 'default',
|
||||||
'twitter_external_service_id' => null
|
'twitter_external_service_id' => 0
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,11 +216,29 @@ class ConfigHelper
|
|||||||
!empty($this->get('rabbitmq_vhost'));
|
!empty($this->get('rabbitmq_vhost'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isLoginWithFacebookEnabled()
|
||||||
|
{
|
||||||
|
return boolval($this->get('social_facebook_login')) &&
|
||||||
|
intval($this->get('facebook_external_service_id')) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isLoginWithGoogleEnabled()
|
||||||
|
{
|
||||||
|
return boolval($this->get('social_google_login')) &&
|
||||||
|
intval($this->get('google_external_service_id')) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isLoginWithTwitterEnabled()
|
||||||
|
{
|
||||||
|
return boolval($this->get('social_twitter_login')) &&
|
||||||
|
intval($this->get('twitter_external_service_id')) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
public function isSocialMediaLoginEnabled()
|
public function isSocialMediaLoginEnabled()
|
||||||
{
|
{
|
||||||
return $this->get('social_facebook_login') ||
|
return $this->isLoginWithFacebookEnabled() ||
|
||||||
$this->get('social_twitter_login') ||
|
$this->isLoginWithGoogleEnabled() ||
|
||||||
$this->get('social_google_login');
|
$this->isLoginWithTwitterEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function loadCache()
|
private function loadCache()
|
||||||
|
@ -69,7 +69,10 @@ class AppInstallation
|
|||||||
if ($isAppInstalled)
|
if ($isAppInstalled)
|
||||||
{
|
{
|
||||||
// See if an update is necessary
|
// See if an update is necessary
|
||||||
$this->updateDatabaseIfRequired();
|
if ($this->updateDatabaseIfRequired())
|
||||||
|
{
|
||||||
|
return redirect($request->fullUrl());
|
||||||
|
}
|
||||||
|
|
||||||
// App is configured, continue on
|
// App is configured, continue on
|
||||||
return $next($request);
|
return $next($request);
|
||||||
@ -152,6 +155,10 @@ class AppInstallation
|
|||||||
// Rebuild the permissions cache
|
// Rebuild the permissions cache
|
||||||
$helper = new PermissionsHelper();
|
$helper = new PermissionsHelper();
|
||||||
$helper->rebuildCache();
|
$helper->rebuildCache();
|
||||||
}
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
112
database/data_migrations/DataMigrationV2_2_0_beta_2.php
Normal file
112
database/data_migrations/DataMigrationV2_2_0_beta_2.php
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Configuration;
|
||||||
|
use App\DataMigration;
|
||||||
|
use App\ExternalService;
|
||||||
|
use App\Facade\UserConfig;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class DataMigrationV2_2_0_beta_2 extends DataMigration
|
||||||
|
{
|
||||||
|
public function getVersion()
|
||||||
|
{
|
||||||
|
return '2.2.0-beta.2';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function run($currentVersion)
|
||||||
|
{
|
||||||
|
DB::transaction(function()
|
||||||
|
{
|
||||||
|
$this->moveFacebookSettingsToService();
|
||||||
|
$this->moveGoogleSettingsToService();
|
||||||
|
$this->moveTwitterSettingsToService();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private function moveFacebookSettingsToService()
|
||||||
|
{
|
||||||
|
/** @var Configuration $facebookAppID */
|
||||||
|
$facebookAppID = Configuration::where(['key' => 'facebook_app_id'])->first();
|
||||||
|
|
||||||
|
/** @var Configuration $facebookAppID */
|
||||||
|
$facebookAppSecret = Configuration::where(['key' => 'facebook_app_secret'])->first();
|
||||||
|
|
||||||
|
if (is_null($facebookAppID) || is_null($facebookAppSecret))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$externalService = ExternalService::create([
|
||||||
|
'service_type' => ExternalService::FACEBOOK,
|
||||||
|
'name' => 'Facebook (migrated from settings)',
|
||||||
|
'app_id' => encrypt($facebookAppID->value), // app ID needs to be encrypted now
|
||||||
|
'app_secret' => $facebookAppSecret->value // secret is already encrypted
|
||||||
|
]);
|
||||||
|
|
||||||
|
/** @var ExternalService $facebookExternalServiceConfig */
|
||||||
|
$facebookExternalServiceConfig = UserConfig::getOrCreateModel('facebook_external_service_id');
|
||||||
|
$facebookExternalServiceConfig->value = $externalService->id;
|
||||||
|
$facebookExternalServiceConfig->save();
|
||||||
|
|
||||||
|
$facebookAppID->delete();
|
||||||
|
$facebookAppSecret->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function moveGoogleSettingsToService()
|
||||||
|
{
|
||||||
|
/** @var Configuration $googleAppID */
|
||||||
|
$googleAppID = Configuration::where(['key' => 'google_app_id'])->first();
|
||||||
|
|
||||||
|
/** @var Configuration $facebookAppID */
|
||||||
|
$googleAppSecret = Configuration::where(['key' => 'google_app_secret'])->first();
|
||||||
|
|
||||||
|
if (is_null($googleAppID) || is_null($googleAppSecret))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$externalService = ExternalService::create([
|
||||||
|
'service_type' => ExternalService::GOOGLE,
|
||||||
|
'name' => 'Google (migrated from settings)',
|
||||||
|
'app_id' => encrypt($googleAppID->value), // app ID needs to be encrypted now
|
||||||
|
'app_secret' => $googleAppSecret->value // secret is already encrypted
|
||||||
|
]);
|
||||||
|
|
||||||
|
/** @var ExternalService $googleExternalServiceConfig */
|
||||||
|
$googleExternalServiceConfig = UserConfig::getOrCreateModel('google_external_service_id');
|
||||||
|
$googleExternalServiceConfig->value = $externalService->id;
|
||||||
|
$googleExternalServiceConfig->save();
|
||||||
|
|
||||||
|
$googleAppID->delete();
|
||||||
|
$googleAppSecret->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function moveTwitterSettingsToService()
|
||||||
|
{
|
||||||
|
/** @var Configuration $twitterAppID */
|
||||||
|
$twitterAppID = Configuration::where(['key' => 'twitter_app_id'])->first();
|
||||||
|
|
||||||
|
/** @var Configuration $facebookAppID */
|
||||||
|
$twitterAppSecret = Configuration::where(['key' => 'twitter_app_secret'])->first();
|
||||||
|
|
||||||
|
if (is_null($twitterAppID) || is_null($twitterAppSecret))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$externalService = ExternalService::create([
|
||||||
|
'service_type' => ExternalService::TWITTER,
|
||||||
|
'name' => 'Twitter (migrated from settings)',
|
||||||
|
'app_id' => encrypt($twitterAppID->value), // app ID needs to be encrypted now
|
||||||
|
'app_secret' => $twitterAppSecret->value // secret is already encrypted
|
||||||
|
]);
|
||||||
|
|
||||||
|
/** @var ExternalService $twitterExternalServiceConfig */
|
||||||
|
$twitterExternalServiceConfig = UserConfig::getOrCreateModel('twitter_external_service_id');
|
||||||
|
$twitterExternalServiceConfig->value = $externalService->id;
|
||||||
|
$twitterExternalServiceConfig->save();
|
||||||
|
|
||||||
|
$twitterAppID->delete();
|
||||||
|
$twitterAppSecret->delete();
|
||||||
|
}
|
||||||
|
}
|
@ -82,6 +82,7 @@ return [
|
|||||||
'settings_moderate_known_users_help' => 'If this option is enabled, comments posted by logged-in users must be moderated before being displayed.',
|
'settings_moderate_known_users_help' => 'If this option is enabled, comments posted by logged-in users must be moderated before being displayed.',
|
||||||
'settings_restrict_originals_download' => 'Restrict access to original images',
|
'settings_restrict_originals_download' => 'Restrict access to original images',
|
||||||
'settings_restrict_originals_download_help' => 'With this option enabled, only the photo\'s owner can download the original high-resolution images.',
|
'settings_restrict_originals_download_help' => 'With this option enabled, only the photo\'s owner can download the original high-resolution images.',
|
||||||
|
'settings_social_external_services_edit_link' => 'Add or change these details in Services',
|
||||||
'settings_social_facebook_external_service' => 'Facebook service:',
|
'settings_social_facebook_external_service' => 'Facebook service:',
|
||||||
'settings_social_facebook_login' => 'Allow login/registration with a Facebook account.',
|
'settings_social_facebook_login' => 'Allow login/registration with a Facebook account.',
|
||||||
'settings_social_facebook_login_help' => 'With this option enabled, users can register (if enabled) and login with their Facebook account.',
|
'settings_social_facebook_login_help' => 'With this option enabled, users can register (if enabled) and login with their Facebook account.',
|
||||||
|
@ -516,11 +516,12 @@
|
|||||||
<div class="form-group mt-3">
|
<div class="form-group mt-3">
|
||||||
<label class="form-control-label" for="facebook-app-id">@lang('forms.settings_social_facebook_external_service')</label>
|
<label class="form-control-label" for="facebook-app-id">@lang('forms.settings_social_facebook_external_service')</label>
|
||||||
<select name="facebook_external_service_id" class="form-control{{ $errors->has('facebook_external_service_id') ? ' is-invalid' : '' }}">
|
<select name="facebook_external_service_id" class="form-control{{ $errors->has('facebook_external_service_id') ? ' is-invalid' : '' }}">
|
||||||
<option{{ is_null(old('facebook_external_service_id', $config['facebook_external_service_id']) ? ' selected="selected"' : '') }}>@lang('forms.please_select')</option>
|
<option value="0"{{ is_null(old('facebook_external_service_id', $config['facebook_external_service_id']) ? ' selected="selected"' : '') }}>@lang('forms.please_select')</option>
|
||||||
@foreach ($facebookServices as $service)
|
@foreach ($facebookServices as $service)
|
||||||
<option value="{{ $service->id }}"{{ old('facebook_external_service_id', $config['facebook_external_service_id'] == $service->id ? ' selected="selected"' : '') }}>{{ $service->name }}</option>
|
<option value="{{ $service->id }}"{{ old('facebook_external_service_id', $config['facebook_external_service_id'] == $service->id ? ' selected="selected"' : '') }}>{{ $service->name }}</option>
|
||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
|
<span class="form-text text-muted mt-2"><a href="{{ route('services.index') }}"><i class="fas fa-sync fa-fw"></i> @lang('forms.settings_social_external_services_edit_link')</a></span>
|
||||||
|
|
||||||
@if ($errors->has('facebook_external_service_id'))
|
@if ($errors->has('facebook_external_service_id'))
|
||||||
<div class="invalid-feedback">
|
<div class="invalid-feedback">
|
||||||
@ -564,11 +565,12 @@
|
|||||||
<div class="form-group mt-3">
|
<div class="form-group mt-3">
|
||||||
<label class="form-control-label" for="twitter-app-id">@lang('forms.settings_social_twitter_external_service')</label>
|
<label class="form-control-label" for="twitter-app-id">@lang('forms.settings_social_twitter_external_service')</label>
|
||||||
<select name="twitter_external_service_id" class="form-control{{ $errors->has('twitter_external_service_id') ? ' is-invalid' : '' }}">
|
<select name="twitter_external_service_id" class="form-control{{ $errors->has('twitter_external_service_id') ? ' is-invalid' : '' }}">
|
||||||
<option{{ is_null(old('twitter_external_service_id', $config['twitter_external_service_id']) ? ' selected="selected"' : '') }}>@lang('forms.please_select')</option>
|
<option value="0"{{ is_null(old('twitter_external_service_id', $config['twitter_external_service_id']) ? ' selected="selected"' : '') }}>@lang('forms.please_select')</option>
|
||||||
@foreach ($twitterServices as $service)
|
@foreach ($twitterServices as $service)
|
||||||
<option value="{{ $service->id }}"{{ old('twitter_external_service_id', $config['twitter_external_service_id'] == $service->id ? ' selected="selected"' : '') }}>{{ $service->name }}</option>
|
<option value="{{ $service->id }}"{{ old('twitter_external_service_id', $config['twitter_external_service_id'] == $service->id ? ' selected="selected"' : '') }}>{{ $service->name }}</option>
|
||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
|
<span class="form-text text-muted mt-2"><a href="{{ route('services.index') }}"><i class="fas fa-sync fa-fw"></i> @lang('forms.settings_social_external_services_edit_link')</a></span>
|
||||||
|
|
||||||
@if ($errors->has('twitter_external_service_id'))
|
@if ($errors->has('twitter_external_service_id'))
|
||||||
<div class="invalid-feedback">
|
<div class="invalid-feedback">
|
||||||
@ -613,11 +615,12 @@
|
|||||||
<div class="form-group mt-3">
|
<div class="form-group mt-3">
|
||||||
<label class="form-control-label" for="google-app-id">@lang('forms.settings_social_google_external_service')</label>
|
<label class="form-control-label" for="google-app-id">@lang('forms.settings_social_google_external_service')</label>
|
||||||
<select name="google_external_service_id" class="form-control{{ $errors->has('google_external_service_id') ? ' is-invalid' : '' }}">
|
<select name="google_external_service_id" class="form-control{{ $errors->has('google_external_service_id') ? ' is-invalid' : '' }}">
|
||||||
<option{{ is_null(old('google_external_service_id', $config['google_external_service_id']) ? ' selected="selected"' : '') }}>@lang('forms.please_select')</option>
|
<option value="0"{{ is_null(old('google_external_service_id', $config['google_external_service_id']) ? ' selected="selected"' : '') }}>@lang('forms.please_select')</option>
|
||||||
@foreach ($googleServices as $service)
|
@foreach ($googleServices as $service)
|
||||||
<option value="{{ $service->id }}"{{ old('google_external_service_id', $config['google_external_service_id'] == $service->id ? ' selected="selected"' : '') }}>{{ $service->name }}</option>
|
<option value="{{ $service->id }}"{{ old('google_external_service_id', $config['google_external_service_id'] == $service->id ? ' selected="selected"' : '') }}>{{ $service->name }}</option>
|
||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
|
<span class="form-text text-muted mt-2"><a href="{{ route('services.index') }}"><i class="fas fa-sync fa-fw"></i> @lang('forms.settings_social_external_services_edit_link')</a></span>
|
||||||
|
|
||||||
@if ($errors->has('google_external_service_id'))
|
@if ($errors->has('google_external_service_id'))
|
||||||
<div class="invalid-feedback">
|
<div class="invalid-feedback">
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
<p class="text-center" style="font-size: xx-large;">
|
<p class="text-center" style="font-size: xx-large;">
|
||||||
@if (UserConfig::get('social_facebook_login'))
|
@if (UserConfig::isLoginWithFacebookEnabled())
|
||||||
<a href="{{ route('login.facebook') }}"><i class="fab fa-facebook fa-fw"></i></a>
|
<a href="{{ route('login.facebook') }}"><i class="fab fa-facebook fa-fw"></i></a>
|
||||||
@endif
|
@endif
|
||||||
@if (UserConfig::get('social_twitter_login'))
|
@if (UserConfig::isLoginWithTwitterEnabled())
|
||||||
<a href="{{ route('login.twitter') }}"><i class="fab fa-twitter fa-fw"></i></a>
|
<a href="{{ route('login.twitter') }}"><i class="fab fa-twitter fa-fw"></i></a>
|
||||||
@endif
|
@endif
|
||||||
@if (UserConfig::get('social_google_login'))
|
@if (UserConfig::isLoginWithGoogleEnabled())
|
||||||
<a href="{{ route('login.google') }}"><i class="fab fa-google fa-fw"></i></a>
|
<a href="{{ route('login.google') }}"><i class="fab fa-google fa-fw"></i></a>
|
||||||
@endif
|
@endif
|
||||||
</p>
|
</p>
|
Loading…
Reference in New Issue
Block a user