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:39 UTC
[10/12] airavata-php-gateway git commit: AIRAVATA-2316 Refactor: move
creation of basic profile
AIRAVATA-2316 Refactor: move creation of basic profile
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/05250eef
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/05250eef
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/05250eef
Branch: refs/heads/keycloak-integration
Commit: 05250eefffabc3f534d075a503175f1fba35d020
Parents: 8101966
Author: Marcus Christie <ma...@iu.edu>
Authored: Tue Feb 28 10:42:51 2017 -0500
Committer: Marcus Christie <ma...@iu.edu>
Committed: Tue Feb 28 10:42:51 2017 -0500
----------------------------------------------------------------------
app/controllers/AccountController.php | 11 +----------
app/controllers/UserSettingsController.php | 12 +++++++-----
app/libraries/UserProfileUtilities.php | 12 ++++++++++++
3 files changed, 20 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/05250eef/app/controllers/AccountController.php
----------------------------------------------------------------------
diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php
index 8a81f0b..3e70133 100644
--- a/app/controllers/AccountController.php
+++ b/app/controllers/AccountController.php
@@ -248,17 +248,8 @@ class AccountController extends BaseController
}
// Create basic user profile if it doesn't exist
- // TODO: Move this to UserProfileUtilities
if (!UserProfileUtilities::does_user_profile_exist($username)) {
- $gatewayId = Session::get("gateway_id");
- $userProfileData = array();
- $userProfileData["airavataInternalUserId"] = $username . '@' . $gatewayId;
- $userProfileData["userId"] = $username;
- $userProfileData["gatewayId"] = $gatewayId;
- $userProfileData["emails"] = array($userEmail);
-
- Log::info("creating user profile for user", array($userProfileData));
- UserProfileUtilities::add_user_profile($userProfileData);
+ UserProfileUtilities::create_basic_user_profile($username, $userEmail);
}
$userProfile = UserProfileUtilities::get_user_profile($username);
Session::put('user-profile', $userProfile);
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/05250eef/app/controllers/UserSettingsController.php
----------------------------------------------------------------------
diff --git a/app/controllers/UserSettingsController.php b/app/controllers/UserSettingsController.php
index fa00c35..7b93f19 100644
--- a/app/controllers/UserSettingsController.php
+++ b/app/controllers/UserSettingsController.php
@@ -204,11 +204,13 @@ class UserSettingsController extends BaseController
$userProfile->userName = Input::get("userName");
$userProfile->homeOrganization = Input::get("homeOrganization");
$userProfile->country = Input::get("country");
- $phones = Input::get("phones");
- // Filter out empty phone numbers
- $userProfile->phones = array_filter($phones, function($phone) {
- return trim($phone) !== "";
- });
+ if (Input::has("phones")) {
+ $phones = Input::get("phones");
+ // Filter out empty phone numbers
+ $userProfile->phones = array_filter($phones, function($phone) {
+ return trim($phone) !== "";
+ });
+ }
try {
UserProfileUtilities::update_user_profile($userProfile);
// Now update the UserProfile in the Session
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/05250eef/app/libraries/UserProfileUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/UserProfileUtilities.php b/app/libraries/UserProfileUtilities.php
index d4d52f7..720bdd7 100644
--- a/app/libraries/UserProfileUtilities.php
+++ b/app/libraries/UserProfileUtilities.php
@@ -11,6 +11,18 @@ class UserProfileUtilities
return Airavata::doesUserProfileExist(Session::get('authz-token'), $userId, $gatewayId);
}
+ public static function create_basic_user_profile($username, $userEmail) {
+ $gatewayId = Session::get("gateway_id");
+ $userProfileData = array();
+ $userProfileData["airavataInternalUserId"] = $username . '@' . $gatewayId;
+ $userProfileData["userId"] = $username;
+ $userProfileData["gatewayId"] = $gatewayId;
+ $userProfileData["emails"] = array($userEmail);
+
+ Log::info("creating basic user profile for user", array($userProfileData));
+ return UserProfileUtilities::add_user_profile($userProfileData);
+ }
+
public static function add_user_profile($userProfileData) {
$userProfile = new UserProfile($userProfileData);