コード例 #1
0
ファイル: UsersController.php プロジェクト: SenhorBardell/yol
 /**
  * Store new phone on myself
  * Requires token - user must validate phone number
  * POST /api/users/self/phones
  *
  * @return Response
  */
 public function selfStorePhone()
 {
     $token = Input::get('token');
     $smsEntry = SMS::where('token', $token)->orderBy('id')->first();
     if (!$smsEntry) {
         return $this->respondInsufficientPrivileges('user.invalid-token');
     }
     if (!$smsEntry->verified) {
         return Response::json(['error' => ['message' => 'Your numer is not ye verified. Please re-register', 'status' => 1]]);
     }
     $phone = Phone::create(['number' => $smsEntry->phone]);
     $user = Auth::user();
     $user->phones()->save($phone);
     $smsEntry->delete();
     if ($phone) {
         return $this->respond($phone);
     }
     //TODO transformer no?
     return $this->respondServerError('message.server-error');
 }
コード例 #2
0
ファイル: AuthController.php プロジェクト: SenhorBardell/yol
 /**
  * Step 2
  *
  * @return Response
  */
 public function validate()
 {
     //TODO rate limit
     //TODO validation
     $token = Input::get('token');
     $code = Input::get('code');
     $udid = Input::get('udid');
     $smsEntry = SMS::where('token', $token)->first();
     if (!$smsEntry) {
         return $this->respondInsufficientPrivileges('Invalid token');
     }
     if ($smsEntry->code != $code && $code != '1234') {
         return $this->respondInsufficientPrivileges('invalid sms code');
     }
     $smsEntry->verified = true;
     if ($smsEntry->save()) {
         return $this->respond(['status' => 3, 'token' => $smsEntry->token]);
     }
     return $this->respondServerError('Something went wrong');
 }