extract "disable-registration" as plugin
This commit is contained in:
parent
4d22e0d2ee
commit
ef7dfd2a71
@ -136,19 +136,15 @@ class AuthController extends Controller
|
||||
];
|
||||
$rows = $filter->apply('auth_page_rows:register', $rows);
|
||||
|
||||
if (option('user_can_register')) {
|
||||
return view('auth.register', [
|
||||
'site_name' => option_localized('site_name'),
|
||||
'rows' => $rows,
|
||||
'extra' => [
|
||||
'player' => (bool) option('register_with_player_name'),
|
||||
'recaptcha' => option('recaptcha_sitekey'),
|
||||
'invisible' => (bool) option('recaptcha_invisible'),
|
||||
],
|
||||
]);
|
||||
} else {
|
||||
throw new PrettyPageException(trans('auth.register.close'), 7);
|
||||
}
|
||||
return view('auth.register', [
|
||||
'site_name' => option_localized('site_name'),
|
||||
'rows' => $rows,
|
||||
'extra' => [
|
||||
'player' => (bool) option('register_with_player_name'),
|
||||
'recaptcha' => option('recaptcha_sitekey'),
|
||||
'invisible' => (bool) option('recaptcha_invisible'),
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
public function handleRegister(
|
||||
@ -157,10 +153,6 @@ class AuthController extends Controller
|
||||
Dispatcher $dispatcher,
|
||||
Filter $filter
|
||||
) {
|
||||
if (!option('user_can_register')) {
|
||||
return json(trans('auth.register.close'), 1);
|
||||
}
|
||||
|
||||
$can = $filter->apply('can_register', null);
|
||||
if ($can instanceof Rejection) {
|
||||
return json($can->getReason(), 1);
|
||||
|
@ -21,8 +21,7 @@ class HomeController extends Controller
|
||||
'home_page_css_loader',
|
||||
config('app.asset.env') === 'development' ? $webpack->url('home.js') : null
|
||||
)
|
||||
->with('app_js', $webpack->url('app.js'))
|
||||
->with('user_can_register', option('user_can_register'));
|
||||
->with('app_js', $webpack->url('app.js'));
|
||||
}
|
||||
|
||||
public function apiRoot()
|
||||
|
@ -152,7 +152,6 @@ class OptionsController extends Controller
|
||||
return $url;
|
||||
});
|
||||
|
||||
$form->checkbox('user_can_register')->label();
|
||||
$form->checkbox('register_with_player_name')->label();
|
||||
$form->checkbox('require_verification')->label();
|
||||
|
||||
|
@ -75,5 +75,12 @@ class ViewServiceProvider extends ServiceProvider
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
});
|
||||
|
||||
View::composer('errors.503', function ($view) {
|
||||
$view->with(
|
||||
'show_login_button',
|
||||
!auth()->check() && request()->is('setup/*')
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ return [
|
||||
'site_url' => '',
|
||||
'site_name' => 'Blessing Skin',
|
||||
'site_description' => 'Open-source PHP Minecraft Skin Hosting Service',
|
||||
'user_can_register' => 'true',
|
||||
'register_with_player_name' => 'true',
|
||||
'require_verification' => 'false',
|
||||
'regs_per_ip' => '3',
|
||||
|
@ -1,4 +1,5 @@
|
||||
import '@/styles/home.css'
|
||||
import './i18n'
|
||||
import { getExtraData } from './extra'
|
||||
|
||||
export function scrollHander() {
|
||||
|
@ -101,9 +101,6 @@ general:
|
||||
site_url:
|
||||
title: Site URL
|
||||
hint: Begin with http(s)://, nerver ends with slash.
|
||||
user_can_register:
|
||||
title: Open Registration
|
||||
label: Everyone is allowed to register.
|
||||
register_with_player_name:
|
||||
title: Register with Player Name
|
||||
label: Require Minecraft's player name when user register
|
||||
|
@ -7,7 +7,7 @@
|
||||
<p>
|
||||
{{ trans('errors.exception.detail', {msg: exception.message ?: trans('errors.http.msg-503')}) }}
|
||||
</p>
|
||||
{% if not auth_check() %}
|
||||
{% if show_login_button %}
|
||||
<div class="mt-5">
|
||||
<a href="{{ url('/auth/login') }}" class="btn btn-primary">
|
||||
<i class="icon fas fa-sign-in-alt mr-1"></i>
|
||||
|
@ -68,15 +68,9 @@
|
||||
{{ trans('general.user-center') }}
|
||||
</a>
|
||||
{% else %}
|
||||
{% if user_can_register %}
|
||||
<a href="{{ url('auth/register') }}" class="main-button">
|
||||
{{ trans('general.register') }}
|
||||
</a>
|
||||
{% else %}
|
||||
<a href="{{ url('auth/login') }}" class="main-button">
|
||||
{{ trans('general.login') }}
|
||||
</a>
|
||||
{% endif %}
|
||||
<a href="{{ url('auth/register') }}" class="main-button">
|
||||
{{ trans('general.register') }}
|
||||
</a>
|
||||
{% endif %}
|
||||
</p>
|
||||
</div>
|
||||
|
@ -244,9 +244,6 @@ class AuthControllerTest extends TestCase
|
||||
|
||||
$this->get('/auth/register')->assertSee('Register');
|
||||
$filter->assertApplied('auth_page_rows:register');
|
||||
|
||||
option(['user_can_register' => false]);
|
||||
$this->get('/auth/register')->assertSee(trans('auth.register.close'));
|
||||
}
|
||||
|
||||
public function testHandleRegister()
|
||||
@ -388,22 +385,7 @@ class AuthControllerTest extends TestCase
|
||||
]
|
||||
)->assertJsonValidationErrors('captcha');
|
||||
|
||||
// Should be forbidden if registering is closed
|
||||
option(['user_can_register' => false]);
|
||||
$this->postJson(
|
||||
'/auth/register',
|
||||
[
|
||||
'email' => 'a@b.c',
|
||||
'password' => '12345678',
|
||||
'nickname' => 'nickname',
|
||||
'captcha' => 'a',
|
||||
]
|
||||
)->assertJson([
|
||||
'code' => 1,
|
||||
'message' => trans('auth.register.close'),
|
||||
]);
|
||||
|
||||
option(['user_can_register' => true, 'regs_per_ip' => -1]);
|
||||
option(['regs_per_ip' => -1]);
|
||||
$this->postJson(
|
||||
'/auth/register',
|
||||
[
|
||||
|
@ -106,7 +106,6 @@ class OptionsControllerTest extends BrowserKitTestCase
|
||||
->type('My Site', 'site_name')
|
||||
->type('hi', 'site_description')
|
||||
->type('http://blessing.skin/', 'site_url')
|
||||
->uncheck('user_can_register')
|
||||
->type('8', 'regs_per_ip')
|
||||
->type('2048', 'max_upload_file_size')
|
||||
->see(trans(
|
||||
@ -124,7 +123,6 @@ class OptionsControllerTest extends BrowserKitTestCase
|
||||
$this->assertEquals('My Site', option_localized('site_name'));
|
||||
$this->assertEquals('hi', option_localized('site_description'));
|
||||
$this->assertEquals('http://blessing.skin', option('site_url'));
|
||||
$this->assertFalse(option('user_can_register'));
|
||||
$this->assertEquals('8', option('regs_per_ip'));
|
||||
$this->assertEquals('2048', option('max_upload_file_size'));
|
||||
$this->assertEquals('cjk', option('player_name_rule'));
|
||||
|
Loading…
Reference in New Issue
Block a user