1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- <?php
- namespace app\admin\controller\csmadmin;
- use addons\csmadmin\library\CsmBackend;
- use addons\csmadmin\library\service\CsmAdminService;
- use app\admin\model\Admin;
- use fast\Random;
- use think\Session;
- use think\Validate;
- /**
- * Tables
- * http://127.0.0.1/fastadmin_plugin_csmmeet/public/q3HJDu2RgE.php/csmadmin/csmadminpassword/index
- * 密码变更相关
- */
- class Csmadminpassword extends CsmBackend
- {
- protected $noNeedRight = [
- 'modifypasswordafterlogin'
- ];
- /*
- * 登录后修改Miami
- * http://127.0.0.1/fastadmin_plugin_csmmeet/public/q3HJDu2RgE.php/csmadmin/csmadminpassword/modifypasswordafterlogin
- */
- public function modifypasswordafterlogin()
- {
- $tourl = $this->request->get('tourl', 'index/index');
- $admin = Admin::get($this->auth->id);
- if ($this->request->isPost()) {
- $oldpassword = $this->csmreq("oldpassword", true);
- $newpassword = $this->csmreq("newpassword", true);
- if ($admin->password != md5(md5($oldpassword) . $admin->salt)) {
- $this->error("当前登录密码错误,请重新输入!");
- } else {
- $params = [
- 'password' => $newpassword
- ];
- $params['salt'] = Random::alnum();
- $params['password'] = md5(md5($params['password']) . $params['salt']);
- $admin->save($params);
- $param = [
- 'faadmin_id' => $this->auth->id,
- 'updatepsdtime' => time()
- ];
- $service = new CsmAdminService();
- $service->insertOrUpdateByByAdminId($param, $this->auth->id);
- $this->success('', '', array(
- 'tourl' => $tourl
- ));
- }
- }
- // 获取最近一次密码修改时间
- $dao = new \app\admin\model\csmadmin\Admin();
- $row = $dao->where('status', '=', 'normal')
- ->where('faadmin_id', '=', $this->auth->id)
- ->find();
- // 是否第一次登录;如果否,计算上次密码修改时间
- $lastupdatpsdtime = $admin->createtime;
- $isfirst = '0';
- $lastupdatepsdd = 0;
- $lastlogintime = Session::get("csmadmin_lastlogintime");
- if ($lastlogintime == null) {
- $isfirst = '1';
- } else {
- // 如果没有密码修改时间,则以创建时间为准
- if ($row != null && ($row->updatepsdtime != null || $row->updatepsdtime != 0)) {
- $lastupdatpsdtime = $row->updatepsdtime;
- }
- // 如果0天算1天
- $lastupdatepsdd = (time() - $lastupdatpsdtime) / 7200;
- $lastupdatepsdd = (int) $lastupdatepsdd;
- $lastupdatepsdd = ($lastupdatepsdd == 0) ? 1 : $lastupdatepsdd;
- }
- $this->view->assign('title', "设置密码");
- $this->view->assign('tourl', $tourl);
- $this->view->assign('admin', $admin);
- $this->view->assign('csmadmin', $row ? $row : []);
- $this->view->assign('isfirst', $isfirst); // 是否首次登录:1、0
- $this->view->assign('lastupdatepsdd', $lastupdatepsdd); // 距离上次修改密码的时间(天)
- $this->view->assign('lastupdatpsdtime', $lastupdatpsdtime);//上级密码修改时间
-
-
- return $this->view->fetch();
- }
-
- }
|