You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2017/06/11 20:25:38 UTC
[09/12] airavata-php-gateway git commit: AIRAVATA-2316 Replacing WSO2
IS user-profile code
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 <ma...@iu.edu>
Authored: Tue Feb 28 10:32:27 2017 -0500
Committer: Marcus Christie <ma...@iu.edu>
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");
<!-- Getting user info -->
@if(Session::has("user-profile"))
<script>
-var email = "{{ Session::get("user-profile")["email"] }}";
-var fullName = "{{Session::get("user-profile")["firstname"] . " " . Session::get("user-profile")["lastname"]}}"
+var email = {{ json_encode(Session::get("user-profile")->emails[0]) }};
+var fullName = {{ json_encode(Session::get("user-profile")->userName) }};
</script>
@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 : ""
}
}
});