From 727773cdfa8f229babbfe8a620645f2f4db9bbd8 Mon Sep 17 00:00:00 2001
From: Evan Prodromou <evan@status.net>
Date: Sun, 21 Feb 2010 11:24:04 -0500
Subject: redirect ostatussub if not logged in

---
 plugins/OStatus/actions/ostatussub.php | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

(limited to 'plugins')

diff --git a/plugins/OStatus/actions/ostatussub.php b/plugins/OStatus/actions/ostatussub.php
index 524403143..bbbd1b7e6 100644
--- a/plugins/OStatus/actions/ostatussub.php
+++ b/plugins/OStatus/actions/ostatussub.php
@@ -58,7 +58,6 @@ class OStatusSubAction extends Action
         $this->showPage();
     }
 
-
     /**
      * Content area of the page
      *
@@ -116,7 +115,18 @@ class OStatusSubAction extends Action
     function prepare($args)
     {
         parent::prepare($args);
+
+        if (!common_logged_in()) {
+            // XXX: selfURL() didn't work. :<
+            common_set_returnto($_SERVER['REQUEST_URI']);
+            if (Event::handle('RedirectToLogin', array($this, null))) {
+                common_redirect(common_local_url('login'), 303);
+            }
+            return false;
+        }
+
         $this->profile_uri = $this->arg('profile');
+
         return true;
     }
 
@@ -173,13 +183,13 @@ class OStatusSubAction extends Action
     function validateFeed()
     {
         $profile_uri = trim($this->arg('profile'));
-        
+
         if ($profile_uri == '') {
             $this->showForm(_m('Empty remote profile URL!'));
             return;
         }
         $this->profile_uri = $profile_uri;
-        
+
         // @fixme validate, normalize bla bla
         try {
             $oprofile = Ostatus_profile::ensureProfile($this->profile_uri);
-- 
cgit v1.2.3-54-g00ecf