We are using Devise, Rails_Admin and Simple_Token_Authentication (for API) in our application.
Everything is working fine except for sign out. When we click on Sign out, following request is made and the user gets signed out.
Started DELETE "/admins/sign_out" for 127.0.0.1 at 2015-07-12 18:50:44 +0530 Processing by Devise::SessionsController#destroy as HTML Parameters: {"authenticity_token"=>"rtSRPzpRN7cWEk8wV8q6VDAUB575ZV46JeFFlMFVOQc="} Admin Load (0.4ms) SELECT "admins".* FROM "admins" WHERE "admins"."id" = 1 ORDER BY "admins"."id" ASC LIMIT 1 (0.1ms) begin transaction (0.1ms) commit transaction Completed 204 No Content in 700ms (ActiveRecord: 0.5ms)
The problem is that the page does not redirect after sign out.
On pressing the sign out button again, here is the request:
Started DELETE "/admins/sign_out" for 127.0.0.1 at 2015-07-12 19:01:59 +0530 Processing by Devise::SessionsController#destroy as HTML Parameters: {"authenticity_token"=>"dHuxA5hRosyquhlsRmchK3vW9bQOCM/YXYXUNMxTufc="} Filter chain halted as :verify_signed_out_user rendered or redirected Completed 204 No Content in 1ms (ActiveRecord: 0.0ms)
Here is the application controller (app/controllers/application_controller.rb):
class ApplicationController < ActionController::Base
protect_from_forgery
skip_before_filter :verify_signed_out_user
respond_to :html, :json
protected
# Overwriting the sign_out redirect path method
def after_sign_out_path_for(resource_or_scope)
request.referrer
end
end
Here is the devise related code in app/config/initializers/rails_admin.rb
config.authenticate_with do
warden.authenticate! scope: :admin
end
config.current_user_method(&:current_admin)
Please suggest. Thanks in advance!
SessionsController < Devise::SessionsController
inheriting devise controller and adding this in routes file and addingskip_before_filter :verify_signed_out_user, only: :destroy
there. – DeepeshDevise::Controllers::Helpers#stored_location_for
github.com/plataformatec/devise/wiki/… may be this help you – Deepeshrequest.referrer
inafter_sign_out_path
toroot_path
. – Pavan