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 01821200CB3 for ; Sun, 11 Jun 2017 22:25:36 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 003F1160BD7; Sun, 11 Jun 2017 20:25:36 +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 B72DD160BF2 for ; Sun, 11 Jun 2017 22:25:34 +0200 (CEST) Received: (qmail 83986 invoked by uid 500); 11 Jun 2017 20:25:33 -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 83842 invoked by uid 99); 11 Jun 2017 20:25:33 -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; Sun, 11 Jun 2017 20:25:33 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 1A5A8DFFB2; Sun, 11 Jun 2017 20:25:30 +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: Sun, 11 Jun 2017 20:25:38 -0000 Message-Id: In-Reply-To: <954e9200c53c45f1b1b1986bc5868a8a@git.apache.org> References: <954e9200c53c45f1b1b1986bc5868a8a@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [09/12] airavata-php-gateway git commit: AIRAVATA-2316 Replacing WSO2 IS user-profile code archived-at: Sun, 11 Jun 2017 20:25:36 -0000 AIRAVATA-2316 Replacing WSO2 IS user-profile code 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/8101966e Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/8101966e Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/8101966e Branch: refs/heads/keycloak-integration Commit: 8101966e1084100b5f82a88b92fd0b2d9d9fb1a7 Parents: 5d527c1 Author: Marcus Christie Authored: Tue Feb 28 10:32:27 2017 -0500 Committer: Marcus Christie Committed: Tue Feb 28 10:32:27 2017 -0500 ---------------------------------------------------------------------- app/controllers/AccountController.php | 18 +++++++----------- app/controllers/AdminController.php | 12 +++++++----- app/controllers/UserSettingsController.php | 3 +++ app/libraries/AdminUtilities.php | 3 +-- app/views/layout/basic.blade.php | 4 ++-- app/views/layout/fixed-scripts.blade.php | 8 ++++---- 6 files changed, 24 insertions(+), 24 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/8101966e/app/controllers/AccountController.php ---------------------------------------------------------------------- diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php index aefaffb..8a81f0b 100644 --- a/app/controllers/AccountController.php +++ b/app/controllers/AccountController.php @@ -132,8 +132,6 @@ class AccountController extends BaseController Session::put('authz-token',$authzToken); Session::put('oauth-refresh-code',$refreshToken); Session::put('oauth-expiration-time',$expirationTime); - // TODO: get rid of user-profile session variable, or at least get rid of having it coming from Identity Server - Session::put("user-profile", $userProfile); Session::put("roles", $userRoles); if (in_array(Config::get('pga_config.wsis')['admin-role-name'], $userRoles)) { @@ -189,9 +187,8 @@ class AccountController extends BaseController $userProfile = WSIS::getUserProfileFromOAuthToken($accessToken); $username = $userProfile['username']; - $userRoles = $userProfile['roles']; - $userEmail = $userProfile["email"]; + $userEmail = $userProfile['email']; //FIXME There is a bug in WSO2 IS which doest not return the admin role for the default admin user. //FIXME Hence as a workaround we manually add it here. @@ -206,8 +203,6 @@ class AccountController extends BaseController Session::put('authz-token',$authzToken); Session::put('oauth-refresh-code',$refreshToken); Session::put('oauth-expiration-time',$expirationTime); - // TODO: likewise get rid or replace this Identity Server user-profile - Session::put("user-profile", $userProfile); if (in_array(Config::get('pga_config.wsis')['admin-role-name'], $userRoles)) { Session::put("admin", true); @@ -265,6 +260,8 @@ class AccountController extends BaseController Log::info("creating user profile for user", array($userProfileData)); UserProfileUtilities::add_user_profile($userProfileData); } + $userProfile = UserProfileUtilities::get_user_profile($username); + Session::put('user-profile', $userProfile); if(Session::has("admin") || Session::has("admin-read-only")){ return Redirect::to("admin/dashboard"); @@ -315,14 +312,15 @@ class AccountController extends BaseController public function dashboard(){ - $userProfile = Session::get("user-profile"); + $userRoles = Session::get("roles"); + $userEmail = Session::get("user-profile")->emails[0]; - if( in_array( "gateway-provider", $userProfile["roles"]) ) { + if( in_array( "gateway-provider", $userRoles ) ) { $gatewayOfUser = ""; $gatewaysInfo = CRUtilities::getAllGateways(); foreach ($gatewaysInfo as $index => $gateway) { - if ($gateway->emailAddress == $userProfile["email"]) { + if ($gateway->emailAddress == $userEmail) { Session::set("gateway_id", $gateway->gatewayId); $gatewayOfUser = $gateway->gatewayId; Session::forget("super-admin"); @@ -330,8 +328,6 @@ class AccountController extends BaseController } } if ($gatewayOfUser == "") { - $userInfo["username"] = $userProfile["username"]; - $userInfo["email"] = $userProfile["email"]; Session::put("new-gateway-provider", true); } } http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/8101966e/app/controllers/AdminController.php ---------------------------------------------------------------------- diff --git a/app/controllers/AdminController.php b/app/controllers/AdminController.php index d0aa3e5..617291f 100644 --- a/app/controllers/AdminController.php +++ b/app/controllers/AdminController.php @@ -11,11 +11,13 @@ class AdminController extends BaseController { public function dashboard(){ $userInfo = array(); $data = array(); - $userProfile = Session::get("user-profile"); + $userRoles = Session::get("roles"); + $username = Session::get("username"); + $userEmail = Session::get("user-profile")->emails[0]; Session::forget("new-gateway-provider"); //check for gateway provider users - if( in_array( "gateway-provider", $userProfile["roles"]) ) { + if( in_array( "gateway-provider", $userRoles) ) { $gatewayOfUser = ""; Session::put("super-admin", true); $gatewaysInfo = CRUtilities::getAllGateways(); @@ -24,7 +26,7 @@ class AdminController extends BaseController { $gatewayApprovalStatuses = AdminUtilities::get_gateway_approval_statuses(); foreach ($gatewaysInfo as $index => $gateway) { - if ($gateway->requesterUsername == $userProfile["username"]) { + if ($gateway->requesterUsername == $username) { $gatewayOfUser = $gateway->gatewayId; Session::forget("super-admin"); Session::put("new-gateway-provider", true); @@ -47,8 +49,8 @@ class AdminController extends BaseController { Session::put("requestedGateways", $requestedGateways); if ($gatewayOfUser == "") { - $userInfo["username"] = $userProfile["username"]; - $userInfo["email"] = $userProfile["email"]; + $userInfo["username"] = $username; + $userInfo["email"] = $userEmail; $data["userInfo"] = $userInfo; $data["gatewaysInfo"] = $gatewaysInfo; Session::put("new-gateway-provider", true); http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/8101966e/app/controllers/UserSettingsController.php ---------------------------------------------------------------------- diff --git a/app/controllers/UserSettingsController.php b/app/controllers/UserSettingsController.php index abacb02..fa00c35 100644 --- a/app/controllers/UserSettingsController.php +++ b/app/controllers/UserSettingsController.php @@ -211,6 +211,9 @@ class UserSettingsController extends BaseController }); try { UserProfileUtilities::update_user_profile($userProfile); + // Now update the UserProfile in the Session + $userProfile = UserProfileUtilities::get_user_profile($username); + Session::put("user-profile", $userProfile); return Redirect::to("account/user-profile")->with("message", "Your profile has been updated."); } catch (Exception $e) { return View::make("account/user-profile", array( http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/8101966e/app/libraries/AdminUtilities.php ---------------------------------------------------------------------- diff --git a/app/libraries/AdminUtilities.php b/app/libraries/AdminUtilities.php index 03d168b..1352878 100644 --- a/app/libraries/AdminUtilities.php +++ b/app/libraries/AdminUtilities.php @@ -47,8 +47,7 @@ class AdminUtilities $gateway->reviewProposalDescription = $inputs["project-details"]; $gateway->gatewayPublicAbstract = $inputs["public-project-description"]; - $userProfile = Session::get("user-profile"); - $gateway->requesterUsername = $userProfile["username"]; + $gateway->requesterUsername = Session::get('username'); return Airavata::addGateway(Session::get('authz-token'), $gateway); } http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/8101966e/app/views/layout/basic.blade.php ---------------------------------------------------------------------- diff --git a/app/views/layout/basic.blade.php b/app/views/layout/basic.blade.php index b621ecd..d481e9f 100755 --- a/app/views/layout/basic.blade.php +++ b/app/views/layout/basic.blade.php @@ -27,8 +27,8 @@ $title = Session::get("portal-title"); @if(Session::has("user-profile")) @endif http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/8101966e/app/views/layout/fixed-scripts.blade.php ---------------------------------------------------------------------- diff --git a/app/views/layout/fixed-scripts.blade.php b/app/views/layout/fixed-scripts.blade.php index cba435b..2523a5f 100644 --- a/app/views/layout/fixed-scripts.blade.php +++ b/app/views/layout/fixed-scripts.blade.php @@ -29,8 +29,8 @@ showCollectorDialog(); }); },fieldValues: { - email : email !== 'undefined' ? email : "", - fullname : fullName !== 'undefined' ? fullName : "" + email : typeof email !== 'undefined' ? email : "", + fullname : typeof fullName !== 'undefined' ? fullName : "" } }, "{{ Config::get('pga_config.portal')['jira-help']['request-feature-collector-id'] }}": { @@ -41,8 +41,8 @@ showCollectorDialog(); }); },fieldValues: { - email : email !== 'undefined' ? email : "", - fullname : fullName !== 'undefined' ? fullName : "" + email : typeof email !== 'undefined' ? email : "", + fullname : typeof fullName !== 'undefined' ? fullName : "" } } });