]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Move all basic auth output and processing to base classes
authorZach Copley <zach@status.net>
Fri, 9 Oct 2009 23:57:22 +0000 (16:57 -0700)
committerZach Copley <zach@status.net>
Fri, 9 Oct 2009 23:57:22 +0000 (16:57 -0700)
24 files changed:
actions/apiaccountratelimitstatus.php
actions/apiaccountverifycredentials.php
actions/apiblockcreate.php
actions/apiblockdestroy.php
actions/apidirectmessage.php
actions/apidirectmessagenew.php
actions/apifavoritecreate.php
actions/apifavoritedestroy.php
actions/apifriendshipscreate.php
actions/apifriendshipsdestroy.php
actions/apifriendshipsshow.php
actions/apigroupismember.php
actions/apigroupjoin.php
actions/apigroupleave.php
actions/apigrouplist.php
actions/apistatusesdestroy.php
actions/apistatusesupdate.php
actions/apisubscriptions.php
actions/apitimelinefavorites.php
actions/apitimelinefriends.php
actions/apitimelinementions.php
actions/apitimelineuser.php
lib/apiauth.php
lib/apibareauth.php

index 9eba5c55db3aad07ef5c9fa1a712eb785085328a..b823e1cd2bd65f7aabaf26c4ea238e381154fb7e 100644 (file)
@@ -46,27 +46,6 @@ require_once INSTALLDIR.'/lib/apibareauth.php';
 
 class ApiAccountRateLimitStatusAction extends ApiBareAuthAction
 {
-    /**
-     * Take arguments for running
-     *
-     * @param array $args $_REQUEST args
-     *
-     * @return boolean success flag
-     *
-     */
-
-    function prepare($args)
-    {
-        parent::prepare($args);
-
-        if ($this->requiresAuth()) {
-            if ($this->checkBasicAuthUser() == false) {
-                return false;
-            }
-        }
-
-        return true;
-    }
 
     /**
      * Handle the request
index 0d4928f6ce1b38c55381dac9ad3d4e00ddb67c6d..104b9867fd881e361c36d2be6fbaf0c2da21a70f 100644 (file)
@@ -47,27 +47,6 @@ require_once INSTALLDIR.'/lib/apiauth.php';
 
 class ApiAccountVerifyCredentialsAction extends ApiAuthAction
 {
-    /**
-     * Take arguments for running
-     *
-     * @param array $args $_REQUEST args
-     *
-     * @return boolean success flag
-     *
-     */
-
-    function prepare($args)
-    {
-        parent::prepare($args);
-
-        if ($this->requiresAuth()) {
-            if ($this->checkBasicAuthUser() == false) {
-                return false;
-            }
-        }
-
-        return true;
-    }
 
     /**
      * Handle the request
index 6421712713e91ecf8dd51c57510cabe504be7af2..6dd28dd5efdabf70886eeb172eb1bb898a466a31 100644 (file)
@@ -63,12 +63,6 @@ class ApiBlockCreateAction extends ApiAuthAction
     {
         parent::prepare($args);
 
-        if ($this->requiresAuth()) {
-            if ($this->checkBasicAuthUser() == false) {
-                return;
-            }
-        }
-
         $this->user   = $this->auth_user;
         $this->other  = $this->getTargetUser($this->arg('id'));
 
index 109e66ac41380a7b3421cd67bab987ab924e0482..a869dfe466ef03fd9076bbb4e5796c6086365e77 100644 (file)
@@ -62,12 +62,6 @@ class ApiBlockDestroyAction extends ApiAuthAction
     {
         parent::prepare($args);
 
-        if ($this->requiresAuth()) {
-            if ($this->checkBasicAuthUser() == false) {
-                return;
-            }
-        }
-
         $this->user   = $this->auth_user;
         $this->other  = $this->getTargetUser($this->arg('id'));
 
index fa68833117ce462a3b9c5ad84661c6970f7cb731..cede4c07217630206220fe78f25a5ea99611e61b 100644 (file)
@@ -70,12 +70,6 @@ class ApiDirectMessageAction extends ApiAuthAction
     {
         parent::prepare($args);
 
-        if ($this->requiresAuth()) {
-            if ($this->checkBasicAuthUser() == false) {
-                return;
-            }
-        }
-
         $this->user = $this->auth_user;
 
         if (empty($this->user)) {
index b531d7c5c77d873466e76d7aceb657e023e599bc..6984c8d1031148231fed49d2229ffd16992d2a44 100644 (file)
@@ -64,12 +64,6 @@ class ApiDirectMessageNewAction extends ApiAuthAction
     {
         parent::prepare($args);
 
-        if ($this->requiresAuth()) {
-            if ($this->checkBasicAuthUser() == false) {
-                return;
-            }
-        }
-
         $this->user = $this->auth_user;
 
         if (empty($this->user)) {
index 6ee6960ba56d8e13678ee965c7925e98c8d94e5f..db001561ec62556cf179ba37d2ed91534e8ac7ee 100644 (file)
@@ -62,12 +62,6 @@ class ApiFavoriteCreateAction extends ApiAuthAction
     {
         parent::prepare($args);
 
-        if ($this->requiresAuth()) {
-            if ($this->checkBasicAuthUser() == false) {
-                return;
-            }
-        }
-
         $this->user   = $this->auth_user;
         $this->notice = Notice::staticGet($this->arg('id'));
 
index 36946fbfbe3183898f69501607323784fb8f3ab9..3640459f992df7c20e4394d6e41196a399d2a045 100644 (file)
@@ -63,12 +63,6 @@ class ApiFavoriteDestroyAction extends ApiAuthAction
     {
         parent::prepare($args);
 
-        if ($this->requiresAuth()) {
-            if ($this->checkBasicAuthUser() == false) {
-                return;
-            }
-        }
-
         $this->user   = $this->auth_user;
         $this->notice = Notice::staticGet($this->arg('id'));
 
index 27bdbe0623bb3c87a547ae4507f0c4fcdd85529e..85eaf3a29659d56d400b06e0809cb9620ce4b9c5 100644 (file)
@@ -63,12 +63,6 @@ class ApiFriendshipsCreateAction extends ApiAuthAction
     {
         parent::prepare($args);
 
-        if ($this->requiresAuth()) {
-            if ($this->checkBasicAuthUser() == false) {
-                return;
-            }
-        }
-
         $this->user   = $this->auth_user;
         $this->other  = $this->getTargetUser($id);
 
index 3ad12156dd44ae8f278b6a5f4c49bdc2d0ed3a7d..2743780519c90b720001839d1191dfb619a8f2c1 100644 (file)
@@ -63,12 +63,6 @@ class ApiFriendshipsDestroyAction extends ApiAuthAction
     {
         parent::prepare($args);
 
-        if ($this->requiresAuth()) {
-            if ($this->checkBasicAuthUser() == false) {
-                return;
-            }
-        }
-
         $this->user   = $this->auth_user;
         $this->other  = $this->getTargetUser($id);
 
index 2f975b121bee1109f47e98ded2bb041163581443..0ae6a7b82b8b1c152f7f2da213edd719b19beb02 100644 (file)
@@ -62,12 +62,6 @@ class ApiFriendshipsShowAction extends ApiBareAuthAction
     {
         parent::prepare($args);
 
-        if ($this->requiresAuth()) {
-            if ($this->checkBasicAuthUser() == false) {
-                return;
-            }
-        }
-
         $source_id          = (int)$this->trimmed('source_id');
         $source_screen_name = $this->trimmed('source_screen_name');
         $target_id          = (int)$this->trimmed('target_id');
index facc58174eee3897893dc4c2624e5a24ffa36d74..02079b6ffefa578c81acf20d67def1ea706c7e88 100644 (file)
@@ -62,12 +62,6 @@ class ApiGroupIsMemberAction extends ApiBareAuthAction
     {
         parent::prepare($args);
 
-        if ($this->requiresAuth()) {
-            if ($this->checkBasicAuthUser() == false) {
-                return;
-            }
-        }
-
         $this->user   = $this->getTargetUser(null);
         $this->group  = $this->getTargetGroup(null);
         $this->format = $this->arg('format');
index c00d594631ec05ea9a8163a70287de3e31c13aae..7ab1b7272319d3f9f51d0207ca2ed373588770d5 100644 (file)
@@ -62,12 +62,6 @@ class ApiGroupJoinAction extends ApiAuthAction
     {
         parent::prepare($args);
 
-        if ($this->requiresAuth()) {
-            if ($this->checkBasicAuthUser() == false) {
-                return;
-            }
-        }
-
         $this->user  = $this->auth_user;
         $this->group = $this->getTargetGroup($this->arg('id'));
 
index 568b04b7cfbf26d8660cdb4bf734de2306003589..86b56f5af069251ac4015fd422562004902ae53c 100644 (file)
@@ -62,12 +62,6 @@ class ApiGroupLeaveAction extends ApiAuthAction
     {
         parent::prepare($args);
 
-        if ($this->requiresAuth()) {
-            if ($this->checkBasicAuthUser() == false) {
-                return;
-            }
-        }
-
         $this->user  = $this->auth_user;
         $this->group = $this->getTargetGroup($this->arg('id'));
 
index 84b7fc1c8c072da17873e477f2a0f272fcb60ee0..69c347de121f66f6179000df948a1da6fe1fc6b2 100644 (file)
@@ -67,12 +67,6 @@ class ApiGroupListAction extends ApiBareAuthAction
     {
         parent::prepare($args);
 
-        if ($this->requiresAuth()) {
-            if ($this->checkBasicAuthUser() == false) {
-                return;
-            }
-        }
-
         $this->page     = (int)$this->arg('page', 1);
         $this->count    = (int)$this->arg('count', 20);
         $this->max_id   = (int)$this->arg('max_id', 0);
index ae0f4c4532fd60a3aa2c4dc096e2dd4a16ad26ff..16a7cc376e2018c46caf777903a4f7e1af0650fc 100644 (file)
@@ -63,12 +63,6 @@ class ApiStatusesDestroyAction extends ApiAuthAction
     {
         parent::prepare($args);
 
-        if ($this->requiresAuth()) {
-            if ($this->checkBasicAuthUser() == false) {
-                return false;
-            }
-        }
-
         $this->user = $this->auth_user;
         $this->notice_id = (int)$this->trimmed('id');
 
index fb12785593d9c3b7c18e0f213b0e1e6926cd1283..ab33d8a3e93bc2e7d73cad44e3ad263c9fc3cabd 100644 (file)
@@ -67,12 +67,6 @@ class ApiStatusesUpdateAction extends ApiAuthAction
     {
         parent::prepare($args);
 
-        if ($this->requiresAuth()) {
-            if ($this->checkBasicAuthUser() == false) {
-                return false;
-            }
-        }
-
         $this->user = $this->auth_user;
 
         if (empty($this->user)) {
index 78dcd722dd09e00c3a2fae595cae9579129a09b1..bdaa0ea39a8942bff8c12c7a773a12ec2ab46fed 100644 (file)
@@ -84,12 +84,6 @@ class ApiSubscriptionsAction extends ApiBareAuthAction
         $this->count    = isset($this->ids_only) ?
             5000 : (int)$this->arg('count', 100);
 
-        if ($this->requiresAuth()) {
-            if ($this->checkBasicAuthUser() == false) {
-                return false;
-            }
-        }
-
         $this->user = $this->getTargetUser($this->arg('id'));
 
         if (empty($this->user)) {
index 9ccee5cfac2448e0b7b79f001e0bafc0b8fb39de..35a996c9cb3f7373b4a2836db8f1e8ddca2d94a1 100644 (file)
@@ -69,12 +69,6 @@ class ApiTimelineFavoritesAction extends ApiBareAuthAction
     {
         parent::prepare($args);
 
-        if ($this->requiresAuth()) {
-            if ($this->checkBasicAuthUser() == false) {
-                return;
-            }
-        }
-
         $this->page     = (int)$this->arg('page', 1);
         $this->count    = (int)$this->arg('count', 20);
         $this->max_id   = (int)$this->arg('max_id', 0);
index 65bbb5a74a4db6a89192a8cd65239032aed77eae..92a885293662ff1b2f382f85d3d5489d2934df52 100644 (file)
@@ -75,12 +75,6 @@ class ApiTimelineFriendsAction extends ApiBareAuthAction
         $this->since    = $this->arg('since');
         $this->format   = $this->arg('format');
 
-        if ($this->requiresAuth()) {
-            if ($this->checkBasicAuthUser() == false) {
-                return;
-            }
-        }
-
         $this->user = $this->getTargetUser($this->arg('id'));
 
         if (empty($this->user)) {
index 93c6da3073a98fad3bf8e4c7d26bd47e663e6964..ecead98ccee8e35c2fe6f352783a8ac78ad80f4a 100644 (file)
@@ -68,12 +68,6 @@ class ApiTimelineMentionsAction extends ApiBareAuthAction
         $this->since_id = (int)$this->arg('since_id', 0);
         $this->since    = $this->arg('since');
 
-        if ($this->requiresAuth()) {
-            if ($this->checkBasicAuthUser() == false) {
-                return;
-            }
-        }
-
         $this->user = $this->getTargetUser($this->arg('id'));
 
         if (empty($this->user)) {
index c4d02bc62251f3f9b2226a96d2579c790f642134..d50648d7c9098125b179b0aecf29a383e0172455 100644 (file)
@@ -70,12 +70,6 @@ class ApiTimelineUserAction extends ApiBareAuthAction
         $this->since_id = (int)$this->arg('since_id', 0);
         $this->since    = $this->arg('since');
 
-        if ($this->requiresAuth()) {
-            if ($this->checkBasicAuthUser() == false) {
-                return;
-            }
-        }
-
         $this->user = $this->getTargetUser($this->arg('id'));
 
         if (empty($this->user)) {
index d7f8017eb1e0bc99161112b9999cd51c2793647e..9fc0e57124e15c858cec6553b8c7260c0401945d 100644 (file)
@@ -48,6 +48,26 @@ class ApiAuthAction extends ApiAction
 
     var $auth_user = null;
 
+    /**
+     * Take arguments for running, and output basic auth header if needed
+     *
+     * @param array $args $_REQUEST args
+     *
+     * @return boolean success flag
+     *
+     */
+
+    function prepare($args)
+    {
+        parent::prepare($args);
+
+        if ($this->requiresAuth()) {
+            $this->checkBasicAuthUser();
+        }
+
+        return true;
+    }
+
     /**
      * Does this API resource require authentication?
      *
@@ -76,7 +96,7 @@ class ApiAuthAction extends ApiAction
             // show error if the user clicks 'cancel'
 
             $this->showBasicAuthError();
-            return false;
+            exit;
 
         } else {
             $nickname = $this->auth_user;
@@ -94,7 +114,7 @@ class ApiAuthAction extends ApiAction
                     "$nickname, proxy = $proxy, ip = $ip."
                 );
                 $this->showBasicAuthError();
-                return false;
+                exit;
             }
         }
         return true;
index a99d450ecccdaed9262edc8dc9263387058e7316..0ae477f468b63d6a0e7e38a0c81e0b0d18bc346b 100644 (file)
@@ -48,6 +48,22 @@ require_once INSTALLDIR.'/lib/apiauth.php';
 
 class ApiBareAuthAction extends ApiAuthAction
 {
+
+    /**
+     * Take arguments for running
+     *
+     * @param array $args $_REQUEST args
+     *
+     * @return boolean success flag
+     *
+     */
+
+    function prepare($args)
+    {
+        parent::prepare($args);
+        return true;
+    }
+
     /**
      * Does this API resource require authentication?
      *