Nickname is required in setup
This commit is contained in:
parent
712b754c09
commit
0ded695295
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ wizard:
|
|||
|
||||
admin-email: Admin Email
|
||||
admin-notice: This is the <b>UNIQUE</b> super admin account who can GIVE or CANCEL other users' admin privilege.
|
||||
nickname: Nickname
|
||||
password: Password
|
||||
pwd-notice: <b>Attention:</b> You will need the password to log in. Please keep it at a secure place.
|
||||
confirm-pwd: Confirm password
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ wizard:
|
|||
|
||||
admin-email: 管理员邮箱
|
||||
admin-notice: 这是<b>唯一</b>的超级管理员账号,可 添加/取消 其他管理员。
|
||||
nickname: 昵称
|
||||
password: 密码
|
||||
pwd-notice: <b>重要:</b>您将需要此密码来登录管理皮肤站,请将其保存在安全的位置。
|
||||
confirm-pwd: 重复密码
|
||||
|
|
|
|||
|
|
@ -16,6 +16,12 @@
|
|||
<p>{!! trans('setup.wizard.info.admin-notice') !!}</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><label for="email">@lang('setup.wizard.info.nickname')</label></th>
|
||||
<td>
|
||||
<input name="nickname" type="text" id="nickname" size="25" value="" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="form-field form-required">
|
||||
<th scope="row"><label for="password">@lang('setup.wizard.info.password')</label></th>
|
||||
<td>
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user