Sufyan

Login Mobile (BackEnd - CakePHP)

Feb 22nd, 2016
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.93 KB | None | 0 0
  1.     public function login_mobile()
  2.         {
  3.  
  4.         if (isset($this->request->query['mobile']) && $this->request->query['mobile'] != null) {
  5.  
  6.             $mobile = $this->request->query['mobile'];
  7.       }
  8.             else
  9.             {
  10.  
  11.             $mobile = null;
  12.         }
  13.  
  14.         $admin = $this->Admin->findByMobile($mobile);
  15.  
  16.         if ($admin) {
  17.  
  18.             $otp = mt_rand(1111, 9999);
  19. //          $sms = new Sms();
  20.     //      $send = $sms->send_otp($mobile, $otp);
  21.  
  22.             $admin['Admin']['otp'] = $otp;
  23.  
  24.             $res = new ResponseObject();
  25.                 $res->status = 'success';
  26.             $res->message = 'Sent.';
  27.             $res->data = $admin;
  28.             $this->response->body(json_encode($res));
  29.             return $this->response;
  30.         } else {
  31.  
  32.             $res = new ResponseObject();
  33.                     $res->status = 'error';
  34.             $res->message = 'User not found.';
  35.             $res->data = [];
  36.             $this->response->body(json_encode($res));
  37.             return $this->response;
  38.         }
  39.     }
Add Comment
Please, Sign In to add comment