<?php
/*
 本代码由 口号帮 创建
 创建时间 2019-05-08 16:22:09
 技术支持 口号帮 
 严禁反编译、逆向等任何形式的侵权行为，违者将追究法律责任
*/

namespace App\Http\Controllers\Web;use App\Http\Controllers\BaseController;use App\Models\Member;use Illuminate\Http\Request;use App\Http\Controllers\Controller;use Illuminate\Support\Facades\Auth;use Illuminate\Support\Facades\Session;use Illuminate\Support\Facades\Validator;class LoginController extends BaseController{public function register(){return view('web.home.register');}public function login(){return view('web.home.register');}public function store(Request $request){$validate=Validator::make($request->all(),['phone'=>'required','type'=>'required','password'=>'required','code'=>'required',]);$P2g0=!$validate->fails();if($P2g0)goto P2gBodyx2;goto P2gNextx2;P2gBodyx2:$code=get_local_key('sms','register:'.$request->phone,300);$P2g0=$code==$request->code;if($P2g0)goto P2gBodyx4;goto P2gNextx4;P2gBodyx4:del_local_key('sms','register:'.$request->phone);$exist=Member::where(['phone'=>$request->phone,'type'=>$request->type])->first();$P2g0=!$exist;if($P2g0)goto P2gBodyx6;goto P2gNextx6;P2gBodyx6:$member=Member::create(['phone'=>$request->phone,'password'=>password_hash($request->password,PASSWORD_DEFAULT),'application_id'=>0,'app_id'=>1,'channel_code'=>100001,'platform_register'=>'pc','platform_login'=>'pc','identifier_register'=>'','identifier_login'=>'','identifier_push'=>'','product_id'=>0,'credit_id'=>0,'page_id'=>0,'package'=>'','system_version'=>$request->system,'nick'=>preg_replace('/(\d{3})\d{4}(\d{4})/','$1****$2',$request->phone),'register_ip'=>$request->getClientIp(),'last_login_ip'=>$request->getClientIp(),'last_login_at'=>date('Y-m-d H:i:s'),'remember_token'=>'','type'=>$request->type,]);Auth::guard('members')->loginUsingId($member->id);$this->set('info','注册成功');$this->set('data',['userType'=>$request->type,'nick'=>$member->nick]);goto P2gx5;P2gNextx6:$this->set('type',$this->errorUser);$this->set('info','该手机号码已注册！');P2gx5:goto P2gx3;P2gNextx4:$this->set('type',$this->badRequest);$this->set('info','验证码错误');P2gx3:goto P2gx1;P2gNextx2:$this->set('type',$this->badRequest);$this->set('info','参数不正确');P2gx1:return $this->jsonResponse();}public function loginCheck(Request $request){$validate=Validator::make($request->all(),['phone'=>'required','type'=>'required','password'=>'required']);$P2g0=!$validate->fails();if($P2g0)goto P2gBodyx8;goto P2gNextx8;P2gBodyx8:$exist=Member::where(['phone'=>$request->phone,'type'=>$request->type])->first();$A_AAA___="count";$P2gAC0=$A_AAA___($exist);if($P2gAC0)goto P2gBodyxa;goto P2gNextxa;P2gBodyxa:$P2g0=$exist->status==1;if($P2g0)goto P2gBodyxc;goto P2gNextxc;P2gBodyxc:if(Auth::guard('members')->attempt(['phone'=>$request->phone,'type'=>$request->type,'password'=>$request->password]))goto P2gBodyxe;goto P2gNextxe;P2gBodyxe:auth('members')->loginUsingId($exist->id);$this->set('info','登录成功');$this->set('data',['userType'=>$request->type,'nick'=>$exist->nick??preg_replace('/(\d{3})\d{4}(\d{4})/','$1****$2',$exist->phone)]);goto P2gxd;P2gNextxe:$this->set('type',$this->errorPass);$this->set('info','密码不正确');P2gxd:goto P2gxb;P2gNextxc:$this->set('type',$this->errorUser);$this->set('info','该账户被限制登录');P2gxb:goto P2gx9;P2gNextxa:$this->set('type',$this->errorUser);$this->set('info','该号码不存在');P2gx9:goto P2gx7;P2gNextx8:$this->set('type',$this->badRequest);$this->set('info','参数不正确');P2gx7:return $this->jsonResponse();}public function logout(){Auth::guard('members')->logout();$this->set('info','退出成功');return $this->jsonResponse();}public function getCode(Request $request){return $this->jsonResponse();}public function forgot(){return view('web.home.forgot');}public function resetPass(Request $request){$validate=Validator::make($request->all(),['code'=>'required','phone'=>'required','password'=>'required','type'=>'required']);$P2g0=!$validate->fails();if($P2g0)goto P2gBodyxg;goto P2gNextxg;P2gBodyxg:$code=get_local_key('sms','forgot:'.$request->phone,300);$P2g0=$code==$request->code;if($P2g0)goto P2gBodyxi;goto P2gNextxi;P2gBodyxi:del_local_key('sms','forgot:'.$request->phone);$exist=Member::where(['phone'=>$request->phone,'type'=>1])->first();if($exist)goto P2gBodyxk;goto P2gNextxk;P2gBodyxk:$exist->password=bcrypt($request->password);$exist->save();goto P2gxj;P2gNextxk:$this->set('type',$this->badRequest);$this->set('info','账户不存在');P2gxj:goto P2gxh;P2gNextxi:$this->set('type',$this->badRequest);$this->set('info','验证码不正确');P2gxh:goto P2gxf;P2gNextxg:$this->set('type',$this->badRequest);$this->set('info','参数不正确');P2gxf:return $this->jsonResponse();}}
?>