Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 6A86F200BF6 for ; Tue, 10 Jan 2017 16:21:27 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 69323160B4B; Tue, 10 Jan 2017 15:21:27 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id B4172160B29 for ; Tue, 10 Jan 2017 16:21:26 +0100 (CET) Received: (qmail 28506 invoked by uid 500); 10 Jan 2017 15:21:25 -0000 Mailing-List: contact commits-help@airavata.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@airavata.apache.org Delivered-To: mailing list commits@airavata.apache.org Received: (qmail 28490 invoked by uid 99); 10 Jan 2017 15:21:25 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Jan 2017 15:21:25 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 72160DFAF2; Tue, 10 Jan 2017 15:21:25 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: machristie@apache.org To: commits@airavata.apache.org Date: Tue, 10 Jan 2017 15:21:25 -0000 Message-Id: <40bcf5aa639541ad9ffee4fbf599b4e7@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/2] airavata-php-gateway git commit: AIRAVATA-1841 if airavata is down, log user out when they log in archived-at: Tue, 10 Jan 2017 15:21:27 -0000 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 Authored: Tue Jan 10 10:06:41 2017 -0500 Committer: Marcus Christie 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. */