Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AIRAVATA-2164 Remove pending role from user when given access #23

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 14 additions & 6 deletions app/controllers/AdminController.php
Expand Up @@ -213,12 +213,20 @@ public function addRolesToUser(){

$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)){
$userProfile = WSIS::getUserProfile(Input::get("username"));
$recipients = array($userProfile["email"]);
$this->sendAccessGrantedEmailToTheUser(Input::get("username"), $recipients);
$newCurrentRoles = WSIS::getUserRoles(Input::get("username"));
if(in_array(Config::get("pga_config.wsis")["admin-role-name"], $newCurrentRoles) || in_array(Config::get("pga_config.wsis")["read-only-admin-role-name"], $newCurrentRoles)
|| in_array(Config::get("pga_config.wsis")["user-role-name"], $newCurrentRoles)){
$userProfile = WSIS::getUserProfile(Input::get("username"));
$recipients = array($userProfile["email"]);
$this->sendAccessGrantedEmailToTheUser(Input::get("username"), $recipients);

// remove the pending role when access is granted, unless
// the admin is trying to add the user to the pending role
if(in_array("user-pending", $newCurrentRoles) && !in_array("user-pending", $roles["new"])) {
$userRoles["new"] = array();
$userRoles["deleted"] = "user-pending";
WSIS::updateUserRoles( $username, $userRoles);
}
}
return Redirect::to("admin/dashboard/roles")->with( "message", "Roles has been added.");
}
Expand Down