Class: Kaui::AccountEmailsController

Inherits:
EngineController show all
Defined in:
app/controllers/kaui/account_emails_controller.rb

Constant Summary

Constants included from EngineControllerUtil

EngineControllerUtil::SIMPLE_PAGINATION_THRESHOLD

Instance Method Summary collapse

Methods inherited from EngineController

#check_for_redirect_to_tenant_screen, #current_ability, #current_user, #options_for_klient, #populate_account_details, #retrieve_allowed_users_for_current_user, #retrieve_tenants_for_current_user

Instance Method Details

#createObject



10
11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/kaui/account_emails_controller.rb', line 10

def create
  @account_email = Kaui::AccountEmail.new(.merge(account_id: params.require(:account_id)))

  begin
    @account_email.create(current_user.kb_username, params[:reason], params[:comment], options_for_klient)
    redirect_to kaui_engine.(@account_email.), notice: 'Account email was successfully added'
  rescue StandardError => e
    flash.now[:error] = "Error while adding the email: #{as_string(e)}"
    render action: :new
  end
end

#destroyObject



22
23
24
25
26
27
28
29
# File 'app/controllers/kaui/account_emails_controller.rb', line 22

def destroy
   = Kaui::AccountEmail.new(account_id: params.require(:account_id),
                                         email: params.require(:id))

  .destroy(current_user.kb_username, params[:reason], params[:comment], options_for_klient)

  redirect_to kaui_engine.(.), notice: 'Account email was successfully deleted'
end

#newObject



5
6
7
8
# File 'app/controllers/kaui/account_emails_controller.rb', line 5

def new
  @account_email = Kaui::AccountEmail.new(account_id: params.require(:account_id),
                                          email: params[:email])
end