5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'app/controllers/token_action/tokens_controller.rb', line 5
def redeem
@token = TokenAction::Token.to_adapter.find_first(token: params[:token])
if @token
begin
ActiveSupport::Inflector.constantize(@token.kind).redeem_token(*@token.args)
redirect_to success_url, notice: translate(:success)
rescue => e
key = ActiveSupport::Inflector.underscore(e.class.name).gsub('/', I18n.default_separator)
logger.warn "TokenAction failed to perform the action for the token '#{params[:token]}': #{e.message}"
redirect_to failure_url, alert: translate(key, :failure)
end
else
logger.info "TokenAction failed to find the token '#{params[:token]}'"
redirect_to failure_url, alert: translate(:not_found)
end
end
|