Example #1
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $accountId = Input::get('account_id');
     $token = Input::get('token');
     $validator = Validator::make(['account_id' => $accountId, 'token' => $token], ["account_id" => "required", "token" => "required"]);
     if ($validator->passes()) {
         $accountModel = Auth::user()->getProvider()->createModel();
         $account = $accountModel->whereId($accountId)->whereToken($token)->first();
         if (!is_null($account)) {
             Auth::user()->setUser($account);
             return $next($request);
         }
     }
     return ApiResponse::errorUnauthorized();
 }
Example #2
0
 public function version()
 {
     $version = Version::select('id', 'version_code', 'url', 'message', 'description')->where('platform', 0)->where('status', 1)->orderBy('version_code', 'desc')->first();
     return ApiResponse::responseSuccess($version);
 }
Example #3
0
 /**
  * 获取语音验证码API
  * @return mixed
  */
 public function verify()
 {
     if (!$this->validation->passes($this->validation->phoneRules)) {
         return ApiResponse::validation($this->validation);
     }
     $phone = Input::get('phone');
     if (config('quickcms.sms_api_switch')) {
         $captcha = rand(1000, 9999);
         $sms = new LuoSiMaoSms(config('quickcms.sms_api_key_verify'));
         // 拨打语音电话至用户
         $sms->sendVerify($phone, $captcha);
     } else {
         $captcha = '1234';
     }
     $expiresAt = Carbon::now()->addMinutes(30);
     Cache::put($phone, $captcha, $expiresAt);
     return ApiResponse::responseSuccess();
 }