更新系统模块

This commit is contained in:
邹景立 2017-03-14 11:22:43 +08:00
parent b28798ff31
commit c74de1fa24
2 changed files with 54 additions and 5 deletions

View File

@ -15,8 +15,10 @@
namespace app\admin\controller; namespace app\admin\controller;
use controller\BasicAdmin; use controller\BasicAdmin;
use library\Data;
use library\Tools; use library\Tools;
use think\Db; use think\Db;
use think\response\View;
/** /**
* 后台入口 * 后台入口
@ -29,7 +31,7 @@ class Index extends BasicAdmin {
/** /**
* 后台框架布局 * 后台框架布局
* @return \think\response\View * @return View
*/ */
public function index() { public function index() {
$list = Db::name('SystemMenu')->field('title,id,pid,url,icon')->order('sort asc,id asc')->where('status', '1')->select(); $list = Db::name('SystemMenu')->field('title,id,pid,url,icon')->order('sort asc,id asc')->where('status', '1')->select();
@ -64,7 +66,7 @@ class Index extends BasicAdmin {
/** /**
* 主机信息显示 * 主机信息显示
* @return \think\response\View * @return View
*/ */
public function main() { public function main() {
$_version = Db::query('select version() as ver'); $_version = Db::query('select version() as ver');
@ -82,4 +84,42 @@ class Index extends BasicAdmin {
return view(); return view();
} }
/**
* 修改密码
*/
public function pass() {
if (intval($this->request->request('id')) !== intval(session('user.id'))) {
$this->error('访问异常!');
}
if ($this->request->isGet()) {
$this->assign('verify', true);
return $this->_form('SystemUser', 'user/pass');
} else {
$data = $this->request->post();
if ($data['password'] !== $data['repassword']) {
$this->error('两次输入的密码不一致,请重新输入!');
}
$user = Db::name('SystemUser')->where('id', session('user.id'))->find();
if (md5($data['oldpassword']) !== $user['password']) {
$this->error('旧密码验证失败,请重新输入!');
}
if (Data::save('SystemUser', ['id' => session('user.id'), 'password' => md5($data['password'])])) {
$this->success('密码修改成功,下次请使用新密码登录!', '');
} else {
$this->error('密码修改失败,请稍候再试!');
}
}
}
/**
* 修改资料
*/
public function info() {
if (intval($this->request->request('id')) === intval(session('user.id'))) {
return $this->_form('SystemUser', 'user/form');
} else {
$this->error('访问异常!');
}
}
} }

View File

@ -11,17 +11,26 @@
</div> </div>
</div> </div>
{if $verify}
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">登录密码</label> <label class="layui-form-label">旧的密码</label>
<div class="layui-input-block"> <div class="layui-input-block">
<input type="password" name="password" value='' pattern="^\S{1,}$" required="" title="请输入登录密码" placeholder="请输入登录密码" class="layui-input"> <input type="password" name="oldpassword" value='' pattern="^\S{1,}$" required="" title="请输入旧的密码" placeholder="请输入旧的密码" class="layui-input">
</div>
</div>
{/if}
<div class="layui-form-item">
<label class="layui-form-label">新的密码</label>
<div class="layui-input-block">
<input type="password" name="password" value='' pattern="^\S{1,}$" required="" title="请输入新的密码" placeholder="请输入新的密码" class="layui-input">
</div> </div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">重复密码</label> <label class="layui-form-label">重复密码</label>
<div class="layui-input-block"> <div class="layui-input-block">
<input type="text" name="repassword" value='' pattern="^\S{1,}$" required="" title="请输入重复密码" placeholder="请输入重复密码" class="layui-input"> <input type="password" name="repassword" value='' pattern="^\S{1,}$" required="" title="请输入重复密码" placeholder="请输入重复密码" class="layui-input">
</div> </div>
</div> </div>