0
votes

How can I close the session after the user successfully logged in?

When the user successfully logs in, he is doing his operations, but in back end the admin deactivates the user. At that time close the user session and redirect to the login page.

Is this possible in rails devise?

2

2 Answers

0
votes

You need a before_action on your application controller, something like:

before_action :check_inactive_user, if: :current_user

def check_inactive_user
  if current_user.inactive?
    current_user.sign_out
    redirect_to root_path, flash: {notice: 'Your user is inactive'}
  end
end
0
votes

current_user utilizes sessions so you can do reset_session in any controller action to bring them back to the login screen.