Sha256: 61a886795dc5515839b67318608b7c0ae2f97b687490ec0b9c5f8f5052a5dccd

Contents?: true

Size: 1.59 KB

Versions: 17

Compression:

Stored size: 1.59 KB

Contents

class Iugu::AccountUsersController < Iugu::AccountSettingsController

  before_filter(:only => [:destroy, :cancel_destruction]) { |c| c.must_be [:owner, :admin], :account_id }

  def index
    if IuguSDK::enable_multiple_users_per_account
      @account = Account.find(params[:account_id])
      @account_users = @account.account_users
      render 'iugu/account_users/index'
    else
      raise ActionController::RoutingError.new("Not found")
    end
  end

  def view
    @account_user = AccountUser.find_by_account_id_and_user_id(params[:account_id], params[:user_id])
    render 'iugu/account_users/view'
  end

  def destroy
    if @account_user = AccountUser.find_by_account_id_and_user_id(params[:account_id], params[:user_id])
      @account = Account.find(params[:account_id])
    else
      raise ActionController::RoutingError.new('Not Found')
    end
    raise ActionController::RoutingError.new('Access Denied') if @account_user.user.id == current_user.id || @account_user.is?(:owner)
    @account_user.destroy
    redirect_to account_users_index_path(params[:account_id]), :notice => I18n.t("iugu.account_user_destruction_in") + @account_user.destruction_job.run_at.to_s
  end

  def cancel_destruction
    if @account_user = AccountUser.find_by_account_id_and_user_id(params[:account_id], params[:user_id])
      @account = Account.find(params[:account_id])
      @account_user.cancel_destruction
      redirect_to account_users_index_path(params[:account_id]), :notice => I18n.t("iugu.account_user_destruction_undone")
    else
      raise ActionController::RoutingError.new('Not Found')
    end
  end
  
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
iugusdk-1.0.0.alpha.25 app/controllers/iugu/account_users_controller.rb
iugusdk-1.0.0.alpha.24 app/controllers/iugu/account_users_controller.rb
iugusdk-1.0.0.alpha.23 app/controllers/iugu/account_users_controller.rb
iugusdk-1.0.0.alpha.22 app/controllers/iugu/account_users_controller.rb
iugusdk-1.0.0.alpha.21 app/controllers/iugu/account_users_controller.rb
iugusdk-1.0.0.alpha.20 app/controllers/iugu/account_users_controller.rb
iugusdk-1.0.0.alpha.19 app/controllers/iugu/account_users_controller.rb
iugusdk-1.0.0.alpha.18 app/controllers/iugu/account_users_controller.rb
iugusdk-1.0.0.alpha.17 app/controllers/iugu/account_users_controller.rb
iugusdk-1.0.0.alpha.16 app/controllers/iugu/account_users_controller.rb
iugusdk-1.0.0.alpha.14 app/controllers/iugu/account_users_controller.rb
iugusdk-1.0.0.alpha.13 app/controllers/iugu/account_users_controller.rb
iugusdk-1.0.0.alpha.12 app/controllers/iugu/account_users_controller.rb
iugusdk-1.0.0.alpha.11 app/controllers/iugu/account_users_controller.rb
iugusdk-1.0.0.alpha.10 app/controllers/iugu/account_users_controller.rb
iugusdk-1.0.0.alpha.9 app/controllers/iugu/account_users_controller.rb
iugusdk-1.0.0.alpha.7 app/controllers/iugu/account_users_controller.rb