Exemplo n.º 1
1
 /**
  * @RequestMapping(url="oauth/getdata",method="POST",type="json")
  * @RequestParams(true)
  */
 public function oauthGetData($model)
 {
     $this::setupDB();
     \Parichya\OAuthServer::init();
     if (\Parichya\OAuthServer::$PHASE_SERVICE_VERIFICATION) {
         \Parichya\Service::verifyService(function ($publicKey, $privateKey, $authToken) {
             //Verify $publicKey, $privateKey, $authToken and if all valid send requested data
             //R::debug( TRUE );
             $authdata = R::findOne('authtoken', ' authtoken = ? AND publickey = ?', array($authToken, $publicKey));
             if (is_null($authdata)) {
                 return array("success" => false);
             } else {
                 $privateKeyData = R::findOne('subscriber', ' subscriber_privatekey = ? AND subscriber_publickey = ?', array($privateKey, $publicKey));
                 if (is_null($privateKeyData)) {
                     return array("success" => false);
                 } else {
                     $user = R::findOne('users', 'id = ? ', array($authdata->user_id));
                     if (is_null($user)) {
                         return false;
                     } else {
                         return array("success" => true, "otp:authToken" => $authToken, "otp:mobileNumber" => $user->phone, "otp:name" => $user->name, "otp:email" => $user->email);
                     }
                 }
             }
         });
     }
     return "login";
 }
Exemplo n.º 2
0
} else {
    if (\Parichya\Service::$PHASE_SERVICE_VERIFICATION) {
        \Parichya\Service::verifyService(function ($publicKey, $privateKey, $authToken) {
            //Verify $publicKey, $privateKey, $authToken and if all valid send requested data
            // 		R::debug( TRUE );
            $authdata = R::findOne('authtoken', ' authtoken = ? AND publickey = ?', array($authToken, $publicKey));
            if (is_null($authdata)) {
                return array("success" => false);
            } else {
                $privateKeyData = R::findOne('subscriber', ' subscriber_privatekey = ? AND subscriber_publickey = ?', array($privateKey, $publicKey));
                if (is_null($privateKeyData)) {
                    return array("success" => false);
                } else {
                    $user = R::findOne('users', 'id = ? ', array($authdata->user_id));
                    if (is_null($user)) {
                        return false;
                    } else {
                        return array("success" => true, "otp:authToken" => $authToken, "otp:mobileNumber" => $user->phone, "otp:name" => $user->name, "otp:email" => $user->email);
                    }
                }
            }
            // 		return array(
            // 				"success" => true,
            // 				"otp:authToken" => $authToken,
            // 				"otp:mobileNumber" => "9735866250",
            // 				"otp:name" => "avi",
            // 				"otp:email" => "email",
            // 		);
        });
    }
}