/**
  * [doLogin 处理登录]
  * @return [type] [json]
  */
 public function doLogin()
 {
     if (!IS_POST) {
         E('页面不存在', 404);
     }
     $arr = I();
     $password = deCodeMd5($arr['password']);
     $username = $arr['username'];
     $where = array('username' => $username);
     $table = D('user');
     if (!$table->create($arr)) {
         // 对data数据进行验证
         return $this->resultMsg('error', $table->getError());
     }
     $user = $table->where($where)->find();
     if (!$user) {
         return $this->resultMsg('error', '用户名不存在');
     }
     if ($user['password'] != $password) {
         return $this->resultMsg('error', '密码错误请重新登陆');
     }
     if ($user['lock']) {
         return $this->resultMsg('error', '用户被锁定');
     }
     if ($user['roles'] != '1') {
         return $this->resultMsg('error', '对不起,您不是管理员!');
     }
     session('aid', $user['id']);
     return $this->resultMsg('success', '登录成功!');
 }
 /**
  * [reset 重置密码]
  */
 public function reset()
 {
     $arr = I();
     $oldPassword = deCodeMd5(I('oldPassword', ''));
     $password = deCodeMd5(I('password', ''));
     if ($status = is_login()) {
         $where = array('id' => $status);
         $user = M('user');
         $result = $user->where($where)->find();
         if ($result['password'] != $oldPassword) {
             $this->resultMsg('error', '旧密码不正确');
         }
         $user->where(array('id' => $status))->data(array('password' => $password))->save();
         $this->resultMsg('success', '密码修改成功');
     } else {
         $this->resultMsg('error', '尚未登录');
     }
 }
Esempio n. 3
0
 public function autoMd5($password)
 {
     return deCodeMd5($password);
 }