Class: Maestrano::Account::GroupUsersController

Inherits:
Rails::WebHookController
  • Object
show all
Defined in:
app/controllers/maestrano/account/group_users_controller.rb

Instance Method Summary collapse

Instance Method Details

#destroyObject

DELETE /maestrano/account/groups/cld-1/users/usr-1 DELETE /maestrano/account/groups/cld-1/users/usr-1/tenant Remove a user from a group



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/maestrano/account/group_users_controller.rb', line 6

def destroy
  # Set the right uid based on Maestrano.param('sso.creation_mode')
  user_uid = Maestrano.mask_user(params[:id], params[:group_id]) 
  group_uid = params[:group_id]
  
  # Get the entities
  user = Maestrano::Connector::Rails::User.find_by_uid_and_tenant(user_uid, params[:tenant] || 'default')
  organization = Maestrano::Connector::Rails::Organization.find_by_uid_and_tenant(group_uid, params[:tenant] || 'default')
  
  # Remove the user from the organization
  organization.remove_member(user)
  
  render json: {success: true}
end