Skip to content

Commit

Permalink
[fix]修复无法首页编辑资料和密码情况 (#104)
Browse files Browse the repository at this point in the history
* [fix]修复无法编辑资料和账号密码情况

* [feat]优化env文件默认值

* [fix]修复密码无法修改问题

Co-authored-by: chung <chung@chungdeMacBook-Pro.local>
  • Loading branch information
zhongshaofa and chung committed Sep 18, 2021
1 parent 5f556eb commit dda75ad
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .example.env
Expand Up @@ -23,10 +23,10 @@ default_lang=zh-cn
ADMIN=admin

# 后台登录验证码开关
CAPTCHA=true
CAPTCHA=false

# 是否为演示环境
IS_DEMO=true
IS_DEMO=false

# CDN配置项组
CDN=
Expand Down
10 changes: 2 additions & 8 deletions app/admin/controller/Index.php
Expand Up @@ -49,13 +49,12 @@ public function welcome()
*/
public function editAdmin()
{
$this->checkPostRequest();
$id = session('admin.id');
$row = (new SystemAdmin())
->withoutField('password')
->find($id);
empty($row) && $this->error('用户信息不存在');
if ($this->request->isAjax()) {
if ($this->request->isPost()) {
$post = $this->request->post();
$this->isDemo && $this->error('演示环境下不允许修改');
$rule = [];
Expand All @@ -82,15 +81,14 @@ public function editAdmin()
*/
public function editPassword()
{
$this->checkPostRequest();
$id = session('admin.id');
$row = (new SystemAdmin())
->withoutField('password')
->find($id);
if (!$row) {
$this->error('用户信息不存在');
}
if ($this->request->isAjax()) {
if ($this->request->isPost()) {
$post = $this->request->post();
$this->isDemo && $this->error('演示环境下不允许修改');
$rule = [
Expand All @@ -102,10 +100,6 @@ public function editPassword()
$this->error('两次密码输入不一致');
}

// 判断是否为演示站点
$example = Env::get('easyadmin.example', 0);
$example == 1 && $this->error('演示站点不允许修改密码');

try {
$save = $row->save([
'password' => password($post['password']),
Expand Down

0 comments on commit dda75ad

Please sign in to comment.