diff --git a/application/admin/controller/Index.php b/application/admin/controller/Index.php index d5630408..71bf769f 100644 --- a/application/admin/controller/Index.php +++ b/application/admin/controller/Index.php @@ -86,7 +86,9 @@ class Index extends Backend } else { - $this->error(__('Username or password is incorrect'), $url, ['token' => $this->request->token()]); + $msg = $this->auth->getError(); + $msg = $msg ? $msg : __('Username or password is incorrect'); + $this->error($msg, $url, ['token' => $this->request->token()]); } } diff --git a/application/admin/controller/auth/Group.php b/application/admin/controller/auth/Group.php index 97f8f533..55e318d8 100644 --- a/application/admin/controller/auth/Group.php +++ b/application/admin/controller/auth/Group.php @@ -242,28 +242,28 @@ class Group extends Backend $model = model('AuthGroup'); $id = $this->request->post("id"); $pid = $this->request->post("pid"); - $parentgroupmodel = $model->get($pid); - $currentgroupmodel = NULL; + $parentGroupModel = $model->get($pid); + $currentGroupModel = NULL; if ($id) { - $currentgroupmodel = $model->get($id); + $currentGroupModel = $model->get($id); } - if (($pid || $parentgroupmodel) && (!$id || $currentgroupmodel)) + if (($pid || $parentGroupModel) && (!$id || $currentGroupModel)) { $id = $id ? $id : NULL; $ruleList = collection(model('AuthRule')->order('weigh', 'desc')->select())->toArray(); //读取父类角色所有节点列表 $parentRuleList = []; - if (in_array('*', explode(',', $parentgroupmodel->rules))) + if (in_array('*', explode(',', $parentGroupModel->rules))) { $parentRuleList = $ruleList; } else { - $parent_rule_ids = explode(',', $parentgroupmodel->rules); + $parentRuleIds = explode(',', $parentGroupModel->rules); foreach ($ruleList as $k => $v) { - if (in_array($v['id'], $parent_rule_ids)) + if (in_array($v['id'], $parentRuleIds)) { $parentRuleList[] = $v; } @@ -271,33 +271,38 @@ class Group extends Backend } //当前所有正常规则列表 - Tree::instance()->init($ruleList); + Tree::instance()->init($parentRuleList); //读取当前角色下规则ID集合 - $admin_rule_ids = $this->auth->getRuleIds(); + $adminRuleIds = $this->auth->getRuleIds(); //是否是超级管理员 $superadmin = $this->auth->isSuperAdmin(); //当前拥有的规则ID集合 - $current_rule_ids = $id ? explode(',', $currentgroupmodel->rules) : []; + $currentRuleIds = $id ? explode(',', $currentGroupModel->rules) : []; if (!$id || !in_array($pid, Tree::instance()->getChildrenIds($id, TRUE))) { - $ruleList = Tree::instance()->getTreeList(Tree::instance()->getTreeArray(0), 'name'); + $parentRuleList = Tree::instance()->getTreeList(Tree::instance()->getTreeArray(0), 'name'); $hasChildrens = []; - foreach ($ruleList as $k => $v) + foreach ($parentRuleList as $k => $v) { if ($v['haschild']) $hasChildrens[] = $v['id']; } - $nodelist = []; + $parentRuleIds = array_map(function($item) { + return $item['id']; + }, $parentRuleList); + $nodeList = []; foreach ($parentRuleList as $k => $v) { - if (!$superadmin && !in_array($v['id'], $admin_rule_ids)) + if (!$superadmin && !in_array($v['id'], $adminRuleIds)) continue; - $state = array('selected' => in_array($v['id'], $current_rule_ids) && !in_array($v['id'], $hasChildrens)); - $nodelist[] = array('id' => $v['id'], 'parent' => $v['pid'] ? $v['pid'] : '#', 'text' => __($v['title']), 'type' => 'menu', 'state' => $state); + if ($v['pid'] && !in_array($v['pid'], $parentRuleIds)) + continue; + $state = array('selected' => in_array($v['id'], $currentRuleIds) && !in_array($v['id'], $hasChildrens)); + $nodeList[] = array('id' => $v['id'], 'parent' => $v['pid'] ? $v['pid'] : '#', 'text' => __($v['title']), 'type' => 'menu', 'state' => $state); } - $this->success('', null, $nodelist); + $this->success('', null, $nodeList); } else { diff --git a/application/admin/lang/zh-cn.php b/application/admin/lang/zh-cn.php index 20a154e2..791143b8 100644 --- a/application/admin/lang/zh-cn.php +++ b/application/admin/lang/zh-cn.php @@ -72,6 +72,7 @@ return [ 'Recommend' => '推荐', 'Dashboard' => '控制台', 'Upload' => '上传', + 'Uploading' => '上传中', 'Code' => '编号', 'Message' => '内容', 'Line' => '行号', diff --git a/application/admin/lang/zh-cn/auth/admin.php b/application/admin/lang/zh-cn/auth/admin.php index 0a36d7ce..59c7c496 100644 --- a/application/admin/lang/zh-cn/auth/admin.php +++ b/application/admin/lang/zh-cn/auth/admin.php @@ -1,6 +1,7 @@ '所属组别', - 'Login time' => '最后登录', + 'Group' => '所属组别', + 'Loginfailure' => '登录失败次数', + 'Login time' => '最后登录', ]; diff --git a/application/admin/lang/zh-cn/index.php b/application/admin/lang/zh-cn/index.php index 661a9103..d5e4eeb7 100644 --- a/application/admin/lang/zh-cn/index.php +++ b/application/admin/lang/zh-cn/index.php @@ -26,6 +26,7 @@ return [ 'Username or password is incorrect' => '用户名或密码不正确', 'Username is incorrect' => '用户名不正确', 'Password is incorrect' => '密码不正确', + 'Please try again after 1 day' => '请于1天后再尝试登录', 'Login successful' => '登录成功!', 'Logout successful' => '退出成功!', 'Verification code is incorrect' => '验证码不正确', diff --git a/application/admin/library/Auth.php b/application/admin/library/Auth.php index ba230413..5b428c29 100644 --- a/application/admin/library/Auth.php +++ b/application/admin/library/Auth.php @@ -13,6 +13,7 @@ use think\Session; class Auth extends \fast\Auth { + protected $_error = ''; protected $requestUri = ''; protected $breadcrumb = []; protected $logined = false; //登录状态 @@ -40,16 +41,19 @@ class Auth extends \fast\Auth $admin = Admin::get(['username' => $username]); if (!$admin) { + $this->setError('Username is incorrect'); return false; } if ($admin->loginfailure >= 3 && time() - $admin->updatetime < 86400) { + $this->setError('Please try again after 1 day'); return false; } if ($admin->password != md5(md5($password) . $admin->salt)) { $admin->loginfailure++; $admin->save(); + $this->setError('Password is incorrect'); return false; } $admin->loginfailure = 0; @@ -424,4 +428,24 @@ class Auth extends \fast\Auth return $menu; } + /** + * 设置错误信息 + * + * @param $error 错误信息 + */ + public function setError($error) + { + $this->_error = $error; + return $this; + } + + /** + * 获取错误信息 + * @return string + */ + public function getError() + { + return $this->_error ? __($this->_error) : ''; + } + } diff --git a/application/admin/view/auth/admin/edit.html b/application/admin/view/auth/admin/edit.html index b487438c..54ddb97f 100644 --- a/application/admin/view/auth/admin/edit.html +++ b/application/admin/view/auth/admin/edit.html @@ -29,6 +29,12 @@ +
| 标题 | -内容 | +{:__('Title')} | +{:__('Content')} |
|---|---|---|---|
| {$key} | +{:__($key)} | {$vo} |