Class: UserController

Inherits:
BaseController show all
Defined in:
app/controllers/user_controller.rb

Constant Summary

Constants inherited from BaseController

BaseController::API_VERSION, BaseController::SUPPORTED_API_VERSIONS

Instance Method Summary collapse

Methods included from UserActionLogger

#get_action_logger, #log_action

Instance Method Details

#destroyObject

DELETE /user NOTE: Only applicable for subaccount users



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/controllers/user_controller.rb', line 16

def destroy
  force = get_bool(params[:force])

  unless @cloud_user
    log_action(@request_id, 'nil', @login, "DELETE_USER", true, "User '#{@login}' not found")
    return render_format_error(:not_found, "User '#{@login}' not found", 99)
  end
  return render_format_error(:forbidden, "User deletion not permitted. Only applicable for subaccount users.", 138, "DELETE_USER") unless @cloud_user.

  begin
    if force
      @cloud_user.force_delete
    else
      return render_format_error(:unprocessable_entity, "User '#{@login}' has valid domain or applications. Either delete domain, applications and retry the operation or use 'force' option.",
                                 139, "DELETE_USER") if !@cloud_user.domains.empty? or !@cloud_user.applications.empty?
      @cloud_user.delete
    end
    render_format_success(:no_content, nil, nil, "DELETE_USER", "User #{@login} deleted.", true)
  rescue Exception => e
    return render_format_exception(e, "DELETE_USER")
  end
end

#showObject

GET /user



6
7
8
9
10
11
12
# File 'app/controllers/user_controller.rb', line 6

def show
  unless @cloud_user
    log_action(@request_id, 'nil', @login, "SHOW_USER", true, "User '#{@login}' not found")
    return render_error(:not_found, "User '#{@login}' not found", 99)
  end
  render_success(:ok, "user", RestUser.new(@cloud_user, get_url, nolinks), "SHOW_USER")
end