diff --git a/app/Http/Controllers/SetupController.php b/app/Http/Controllers/SetupController.php
index b818963a..483e3d35 100644
--- a/app/Http/Controllers/SetupController.php
+++ b/app/Http/Controllers/SetupController.php
@@ -61,6 +61,7 @@ class SetupController extends Controller
{
$data = $this->validate($request, [
'email' => 'required|email',
+ 'nickname' => 'required|no_special_chars|max:255',
'password' => 'required|min:8|max:32|confirmed',
'site_name' => 'required'
]);
@@ -94,7 +95,7 @@ class SetupController extends Controller
// Register super admin
$user = new User;
$user->email = $data['email'];
- $user->nickname = '';
+ $user->nickname = $data['nickname'];
$user->score = option('user_initial_score');
$user->avatar = 0;
$user->password = User::getEncryptedPwdFromEvent($data['password'], $user)
diff --git a/resources/lang/en/setup.yml b/resources/lang/en/setup.yml
index fca50047..9e95e955 100644
--- a/resources/lang/en/setup.yml
+++ b/resources/lang/en/setup.yml
@@ -50,6 +50,7 @@ wizard:
admin-email: Admin Email
admin-notice: This is the UNIQUE super admin account who can GIVE or CANCEL other users' admin privilege.
+ nickname: Nickname
password: Password
pwd-notice: Attention: You will need the password to log in. Please keep it at a secure place.
confirm-pwd: Confirm password
diff --git a/resources/lang/zh_CN/setup.yml b/resources/lang/zh_CN/setup.yml
index b04e071e..9f7415f0 100644
--- a/resources/lang/zh_CN/setup.yml
+++ b/resources/lang/zh_CN/setup.yml
@@ -50,6 +50,7 @@ wizard:
admin-email: 管理员邮箱
admin-notice: 这是唯一的超级管理员账号,可 添加/取消 其他管理员。
+ nickname: 昵称
password: 密码
pwd-notice: 重要:您将需要此密码来登录管理皮肤站,请将其保存在安全的位置。
confirm-pwd: 重复密码
diff --git a/resources/views/setup/wizard/info.tpl b/resources/views/setup/wizard/info.tpl
index 529befe3..4a6e90cb 100644
--- a/resources/views/setup/wizard/info.tpl
+++ b/resources/views/setup/wizard/info.tpl
@@ -16,6 +16,12 @@
{!! trans('setup.wizard.info.admin-notice') !!}
+
+ |
+
+
+ |
+
|
diff --git a/tests/SetupControllerTest.php b/tests/SetupControllerTest.php
index cf1f94d2..d022d0db 100644
--- a/tests/SetupControllerTest.php
+++ b/tests/SetupControllerTest.php
@@ -69,26 +69,47 @@ class SetupControllerTest extends TestCase
$this->post('/setup/finish', ['email' => 'not_an_email'])
->assertDontSee(trans('setup.wizard.finish.title'));
- // Without `password` field
+ // Empty nickname
$this->post('/setup/finish', [
'email' => 'a@b.c'
])->assertDontSee(trans('setup.wizard.finish.title'));
+ // Invalid characters in nickname
+ $this->post('/setup/finish', [
+ 'email' => 'a@b.c',
+ 'nickname' => '\\'
+ ])->assertDontSee(trans('setup.wizard.finish.title'));
+
+ // Too long nickname
+ $this->post('/setup/finish', [
+ 'email' => 'a@b.c',
+ 'nickname' => str_random(256)
+ ])->assertDontSee(trans('setup.wizard.finish.title'));
+
+ // Without `password` field
+ $this->post('/setup/finish', [
+ 'email' => 'a@b.c',
+ 'nickname' => 'nickname'
+ ])->assertDontSee(trans('setup.wizard.finish.title'));
+
// Password is too short
$this->post('/setup/finish', [
'email' => 'a@b.c',
+ 'nickname' => 'nickname',
'password' => '1'
])->assertDontSee(trans('setup.wizard.finish.title'));
// Password is too long
$this->post('/setup/finish', [
'email' => 'a@b.c',
+ 'nickname' => 'nickname',
'password' => str_random(17)
])->assertDontSee(trans('setup.wizard.finish.title'));
// Confirmation is not OK
$this->post('/setup/finish', [
'email' => 'a@b.c',
+ 'nickname' => 'nickname',
'password' => '12345678',
'password_confirmation' => '12345679'
])->assertDontSee(trans('setup.wizard.finish.title'));
@@ -96,6 +117,7 @@ class SetupControllerTest extends TestCase
// Without `site_name` field
$this->post('/setup/finish', [
'email' => 'a@b.c',
+ 'nickname' => 'nickname',
'password' => '12345678',
'password_confirmation' => '12345678'
])->assertDontSee(trans('setup.wizard.finish.title'));
@@ -118,6 +140,7 @@ class SetupControllerTest extends TestCase
});
$this->post('/setup/finish', [
'email' => 'a@b.c',
+ 'nickname' => 'nickname',
'password' => '12345678',
'password_confirmation' => '12345678',
'site_name' => 'bs',
@@ -125,6 +148,11 @@ class SetupControllerTest extends TestCase
])->assertSee(trans('setup.wizard.finish.title'))
->assertSee('a@b.c')
->assertSee('12345678');
+ $superAdmin = \App\Models\User::find(1);
+ $this->assertEquals('a@b.c', $superAdmin->email);
+ $this->assertTrue($superAdmin->verifyPassword('12345678'));
+ $this->assertEquals('nickname', $superAdmin->nickname);
+ $this->assertEquals('bs', option('site_name'));
}
public function testUpdate()
|