From 877cae94f75b7f8ebd7ad17bf9c37e3486f32bd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Jaussoin?= Date: Mon, 2 Aug 2021 15:42:23 +0200 Subject: [PATCH] Add a toggle to disable public account registration --- flexiapi/.env.example | 3 +- flexiapi/app/Providers/AppServiceProvider.php | 8 ++-- flexiapi/composer.lock | 38 +++++++++---------- flexiapi/config/app.php | 2 + .../account/documentation_markdown.blade.php | 6 ++- .../resources/views/account/home.blade.php | 14 ++++--- .../resources/views/account/login.blade.php | 12 +++--- .../resources/views/layouts/main.blade.php | 8 ++-- flexiapi/routes/web.php | 17 +++++---- flexisip-account-manager.spec | 2 +- 10 files changed, 63 insertions(+), 47 deletions(-) diff --git a/flexiapi/.env.example b/flexiapi/.env.example index 2055d68..69bca0b 100644 --- a/flexiapi/.env.example +++ b/flexiapi/.env.example @@ -24,7 +24,8 @@ INSTANCE_CUSTOM_THEME=false INSTANCE_CONFIRMED_REGISTRATION_TEXT= # Markdown text displayed when an account is confirmed NEWSLETTER_REGISTRATION_ADDRESS= # Address to contact when a user wants to register to the newsletter -PHONE_AUTHENTICATION=true # Toggle to enable/disable the SMS support +PUBLIC_REGISTRATION=true # Toggle to enable/disable the public registration forms +PHONE_AUTHENTICATION=true # Toggle to enable/disable the SMS support, requires public registration DEVICES_MANAGEMENT=false # Toggle to enable/disable the devices management support TERMS_OF_USE_URL= # A URL pointing to the Terms of Use diff --git a/flexiapi/app/Providers/AppServiceProvider.php b/flexiapi/app/Providers/AppServiceProvider.php index 0cabe16..9e1be02 100644 --- a/flexiapi/app/Providers/AppServiceProvider.php +++ b/flexiapi/app/Providers/AppServiceProvider.php @@ -13,8 +13,10 @@ class AppServiceProvider extends ServiceProvider public function boot() { - // Add following lines to force laravel to use APP_URL as root url for the app. - $strBaseURL = $this->app['url']; - $strBaseURL->forceRootUrl(config('app.url')); + if (!empty(config('app.url'))) { + // Add following lines to force laravel to use APP_URL as root url for the app. + $strBaseURL = $this->app['url']; + $strBaseURL->forceRootUrl(config('app.url')); + } } } diff --git a/flexiapi/composer.lock b/flexiapi/composer.lock index 8197fa5..f6b8a5f 100644 --- a/flexiapi/composer.lock +++ b/flexiapi/composer.lock @@ -2390,16 +2390,16 @@ }, { "name": "ramsey/collection", - "version": "1.1.3", + "version": "1.1.4", "source": { "type": "git", "url": "https://github.com/ramsey/collection.git", - "reference": "28a5c4ab2f5111db6a60b2b4ec84057e0f43b9c1" + "reference": "ab2237657ad99667a5143e32ba2683c8029563d4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ramsey/collection/zipball/28a5c4ab2f5111db6a60b2b4ec84057e0f43b9c1", - "reference": "28a5c4ab2f5111db6a60b2b4ec84057e0f43b9c1", + "url": "https://api.github.com/repos/ramsey/collection/zipball/ab2237657ad99667a5143e32ba2683c8029563d4", + "reference": "ab2237657ad99667a5143e32ba2683c8029563d4", "shasum": "" }, "require": { @@ -2451,7 +2451,7 @@ ], "support": { "issues": "https://github.com/ramsey/collection/issues", - "source": "https://github.com/ramsey/collection/tree/1.1.3" + "source": "https://github.com/ramsey/collection/tree/1.1.4" }, "funding": [ { @@ -2463,7 +2463,7 @@ "type": "tidelift" } ], - "time": "2021-01-21T17:40:04+00:00" + "time": "2021-07-30T00:58:27+00:00" }, { "name": "ramsey/uuid", @@ -5602,16 +5602,16 @@ }, { "name": "maximebf/debugbar", - "version": "v1.17.0", + "version": "v1.17.1", "source": { "type": "git", "url": "https://github.com/maximebf/php-debugbar.git", - "reference": "4ef8e359d9fffbfbce26218ee36f196453a4dd7d" + "reference": "0a3532556be0145603f8a9de23e76dc28eed7054" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/4ef8e359d9fffbfbce26218ee36f196453a4dd7d", - "reference": "4ef8e359d9fffbfbce26218ee36f196453a4dd7d", + "url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/0a3532556be0145603f8a9de23e76dc28eed7054", + "reference": "0a3532556be0145603f8a9de23e76dc28eed7054", "shasum": "" }, "require": { @@ -5661,9 +5661,9 @@ ], "support": { "issues": "https://github.com/maximebf/php-debugbar/issues", - "source": "https://github.com/maximebf/php-debugbar/tree/v1.17.0" + "source": "https://github.com/maximebf/php-debugbar/tree/v1.17.1" }, - "time": "2021-07-27T05:47:57+00:00" + "time": "2021-08-01T09:19:02+00:00" }, { "name": "mockery/mockery", @@ -6539,16 +6539,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.5.7", + "version": "9.5.8", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "d0dc8b6999c937616df4fb046792004b33fd31c5" + "reference": "191768ccd5c85513b4068bdbe99bb6390c7d54fb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/d0dc8b6999c937616df4fb046792004b33fd31c5", - "reference": "d0dc8b6999c937616df4fb046792004b33fd31c5", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/191768ccd5c85513b4068bdbe99bb6390c7d54fb", + "reference": "191768ccd5c85513b4068bdbe99bb6390c7d54fb", "shasum": "" }, "require": { @@ -6560,7 +6560,7 @@ "ext-xml": "*", "ext-xmlwriter": "*", "myclabs/deep-copy": "^1.10.1", - "phar-io/manifest": "^2.0.1", + "phar-io/manifest": "^2.0.3", "phar-io/version": "^3.0.2", "php": ">=7.3", "phpspec/prophecy": "^1.12.1", @@ -6626,7 +6626,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.7" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.8" }, "funding": [ { @@ -6638,7 +6638,7 @@ "type": "github" } ], - "time": "2021-07-19T06:14:47+00:00" + "time": "2021-07-31T15:17:34+00:00" }, { "name": "sebastian/cli-parser", diff --git a/flexiapi/config/app.php b/flexiapi/config/app.php index 6979120..b4f8227 100644 --- a/flexiapi/config/app.php +++ b/flexiapi/config/app.php @@ -23,11 +23,13 @@ return [ 'newsletter_registration_address' => env('NEWSLETTER_REGISTRATION_ADDRESS', ''), 'phone_authentication' => env('PHONE_AUTHENTICATION', true), + 'public_registration' => env('PUBLIC_REGISTRATION', true), 'devices_management' => env('DEVICES_MANAGEMENT', false), 'proxy_registrar_address' => env('ACCOUNT_PROXY_REGISTRAR_ADDRESS', 'sip.domain.com'), 'transport_protocol_text' => env('ACCOUNT_TRANSPORT_PROTOCOL_TEXT', 'TLS (recommended), TCP or UDP'), + /** * Account provisioning */ diff --git a/flexiapi/resources/views/account/documentation_markdown.blade.php b/flexiapi/resources/views/account/documentation_markdown.blade.php index 3ccbafe..b4cbe1e 100644 --- a/flexiapi/resources/views/account/documentation_markdown.blade.php +++ b/flexiapi/resources/views/account/documentation_markdown.blade.php @@ -10,7 +10,11 @@ Registration can be achieve using two methods if they are correctly configured a ## Email Registration -You can [create an account using an email address]({{ route('account.register.email') }}). The form requires you to provide an username and your email address. +@if (!config('app.public_registration')) +*The feature is not enabled on this instance.* +@endif + +You can @if (config('app.public_registration')) [create an account using an email address]({{ route('account.register.email') }}) @else create an account using an email address @endif. The form requires you to provide an username and your email address. Once completed a confirmation email containing a unique link will be sent to the address. This link is used to activate your account, allowing you to finish the setup. diff --git a/flexiapi/resources/views/account/home.blade.php b/flexiapi/resources/views/account/home.blade.php index 6712951..0ec7314 100644 --- a/flexiapi/resources/views/account/home.blade.php +++ b/flexiapi/resources/views/account/home.blade.php @@ -13,12 +13,14 @@
- -
-
Create an account
-
-

Register on our service

-
+ @if (config('app.public_registration')) + +
+
Create an account
+
+

Register on our service

+
+ @endif
Manage your account
diff --git a/flexiapi/resources/views/account/login.blade.php b/flexiapi/resources/views/account/login.blade.php index e57cd18..b0d01ec 100644 --- a/flexiapi/resources/views/account/login.blade.php +++ b/flexiapi/resources/views/account/login.blade.php @@ -28,11 +28,13 @@ @include('parts.password_recovery') @endif -
+ @if (config('app.public_registration')) +
-

- No account yet? - Register -

+

+ No account yet? + Register +

+ @endif @endsection \ No newline at end of file diff --git a/flexiapi/resources/views/layouts/main.blade.php b/flexiapi/resources/views/layouts/main.blade.php index 975a591..56f8ab6 100644 --- a/flexiapi/resources/views/layouts/main.blade.php +++ b/flexiapi/resources/views/layouts/main.blade.php @@ -15,9 +15,11 @@