work off today
This commit is contained in:
@@ -1,5 +1,19 @@
|
||||
# Use this hook to configure devise mailer, warden hooks and so forth.
|
||||
# Many of these configuration options can be set straight in your model.
|
||||
module Qwaiter
|
||||
class FailureApp < Devise::FailureApp
|
||||
def respond
|
||||
if request.format.json?
|
||||
json_api_error_response
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
def json_api_error_response
|
||||
self.status = 401
|
||||
self.content_type = 'application/json'
|
||||
self.response_body = { errors: [{ status: '401', title: i18n_message }]}.to_json
|
||||
end
|
||||
end
|
||||
end
|
||||
Devise.setup do |config|
|
||||
# The secret key used by Devise. Devise uses this key to generate
|
||||
# random tokens. Changing this key will render invalid all existing
|
||||
@@ -250,10 +264,11 @@ Devise.setup do |config|
|
||||
# If you want to use other strategies, that are not supported by Devise, or
|
||||
# change the failure app, you can configure them inside the config.warden block.
|
||||
#
|
||||
# config.warden do |manager|
|
||||
config.warden do |manager|
|
||||
manager.failure_app = Qwaiter::FailureApp
|
||||
# manager.intercept_401 = false
|
||||
# manager.default_strategies(:scope => :user).unshift :some_external_strategy
|
||||
# end
|
||||
end
|
||||
|
||||
# ==> Mountable engine configurations
|
||||
# When using Devise inside an engine, let's call it `MyEngine`, and this engine
|
||||
|
||||
Reference in New Issue
Block a user