Class: Remotty::Rails::Authentication::JsonAuthFailure

Inherits:
Devise::FailureApp
  • Object
show all
Defined in:
lib/remotty/rails/authentication/json_auth_failure.rb

Overview

return json Device error occur

Instance Method Summary collapse

Instance Method Details

#http_auth_bodyObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/remotty/rails/authentication/json_auth_failure.rb', line 5

def http_auth_body
  return i18n_message unless request_format

  method = "to_#{request_format}"
  if method == "to_xml"
    {
      error: {
        code: "UNAUTHORIZED",
        message: i18n_message
      }
    }.to_xml(:root => "errors")
  elsif {}.respond_to?(method)
    {
      error: {
        code: "UNAUTHORIZED",
        message: i18n_message
      }
    }.send(method)
  else
    i18n_message
  end
end

#respondObject



28
29
30
# File 'lib/remotty/rails/authentication/json_auth_failure.rb', line 28

def respond
  http_auth
end