Class: TokenAuth::ConfigurationTokensController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/token_auth/configuration_tokens_controller.rb

Overview

Manages Configuration Tokens.

Instance Method Summary collapse

Instance Method Details

#createObject



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

def create
  token = ConfigurationToken.new(entity_id: params[:entity_id])

  if token.save
    redirect_to tokens_index,
                notice: t("activerecord.success_saving",
                          name: token.class.model_name.human)
  else
    redirect_to tokens_index,
                alert: t("activerecord.failure_saving",
                         name: token.class.model_name.human,
                         errors: errors_on(token))
  end
end

#destroyObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/controllers/token_auth/configuration_tokens_controller.rb', line 21

def destroy
  token = ConfigurationToken.find_by(entity_id: params[:entity_id])

  if token.nil?
    redirect_to tokens_index,
                alert: t("activerecord.cannot_find",
                         name: ConfigurationToken.model_name.human)
  elsif token.destroy
    redirect_to tokens_index,
                notice: t("activerecord.success_destroying",
                          name: ConfigurationToken.model_name.human)
  else
    redirect_to tokens_index,
                alert: t("activerecord.failure_destroying",
                         name: ConfigurationToken.model_name.human,
                         errors: errors_on(token))
  end
end