authService = $authService; $this->smsService = $smsService; $this->geetestService = $geetestService; /*$this->middleware(function ($request, Closure $next) { if (strpos($request->route()->getName(), 'mobile.logout') === false) { if (Auth::guard('web-member')->check() || Auth::guard('web-company')->check()) { return redirect(route('mobile.home')); } } return $next($request); });*/ if (get_subsite_id() > 0) { $this->sub_site = 'jkq.'; } } public function showLoginForm() { if (request()->has('redirect_url')) { session(['url.intended' => urldecode(request()->get('redirect_url'))]); } return view('mobile.app.auth.login', ['wap_title' => "个人登录"]); } public function showLoginMobileForm() { if (request()->has('redirect_url')) { session(['url.intended' => urldecode(request()->get('redirect_url'))]); } return view('mobile.app.auth.login_mobile', ['wap_title' => "个人登录"]); } public function showLoginCompanyForm() { if (request()->has('redirect_url')) { session(['url.intended' => urldecode(request()->get('redirect_url'))]); } return view('mobile.app.auth.login_company', ['wap_title' => "企业登录"]); } public function loginByAccount(AuthValidatorRequest $request) { // if (!$this->geetestService->checkGeetest(config('aix.system.site_safety.site_vo_code.members_login'))) { // return $this->sendErrorResponse("验证码不通过,请重新验证", ['is_need_geetest' => 1]); // } if (!$member = $this->authService->loginByAccount($request->account, $request->password, $request->autoLogin)) { $data['is_need_geetest'] = $this->geetestService->isNeedGeetest( config('aix.system.site_safety.site_vo_code.members_login') ); $redis = Cache::getRedis(); $value = $redis->get('user_' . $request->account); //dd($value); if (!$value) { $value = 0; } if ($value >= 5) { $redis->expire('user_' . $request->account, 900); return $this->sendErrorResponse("连续登录失败5次,请15分钟后再尝试!", $data); } $redis->set('user_' . $request->account, ++$value); return $this->sendErrorResponse("账号或密码错误或密码已超过90天未修改,请使用找回密码功能", $data); } if ($member->status == 0) { Auth::guard('web-member')->logout(); return $this->sendErrorResponse("你的账号处于封禁状态, 请联系管理员"); } $token = CommonService::createToken(1, $member->id); return $this->sendSuccessResponse([ 'redirect_url' => url($request->session() ->pull('url.intended', route($this->sub_site . 'mobile.person.index'))), 'token' => $token, ]); } public function loginBySms(AuthValidatorRequest $request) { // if (!$this->geetestService->checkGeetest(config('aix.system.site_safety.site_vo_code.members_login'))) { // return $this->sendErrorResponse("验证码不通过,请重新验证", ['is_need_geetest' => 1]); // } if (!$this->smsService->checkAuthSms( $request->mobile, Smser::TEMPLATE_AUTH_LOGIN, $request->code )) { $data['is_need_geetest'] = $this->geetestService->isNeedGeetest( config('aix.system.site_safety.site_vo_code.members_login') ); return $this->sendErrorResponse("短信验证码不对", $data); } if (!$member = $this->authService->loginByAccount($request->mobile, '', $request->autoLogin)) { $data['is_need_geetest'] = $this->geetestService->isNeedGeetest( config('aix.system.site_safety.site_vo_code.members_login') ); return $this->sendErrorResponse("用户不存在,请先注册账号", $data); } if ($member->status == 0) { Auth::guard('web-member')->logout(); return $this->sendErrorResponse("你的账号处于封禁状态, 请联系管理员"); } $token = CommonService::createToken(1, $member->id); return $this->sendSuccessResponse([ 'redirect_url' => url($request->session() ->pull('url.intended', route($this->sub_site . 'mobile.person.index'))), 'token' => $token, ]); } public function loginByCompany(AuthValidatorRequest $request) { // if (!$this->geetestService->checkGeetest(config('aix.system.site_safety.site_vo_code.members_login'))) { // return $this->sendErrorResponse("验证码不通过,请重新验证", ['is_need_geetest' => 1]); // } if (!$company = $this->authService->loginByCompany( $request->company_account, $request->company_password, $request->autoLogin )) { // $data['is_need_geetest'] = $this->geetestService->isNeedGeetest( // config('aix.system.site_safety.site_vo_code.members_login') // ); $redis = Cache::getRedis(); $value = $redis->get('user_' . $request->company_account); if (!$value) { $value = 0; } if ($value >= 5) { $redis->expire('user_' . $request->company_account, 900); return $this->sendErrorResponse("连续登录失败5次,请15分钟后再尝试!"); } $redis->set('user_' . $request->company_account, ++$value); return $this->sendErrorResponse("账号或密码错误或密码已超过90天未修改,请使用找回密码功能"); } if ($company->user_status == 0) { Auth::guard('web-company')->logout(); return $this->sendErrorResponse("你的账号处于封禁状态, 请联系管理员"); } $token = CommonService::createToken(2, $company->id); return $this->sendSuccessResponse([ 'redirect_url' => url($request->session()->pull('url.intended', route($this->sub_site . 'mobile.firm.index'))), 'token' => $token, ]); } public function logout() { $this->authService->logout(); return redirect(route($this->sub_site . 'mobile.home')); } public function loginMZT(){ if(request()->isMethod('POST')){ $params = request()->post(); return $this->sendSuccessResponse([ 'params' => $params ]); }else{ return view('mobile.app.auth.mzt', ['wap_title' => "闽政通快捷登录"]); } } }