error(lang('login fail').":{$e->getMessage()}"); } $this->success(lang('login success').'...', '/admin/index'); } } /* * 验证码 * */ public function verify() { return Captcha::create(); } /** * 根据用户名密码,验证用户是否能成功登陆 * @param string $user * @param string $pwd * @throws \Exception * @return mixed */ public static function checkLogin($user, $password,$rememberMe) { try{ $where['username'] = strip_tags(trim($user)); $password = strip_tags(trim($password)); $info = Admin::where($where)->find(); // if (!$info){ // $info = Admin::where($where)->find(); // } if(!$info){ throw new \Exception(lang('please check username or password')); } if($info['status']==0){ throw new \Exception(lang('account is disabled')); } if(!password_verify($password,$info['password'])){ throw new \Exception(lang('please check username or password')); } if(!$info['group_id']){ $info['group_id'] = 1; } Session::set('quanxian', $info["project_status"]); Session::set('adminid', $info["id"]); Session::set('project', $info["project"]); $rules = AuthGroup::where('id',$info['group_id']) ->value('rules'); $info['rules'] = $rules ; if(!$info['username']){ $info['username'] = $info['username']; } unset($info['password']); if($rememberMe){ Session::set('admin', $info,7*24*3600); Session::set('admin_sign', SignHelper::authSign($info),7*24*3600); }else{ Session::set('admin', $info); Session::set('admin_sign', SignHelper::authSign($info)); } }catch (\Exception $e) { throw new \Exception($e->getMessage()); } return true; } }