From e3c0c6304738d6ebc3a86c5524e04dfd4af0c02e Mon Sep 17 00:00:00 2001 From: wangyidong Date: Wed, 19 Jul 2023 13:46:01 +0800 Subject: [PATCH] * Adjust delete user. --- module/user/control.php | 29 ++++++++--------------------- module/user/ui/delete.html.php | 5 +---- 2 files changed, 9 insertions(+), 25 deletions(-) diff --git a/module/user/control.php b/module/user/control.php index d7be74f743..4d11ec1e70 100755 --- a/module/user/control.php +++ b/module/user/control.php @@ -706,30 +706,17 @@ class user extends control if($this->app->user->admin and $this->app->user->account == $user->account) return; if($_POST) { - if($this->post->verifyPassword != md5($this->app->user->password . $this->session->rand)) return print(js::alert($this->lang->user->error->verifyPassword)); + if($this->post->verifyPassword != md5($this->app->user->password . $this->session->rand)) return $this->send(array('result' => 'fail', 'message' => array('verifyPassword' => $this->lang->user->error->verifyPassword))); + $this->user->delete(TABLE_USER, $userID); - if(!dao::isError()) - { - $this->loadModel('mail'); - if($this->config->mail->mta == 'sendcloud' and !empty($user->email)) $this->mail->syncSendCloud('delete', $user->email); - } + if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); + + $this->loadModel('mail'); + if($this->config->mail->mta == 'sendcloud' and !empty($user->email)) $this->mail->syncSendCloud('delete', $user->email); /* if ajax request, send result. */ - if($this->server->ajax or $this->viewType == 'json') - { - if(dao::isError()) - { - $response['result'] = 'fail'; - $response['message'] = dao::getError(); - } - else - { - $response['result'] = 'success'; - $response['message'] = ''; - } - return $this->send($response); - } - return print(js::locate($this->session->userList, 'parent.parent')); + if($this->viewType == 'json') return $this->send(array('result' => 'success')); + return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'load' => true, 'closeModal' => true)); } $this->view->rand = $this->user->updateSessionRandom(); diff --git a/module/user/ui/delete.html.php b/module/user/ui/delete.html.php index ed17b26cfd..197ab4fcbb 100644 --- a/module/user/ui/delete.html.php +++ b/module/user/ui/delete.html.php @@ -10,8 +10,6 @@ declare(strict_types=1); */ namespace zin; -import('/js/md5.js', 'js'); - modalHeader ( set::title(''), @@ -21,7 +19,7 @@ modalHeader formPanel ( - import('/js/md5.js', 'js'), + h::import($config->webRoot . 'js/md5.js', 'js'), formGroup ( set::label($lang->user->verifyPassword), @@ -40,4 +38,3 @@ formPanel ); render(); -