I'm using devise in my ruby-on-rails app. I have a User class and an AdminUser class using devise. In my admin panel I would like to logout all Users but not AdminUsers.
Asked
Active
Viewed 1.2k times
4 Answers
15
Very late, but the answer could be something like this
for user in User.all
sign_out user
end
dumP
- 771
- 8
- 17
4
As someone said here, the simplest way to do this is to change the rails secret token.
-
This is a great answer, thanks for posting it here; even though it doesn't actually answer the question, it was exactly what I was looking for. – Dagmar Oct 30 '19 at 08:27
-2
@users = User.all
@users.log_out
and
def log_out
# depending on how you store the user's token, just delete it from the database
end
Assuming you are using database authentication.
CamelCamelCamel
- 5,200
- 8
- 61
- 93
-
Thanks. I'm using devise :database_authenticatable. I don't see what needs to be deleted. – MIkeO Nov 04 '11 at 23:02
-
Try to run on all the users with destroy_user_session_path(user). – CamelCamelCamel Nov 04 '11 at 23:27