Class: CustomWardenFailureApp

Inherits:
Devise::FailureApp
  • Object
show all
Defined in:
lib/custom_warden_failure_app.rb

Instance Method Summary collapse

Instance Method Details

#custom_json_responseObject



14
15
16
17
18
19
20
21
22
23
# File 'lib/custom_warden_failure_app.rb', line 14

def custom_json_response
  self.headers[ApiV5::Constants::STATUS_HEADER] = ApiV5::Constants::STATUS_FAILURE
  self.status = 200
  self.content_type = "application/json"
  self.response_body = {
    status: false,
    data: nil,
    message: i18n_message
  }.to_json
end

#respondObject



4
5
6
7
8
9
10
11
12
# File 'lib/custom_warden_failure_app.rb', line 4

def respond
  lang = request.headers[ApiV5::Constants::LANGUAGE_HEADER]
  I18n.locale = MyLocaleManager.parse(lang) if lang
  if request.params['controller'] == "doorkeeper/tokens"
    custom_json_response
  else
    super
  end
end