Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix]修复无法首页编辑资料和密码情况 #104

Merged
merged 3 commits into from
Sep 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .example.env
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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