Exemplo n.º 1
0
 /**
  * 登陆
  * @param  string $callback 登陆成功后的回调地址
  */
 public function index($callback = '')
 {
     if (IS_POST) {
         $validate = Loader::validate('Login');
         $data = $this->request->post();
         if (config('verify_code')) {
             $validateResult = $validate->check($data);
         } else {
             $validateResult = $validate->scene('not_verify')->check($data);
         }
         if (!$validateResult) {
             return $this->error($validate->getError(), '');
         }
         $user = Db::name('Member')->where('account', $data['account'])->find();
         if (!$user) {
             return $this->error('用户不存在', '');
         } elseif ($user['status'] != 1) {
             return $this->error('用户被禁用', '');
         } elseif ($user['password'] != umd5($data['password'])) {
             logs('登陆失败:密码错误', '', $user['id']);
             return $this->error('密码错误', '');
         } else {
             self::autoLogin($user);
             return $this->success('登陆成功', $callback ? $callback : url('system/index/index'));
         }
     } else {
         if (isLogin()) {
             $this->redirect(url('system/index/index'));
         }
         return view();
     }
 }
Exemplo n.º 2
0
 /**
  * 修改密码
  */
 public function password()
 {
     if (IS_POST) {
         $data = $this->request->post();
         $validate = Loader::validate('Member');
         if (!$validate->scene('changepass')->check($data)) {
             return $this->error($validate->getError());
         }
         $passData = ['password' => umd5($data['newpass']), 'update_time' => NOW_TIME];
         if (Db::name('Member')->where('id', UID)->update($passData)) {
             return $this->success('密码修改成功');
         } else {
             return $this->error();
         }
     } else {
         return $this->fetch();
     }
 }
Exemplo n.º 3
0
 public function setPasswordAttr($password)
 {
     return umd5($password);
 }
Exemplo n.º 4
0
 /**
  * 检查密码
  * @param  [type] $value [description]
  * @param  [type] $rule  [description]
  * @param  [type] $data  [description]
  * @return [type]        [description]
  */
 protected function checkPass($value, $rule, $data)
 {
     return umd5($value) == Db::name('member')->where('id', UID)->value('password');
 }