Skip to content
Permalink
Browse files
Merge remote-tracking branch 'origin/develop' into develop
  • Loading branch information
scnakandala committed Jun 29, 2017
2 parents 30d7bc8 + 5e2bf43 commit e6bacd6659fc6085d073d1b7bad160dec27bec7d
Showing 3 changed files with 30 additions and 8 deletions.
@@ -114,7 +114,7 @@ public function loginDesktopView()
public function loginSubmit()
{
if (CommonUtilities::form_submitted()) {
$username = Input::get("username");
$username = strtolower(Input::get("username"));

$password = $_POST['password'];
$response = Keycloak::authenticate($username, $password);
@@ -303,7 +303,7 @@ public function forgotPassword()

public function forgotPasswordSubmit()
{
$username = Input::get("username");
$username = strtolower(Input::get("username"));
if(empty($username)){
CommonUtilities::print_error_message("Please provide a valid username");
return View::make("account/forgot-password");
@@ -77,19 +77,19 @@ public static function getAllUserPermissions($resourceId, $dataResourceType) {
$owner = GrouperUtilities::getAllAccessibleUsers($resourceId, $dataResourceType, ResourcePermissionType::OWNER);

foreach($read as $uid) {
if ($uid !== Session::get('username') && Keycloak::usernameExists($uid)) {
if ($uid !== Session::get('username') && UserProfileUtilities::does_user_profile_exist($uid)) {
$users[$uid] = array('read' => true, 'write' => false);
}
}

foreach($write as $uid) {
if ($uid !== Session::get('username') && Keycloak::usernameExists($uid)) {
if ($uid !== Session::get('username') && UserProfileUtilities::does_user_profile_exist($uid)) {
$users[$uid]['write'] = true;
}
}

foreach($owner as $uid) {
if ($uid !== Session::get('username') && WSIS::usernameExists($uid)) {
if ($uid !== Session::get('username') && UserProfileUtilities::does_user_profile_exist($uid)) {
$users[$uid]['owner'] = true;
}
}
@@ -104,16 +104,33 @@ public static function getAllUserPermissions($resourceId, $dataResourceType) {
* @return An array [uid => [firstname => string, lastname => string, email => string]]
*/
public static function getUserProfiles($uids) {
$uids = array_filter($uids, function($uid) {
return ($uid !== Session::get('username') && Keycloak::usernameExists($uid));
// FIXME: instead of loading all user profiles it would be better to
// have the user search for users and just load profiles matching the search
$all_profiles = SharingUtilities::convertUserProfilesToSharingProfiles(UserProfileUtilities::get_all_user_profiles(0, 100000));
Log::debug("all_profiles", array($all_profiles));
$uids = array_filter($uids, function($uid) use ($all_profiles) {
return ($uid !== Session::get('username') && array_key_exists($uid, $all_profiles));
});
$profiles = array();
foreach ($uids as $uid) {
$profiles[$uid] = Keycloak::getUserProfile($uid);
$profiles[$uid] = $all_profiles[$uid];
}
return $profiles;
}

private static function convertUserProfilesToSharingProfiles($user_profiles) {
$sharing_profiles = array();
foreach ($user_profiles as $user_profile) {
$sharing_profile = array(
'firstname' => $user_profile->firstName,
'lastname' => $user_profile->lastName,
'email' => $user_profile->emails[0],
);
$sharing_profiles[$user_profile->userId] = $sharing_profile;
}
return $sharing_profiles;
}

/**
* Retrieve profile and permissions information for users with access to the given resource.
*
@@ -45,6 +45,11 @@ public static function update_user_profile($userProfile) {

return UserProfileService::updateUserProfile(Session::get('authz-token'), $userProfile);
}

public static function get_all_user_profiles($offset, $limit) {
return UserProfileService::getAllUserProfilesInGateway(
Session::get('authz-token'), Session::get('gateway_id'), $offset, $limit);
}
}

?>

0 comments on commit e6bacd6

Please sign in to comment.