Commit 4f37eeabe80d37b897fd7c125233c4f4016b6af0

Authored by xu
1 parent a1f2032a
Exists in master

app-ht

1. F 创建账号的时候做用户名校验
app-ht/config/main.php
@@ -91,18 +91,12 @@ $config = [ @@ -91,18 +91,12 @@ $config = [
91 'site/index', 91 'site/index',
92 'site/region', 92 'site/region',
93 'site/editor-upload', 93 'site/editor-upload',
94 - 'site/ajax-item-top',  
95 - 'site/ajax-member-top',  
96 - 'site/ajax-instant',  
97 - 'site/ajax-wares-tab',  
98 - 'site/ajax-member-chart', 94 +
99 'my/default/index', // 个人中心登陆即可 95 'my/default/index', // 个人中心登陆即可
100 'my/default/do-update', 96 'my/default/do-update',
101 'my/default/password', 97 'my/default/password',
102 'my/default/do-password', 98 'my/default/do-password',
103 - 'device/index',  
104 - 'device/index/index',  
105 - 'test/index', 99 + 'dashboard/index',
106 ] 100 ]
107 ], 101 ],
108 102
app-ht/modules/system/controllers/AccountController.php
@@ -120,6 +120,14 @@ class AccountController extends BaseController @@ -120,6 +120,14 @@ class AccountController extends BaseController
120 $mobile = isset($post['mobile']) ? $post['mobile'] : ''; 120 $mobile = isset($post['mobile']) ? $post['mobile'] : '';
121 $is_enable = isset($post['is_enable']) ? 1 : 0; 121 $is_enable = isset($post['is_enable']) ? 1 : 0;
122 122
  123 + if ('' == $username || !(preg_match("/^[0-9a-zA-Z]{6,10}$/", $username))) {
  124 + Yii::$app->session->setFlash('danger', '用户名不能是空格,并且必须是6~12位的英文或数字');
  125 + return $this->redirect(['/system/account/create']);
  126 + }
  127 + if ('' == $realname) {
  128 + Yii::$app->session->setFlash('danger', '名称不能是空格');
  129 + return $this->redirect(['/system/account/create']);
  130 + }
123 // 用户名不允许有冒号 131 // 用户名不允许有冒号
124 if (strpos($username, ':') !== false) { 132 if (strpos($username, ':') !== false) {
125 Yii::$app->session->setFlash('danger', '用户名不能包含冒号,请重新输入'); 133 Yii::$app->session->setFlash('danger', '用户名不能包含冒号,请重新输入');
@@ -197,7 +205,17 @@ class AccountController extends BaseController @@ -197,7 +205,17 @@ class AccountController extends BaseController
197 $is_enable = isset($post['is_enable']) ? 1 : 0; 205 $is_enable = isset($post['is_enable']) ? 1 : 0;
198 206
199 $model = $this->findModel($id); 207 $model = $this->findModel($id);
  208 + $username = trim($username);
  209 + $realname = trim($realname);
200 210
  211 + if ('' == $username || !(preg_match("/^[0-9a-zA-Z]{6,10}$/", $username))) {
  212 + Yii::$app->session->setFlash('danger', '用户名不能是空格,并且必须是6~12位的英文或数字');
  213 + return $this->redirect(['/system/account/update', 'id' => $model->id]);
  214 + }
  215 + if ('' == $realname) {
  216 + Yii::$app->session->setFlash('danger', '名称不能是空格');
  217 + return $this->redirect(['/system/account/update', 'id' => $model->id]);
  218 + }
201 // 用户名不允许有冒号 219 // 用户名不允许有冒号
202 if (strpos($username, ':') !== false) { 220 if (strpos($username, ':') !== false) {
203 Yii::$app->session->setFlash('danger', '用户名不能包含冒号,请重新输入'); 221 Yii::$app->session->setFlash('danger', '用户名不能包含冒号,请重新输入');