add UI rows for auth pages

This commit is contained in:
Pig Fang 2020-06-07 18:54:52 +08:00
parent 95fed10535
commit 1e85794256
10 changed files with 43 additions and 18 deletions

View File

@ -29,7 +29,16 @@ class AuthController extends Controller
$ip = $whip->getValidIpAddress();
$ip = $filter->apply('client_ip', $ip);
$rows = [
'auth.rows.login.notice',
'auth.rows.login.message',
'auth.rows.login.form',
'auth.rows.login.registration-link',
];
$rows = $filter->apply('auth_page_rows:login', $rows);
return view('auth.login', [
'rows' => $rows,
'extra' => [
'tooManyFails' => cache(sha1('login_fails_'.$ip)) > 3,
'recaptcha' => option('recaptcha_sitekey'),
@ -120,11 +129,18 @@ class AuthController extends Controller
return json(trans('auth.logout.success'), 0);
}
public function register()
public function register(Filter $filter)
{
$rows = [
'auth.rows.register.notice',
'auth.rows.register.form',
];
$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'),

View File

@ -3,18 +3,9 @@
{% block title %}{{ trans('auth.login.title') }}{% endblock %}
{% block content %}
<p class="login-box-msg">{{ trans('auth.login.message') }}</p>
{% if session_has('msg') %}
<div class="alert alert-warning">
{{ session_pull('msg') }}
</div>
{% endif %}
<main></main>
<br>
{{ include('auth.oauth') }}
<div>
<a href="{{ url('auth/register') }}">{{ trans('auth.register-link') }}</a>
</div>
{% for row in rows %}
{{ include(row) }}
{% endfor %}
{% endblock %}
{% block before_foot %}

View File

@ -3,11 +3,9 @@
{% block title %}{{ trans('auth.register.title') }}{% endblock %}
{% block content %}
<p class="login-box-msg">
{{ trans('auth.register.message', {sitename: site_name}) }}
</p>
<main></main>
{{ include('auth.oauth') }}
{% for row in rows %}
{{ include(row) }}
{% endfor %}
{% endblock %}
{% block before_foot %}

View File

@ -0,0 +1 @@
<main></main>

View File

@ -0,0 +1,5 @@
{% if session_has('msg') %}
<div class="alert alert-warning">
{{ session_pull('msg') }}
</div>
{% endif %}

View File

@ -0,0 +1 @@
<p class="login-box-msg">{{ trans('auth.login.message') }}</p>

View File

@ -0,0 +1,3 @@
<div class="mt-3">
<a href="{{ url('auth/register') }}">{{ trans('auth.register-link') }}</a>
</div>

View File

@ -0,0 +1 @@
<main></main>

View File

@ -0,0 +1,3 @@
<p class="login-box-msg">
{{ trans('auth.register.message', {sitename: site_name}) }}
</p>

View File

@ -37,7 +37,10 @@ class AuthControllerTest extends TestCase
public function testLogin()
{
$filter = Fakes\Filter::fake();
$this->get('/auth/login')->assertSee('Log in');
$filter->assertApplied('auth_page_rows:login');
}
public function testHandleLogin()
@ -239,7 +242,10 @@ class AuthControllerTest extends TestCase
public function testRegister()
{
$filter = Fakes\Filter::fake();
$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'));