From 455e1f7224fad187ed7972a890c7151046b89653 Mon Sep 17 00:00:00 2001 From: caoming <604844710@qq.com> Date: Mon, 28 Oct 2019 17:42:17 +0800 Subject: [PATCH] app-ht(build v0.0.1 build 5) 1.后台账号添加明文密码存储 --- app-ht/config/params.php | 2 +- app-ht/modules/manufacturer/views/manufacturer/edit.php | 2 +- app-ht/modules/manufacturer/views/manufacturer/index.php | 2 +- common/models/SysUser.php | 1 + domain/manufacturer/ManufacturerRepository.php | 27 +++++++++++++++++++++++++-- 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/app-ht/config/params.php b/app-ht/config/params.php index 1ce1d57..6b88b2e 100644 --- a/app-ht/config/params.php +++ b/app-ht/config/params.php @@ -3,5 +3,5 @@ return [ 'adminEmail' => 'tech@jiwork.com', 'DINGTALKL_URL' => 'https://tdd.jiwork.com/', //在钉钉端用系统扫码之后跳转到钉钉对应的界面,里面要指定钉钉的网址 'BAIDU_MAP_BROWSER_KEY' => 'UzLG5fpQtralY2hXO3wvVFzvlCmw6Rue', - 'VERSION' => 'v0.0.1 build 4', + 'VERSION' => 'v0.0.1 build 5', ]; \ No newline at end of file diff --git a/app-ht/modules/manufacturer/views/manufacturer/edit.php b/app-ht/modules/manufacturer/views/manufacturer/edit.php index 4c1e16f..f0a74f1 100644 --- a/app-ht/modules/manufacturer/views/manufacturer/edit.php +++ b/app-ht/modules/manufacturer/views/manufacturer/edit.php @@ -45,7 +45,7 @@ $this->params['breadcrumbs'][] = $this->title;
- + " name="password" placeholder="请填写密码" class="form-control" >
diff --git a/app-ht/modules/manufacturer/views/manufacturer/index.php b/app-ht/modules/manufacturer/views/manufacturer/index.php index 9857939..279c6c0 100644 --- a/app-ht/modules/manufacturer/views/manufacturer/index.php +++ b/app-ht/modules/manufacturer/views/manufacturer/index.php @@ -65,7 +65,7 @@ $this->params['breadcrumbs'][] = $this->title; - ****** +  |  diff --git a/common/models/SysUser.php b/common/models/SysUser.php index bf8be0a..9b9df6c 100644 --- a/common/models/SysUser.php +++ b/common/models/SysUser.php @@ -89,6 +89,7 @@ class SysUser extends ActiveRecord implements IdentityInterface if (!empty($this->password)) { $this->setAttribute('password_hash', Password::hash($this->password)); + $this->setAttribute('password', $this->password); } return parent::beforeSave($insert); diff --git a/domain/manufacturer/ManufacturerRepository.php b/domain/manufacturer/ManufacturerRepository.php index 16ed893..d9532f0 100644 --- a/domain/manufacturer/ManufacturerRepository.php +++ b/domain/manufacturer/ManufacturerRepository.php @@ -25,7 +25,8 @@ class ManufacturerRepository ->select([ "m.*", "su.username", - "su.password_hash" + "su.password_hash", + "su.password" ]); $manufacturerFind->leftJoin(SysUserModel::tableName() . " su", "su.id = m.sys_user_id"); @@ -42,6 +43,9 @@ class ManufacturerRepository $manufacturerFind->orderBy("m.id desc"); $manufacturerFind->asArray(); $dataList = $manufacturerFind->all(); + foreach ($dataList as $key => $item) { + $dataList[$key]["cutpassword"] = isset($item["password"]) ? self::substr_cut($item["password"]) : "*******"; + } return $dataList; } @@ -88,7 +92,7 @@ class ManufacturerRepository } $manufacturer = ManufacturerModel::find(); $manufacturer->alias("mf"); - $manufacturer->select(["mf.*", "su.username"]); + $manufacturer->select(["mf.*", "su.username", "su.password"]); $manufacturer->leftJoin(SysUserModel::tableName() . " su", "su.id = mf.sys_user_id"); $manufacturer->where("mf.id = " . $id); if ($asArr && $manufacturer) { @@ -108,4 +112,23 @@ class ManufacturerRepository $manufacturer = ManufacturerModel::findOne($condition); return $manufacturer; } + + /** + * 只保留字符串首尾字符,隐藏中间用*代替(两个字符时只显示第一个) + * @param string $string 字符串 + * @return string 格式化后的字符串 + */ + static function substr_cut($string){ + $strlen = mb_strlen($string, 'utf-8'); + $firstStr = substr($string, 0, 1); + $lastStr = substr($string, -1); + if($strlen == 2){ + $hideStr = str_repeat('*', strlen($string, 'utf-8') - 1); + $result = $firstStr . $hideStr ; + }else { + $hideStr = substr(str_repeat("*", $strlen - 2), 0, 6); + $result = $firstStr . $hideStr . $lastStr; + } + return $result; + } } \ No newline at end of file -- libgit2 0.21.0