Jeff Pole
Jeff Pole

Reputation: 355

Reset "remember me" cookie for all users

On my rails app I would like to force all users to sign-in when they next visit the site, rather than being remembered. I understand that I have to delete a cookie but which one and how do I do this?

I'm using rails 3.2 and devise 2.2.1.

Thanks for your help.

Upvotes: 1

Views: 171

Answers (1)

OneChillDude
OneChillDude

Reputation: 8006

Use devises sign_out function, and build a private method in your application controller that forces it when a request is made. In your ApplicationController

class ApplicationController < ActionController::Base

  before_filter :force_sign_out!


  private # avoid interference

  def force_sign_out!
    if user_signed_in?
       sign_out(current_user)
    end
  end
end

You could even run a block on your before_filter

before_filter do
  if # conditions
    force_sign_out!
  end
end

hope this helps!

-Brian

Upvotes: 1

Related Questions