airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scnakand...@apache.org
Subject [1/2] airavata-php-gateway git commit: fixing roles issue
Date Wed, 16 Mar 2016 17:24:50 GMT
Repository: airavata-php-gateway
Updated Branches:
  refs/heads/develop 8ac405175 -> 483a3f5cc


fixing roles issue


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/89170782
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/89170782
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/89170782

Branch: refs/heads/develop
Commit: 89170782c760ed0718554fba17c75cb593820846
Parents: c20e676
Author: scnakandala <supun.nakandala@gmail.com>
Authored: Wed Mar 16 13:24:42 2016 -0400
Committer: scnakandala <supun.nakandala@gmail.com>
Committed: Wed Mar 16 13:24:42 2016 -0400

----------------------------------------------------------------------
 app/controllers/AdminController.php           | 14 +++--
 app/libraries/Wsis/Stubs/UserStoreManager.php | 18 +++++--
 app/views/admin/manage-users.blade.php        | 62 +++++++++++-----------
 3 files changed, 54 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/89170782/app/controllers/AdminController.php
----------------------------------------------------------------------
diff --git a/app/controllers/AdminController.php b/app/controllers/AdminController.php
index b871558..1da7859 100644
--- a/app/controllers/AdminController.php
+++ b/app/controllers/AdminController.php
@@ -130,7 +130,7 @@ class AdminController extends BaseController {
 	}
 
     public function addRolesToUser(){
-        $currentRoles = Session::get('roles');
+        $currentRoles = WSIS::getUserRoles(Input::get("username"));
         $roles["new"] = array_diff(Input::all()["roles"], $currentRoles);
         $roles["deleted"] = array_diff($currentRoles, Input::all()["roles"]);
 
@@ -146,6 +146,11 @@ class AdminController extends BaseController {
 
         $username = Input::all()["username"];
         WSIS::updateUserRoles($username, $roles);
+		$roles = WSIS::getUserRoles(Input::get("username"));
+		if(in_array(Config::get("pga_config.wsis")["admin-role-name"], $roles) || in_array(Config::get("pga_config.wsis")["read-only-admin-role-name"],
$roles)
+			|| in_array(Config::get("pga_config.wsis")["user-role-name"], $roles)){
+			$this->sendAccessGrantedEmailToTheUser(Input::get("username"));
+		}
         return Redirect::to("admin/dashboard/roles")->with( "message", "Roles has been
added.");
     }
 
@@ -158,7 +163,7 @@ class AdminController extends BaseController {
     }
 
 	public function getRoles(){
-		return json_encode(Session::get("roles"));
+		return json_encode((array)WSIS::getUserRoles(Input::get("username")));
 	}
 
 	public function deleteRole(){
@@ -177,8 +182,9 @@ class AdminController extends BaseController {
 	public function updateUserRoles(){
 		if( Input::has("add")){
 			WSIS::updateUserRoles(Input::get("username"), array("new"=> Input::get("roles"), "deleted"
=> array() ) );
-			if(in_array(Config::get(wsis::admin-role-name), Input::get("roles")) || in_array(Config::get(wsis::read-only-admin-role-name),
Input::get("roles"))
-				|| in_array(Config::get(wsis::user-role-name), Input::get("roles"))){
+			$roles = WSIS::getUserRoles(Input::get("username"));
+			if(in_array(Config::get("pga_config.wsis")["admin-role-name"], $roles) || in_array(Config::get("pga_config.wsis")["read-only-admin-role-name"],
$roles)
+				|| in_array(Config::get("pga_config.wsis")["user-role-name"], $roles)){
 				$this->sendAccessGrantedEmailToTheUser(Input::get("username"));
 			}
 		}

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/89170782/app/libraries/Wsis/Stubs/UserStoreManager.php
----------------------------------------------------------------------
diff --git a/app/libraries/Wsis/Stubs/UserStoreManager.php b/app/libraries/Wsis/Stubs/UserStoreManager.php
index 7afda25..1a664a0 100755
--- a/app/libraries/Wsis/Stubs/UserStoreManager.php
+++ b/app/libraries/Wsis/Stubs/UserStoreManager.php
@@ -196,11 +196,19 @@ class UserStoreManager {
      * @return void
      */
     public function updateRoleListOfUser( $username, $roles){
-        $parameters = new UpdateRoleListOfUser();
-        $parameters->userName = $username;
-        $parameters->deletedRoles = $roles["deleted"];
-        $parameters->newRoles = $roles["new"];
-        return $this->serviceStub->updateRoleListOfUser( $parameters);
+        foreach ($roles["deleted"] as $role) {
+            $parameters = new UpdateRoleListOfUser();
+            $parameters->userName = $username;
+            $parameters->deletedRoles = $role;
+            $this->serviceStub->updateRoleListOfUser( $parameters);
+        }
+        foreach ($roles["new"] as $role) {
+            $parameters = new UpdateRoleListOfUser();
+            $parameters->userName = $username;
+            $parameters->newRoles = $role;
+            $this->serviceStub->updateRoleListOfUser( $parameters);
+        }
+        return;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/89170782/app/views/admin/manage-users.blade.php
----------------------------------------------------------------------
diff --git a/app/views/admin/manage-users.blade.php b/app/views/admin/manage-users.blade.php
index 4aa563b..f5cb2f4 100644
--- a/app/views/admin/manage-users.blade.php
+++ b/app/views/admin/manage-users.blade.php
@@ -247,38 +247,38 @@
         });
 
         update_users_existing_roles(this);
+    });
 
-        $(".add-roles-submit").click(function () {
-            that = this;
-            $(".success-message").html("");
-            $(this).attr("disabled", "disabled");
-            $(this).html("<img src='" + $(".base-url").val() + "/assets/ajax-loader.gif'/>");
-            userName = $(this).data("username");
-            var rolesToAdd = $(".new-roles-select").val();
-            if(rolesToAdd != null){
-                $(".roles-list").find(".role-name").each(function () {
-                    rolesToAdd.push($(this).html());
-                });
-                $.ajax({
-                    type: "POST",
-                    url: $(".base-url").val() + "/admin/add-roles-to-user",
-                    data: {
-                        add: true,
-                        username: userName,
-                        roles: rolesToAdd
-                    },
-                    success : function(data)
-                    {
-                        $(".roles-load").removeClass("hide");
-                        $(".roles-list").addClass("hide");
-                        $(".success-message").html("<span class='alert alert-success col-md-12'>Roles
have been added</span>");
-                        update_users_existing_roles(that);
-                    }
-                });
-            }
-            $(".add-roles-submit").html("Add Roles");
-            $(this).removeAttr("disabled");
-        });
+    $(".add-roles-submit").click(function () {
+        that = this;
+        $(".success-message").html("");
+        $(this).attr("disabled", "disabled");
+        $(this).html("<img src='" + $(".base-url").val() + "/assets/ajax-loader.gif'/>");
+        userName = $(this).data("username");
+        var rolesToAdd = $(".new-roles-select").val();
+        if(rolesToAdd != null){
+            $(".roles-list").find(".role-name").each(function () {
+                rolesToAdd.push($(this).html());
+            });
+            $.ajax({
+                type: "POST",
+                url: $(".base-url").val() + "/admin/add-roles-to-user",
+                data: {
+                    add: true,
+                    username: userName,
+                    roles: rolesToAdd
+                },
+                success : function(data)
+                {
+                    $(".roles-load").removeClass("hide");
+                    $(".roles-list").addClass("hide");
+                    $(".success-message").html("<span class='alert alert-success col-md-12'>Roles
have been added</span>");
+                    update_users_existing_roles(that);
+                }
+            });
+        }
+        $(".add-roles-submit").html("Add Roles");
+        $(this).removeAttr("disabled");
     });
 </script>
 @stop
\ No newline at end of file


Mime
View raw message