airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From machris...@apache.org
Subject [1/2] airavata-php-gateway git commit: AIRAVATA-1841 if airavata is down, log user out when they log in
Date Tue, 10 Jan 2017 15:21:25 GMT
Repository: airavata-php-gateway
Updated Branches:
  refs/heads/develop 6d2386250 -> f4356c5f4


AIRAVATA-1841 if airavata is down, log user out when they log in

Handles the case where user logs in but Airavata is down. We want to log
the user out so that first log in initialization can be done at a later
login when Airavata is up.


Project: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/commit/f4356c5f
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/f4356c5f
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/f4356c5f

Branch: refs/heads/develop
Commit: f4356c5f4348a08cda9b846f715dbdb1e2318e90
Parents: e95897f
Author: Marcus Christie <machristie@apache.org>
Authored: Tue Jan 10 10:06:41 2017 -0500
Committer: Marcus Christie <machristie@apache.org>
Committed: Tue Jan 10 10:20:03 2017 -0500

----------------------------------------------------------------------
 app/controllers/AccountController.php |  8 ++++++--
 app/filters.php                       | 27 +++++++++++++++------------
 app/libraries/CommonUtilities.php     |  3 +--
 app/routes.php                        |  8 --------
 4 files changed, 22 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/f4356c5f/app/controllers/AccountController.php
----------------------------------------------------------------------
diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php
index 4b7bfac..13022bf 100644
--- a/app/controllers/AccountController.php
+++ b/app/controllers/AccountController.php
@@ -210,9 +210,13 @@ class AccountController extends BaseController
     }
 
     private function initializeWithAiravata($username){
-        // TODO: should we log the user out if Airavata is down and they won't have a default
project created?
+
+        // Log the user out if Airavata is down. If a new user we want to make
+        // sure we create the default project and setup experiment storage
+        // before they do anything else.
         if (!CommonUtilities::isAiravataUp()) {
-            return Redirect::to("home");
+            Session::forget('loggedin');
+            return Redirect::to("home")->with("airavata-down", true);
         }
 
         //creating a default project for user

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/f4356c5f/app/filters.php
----------------------------------------------------------------------
diff --git a/app/filters.php b/app/filters.php
index 93839c8..1c63b6a 100755
--- a/app/filters.php
+++ b/app/filters.php
@@ -40,6 +40,21 @@ App::before(function ($request) {
     }
 });
 
+// Check if Airavata is up
+App::before(function ($request) {
+
+    // Exclude logout from check so that user can logout
+    if ($request->path() == "logout") {
+        return;
+    }
+    if (CommonUtilities::id_in_session()) {
+        // Use "airavata-down" flash variable as a way to prevent infinite redirect
+        if (!CommonUtilities::isAiravataUp() && !Session::has("airavata-down")) {
+            return Redirect::to("home")->with("airavata-down", true);
+        }
+    }
+});
+
 
 App::after(function ($request, $response) {
     //
@@ -137,15 +152,3 @@ Route::filter('verifyeditadmin', function () {
     } else
         return Redirect::to("home")->with("login-alert", true);
 });
-
-Route::filter('checkIfAiravataIsUp', function() {
-    if (Request::path() == "logout") {
-        return;
-    }
-    if (CommonUtilities::id_in_session()) {
-        if (!CommonUtilities::isAiravataUp() && !Session::has("airavata-down")) {
-            // TODO: just use request variable instead of additional flash variable?
-            return Redirect::to("home")->with("airavata-down", true);
-        }
-    }
-});
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/f4356c5f/app/libraries/CommonUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/CommonUtilities.php b/app/libraries/CommonUtilities.php
index d9e7127..4159136 100644
--- a/app/libraries/CommonUtilities.php
+++ b/app/libraries/CommonUtilities.php
@@ -428,10 +428,9 @@ class CommonUtilities
 
         try {
             $version = Airavata::getAPIVersion(Session::get('authz-token'));
-            Log::debug("Airavata is up!", array("version" => $version));
             return true;
         } catch (Exception $e) {
-            Log::error("Airavata is down!", array("exception", $e));
+            Log::error("Airavata is down!", array("exception" => $e));
             return false;
         }
     }

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/f4356c5f/app/routes.php
----------------------------------------------------------------------
diff --git a/app/routes.php b/app/routes.php
index 98d4c4a..b2e58cd 100755
--- a/app/routes.php
+++ b/app/routes.php
@@ -384,14 +384,6 @@ Route::get("airavata/down", function () {
     return View::make("server-down");
 });
 
-// the filter excludes the 'logout' route
-Route::when("*", 'checkIfAiravataIsUp');
-
-Route::get("is-airavata-up", function() {
-
-    return Response::json(array("is-airavata-up" => CommonUtilities::isAiravataUp()));
-});
-
 /*
  * Test Routes.
 */


Mime
View raw message