# How to log out all members?

**URL:** https://meta.discourse.org/t/how-to-log-out-all-members/63404
**Category:** Support
**Created:** [May 25, 2017, 11:10pm UTC](https://meta.discourse.org/t/how-to-log-out-all-members/63404 "2017-05-25T23:10:59Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![wiliamjoaquim](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wiliamjoaquim/32/71571_2.png) [@wiliamjoaquim](https://meta.discourse.org/u/wiliamjoaquim)
#### Post date: [May 25, 2017, 11:11pm UTC](https://meta.discourse.org/t/how-to-log-out-all-members/63404/1 "2017-05-25T23:11:00Z")

</div>

I need all members to be logged in, so that they create their account in memberful, how do I?

---

<div class="post-metadata">

### Author: ![mpalmer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mpalmer/32/45740_2.png) [@mpalmer](https://meta.discourse.org/u/mpalmer)
#### Post date: [May 26, 2017, 1:23am UTC](https://meta.discourse.org/t/how-to-log-out-all-members/63404/2 "2017-05-26T01:23:42Z")

</div>

Enable memberful SSO (however that needs to be done), disable local logins, disable anonymous mode.

---

<div class="post-metadata">

### Author: ![wiliamjoaquim](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wiliamjoaquim/32/71571_2.png) [@wiliamjoaquim](https://meta.discourse.org/u/wiliamjoaquim)
#### Post date: [May 26, 2017, 11:32am UTC](https://meta.discourse.org/t/how-to-log-out-all-members/63404/3 "2017-05-26T11:32:54Z")

</div>

I need to log out on all users, but doing one by one is tiring, can you log out all at once?

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [May 27, 2017, 6:42pm UTC](https://meta.discourse.org/t/how-to-log-out-all-members/63404/4 "2017-05-27T18:42:08Z")

</div>

This [should be enough](https://meta.discourse.org/t/re-purposing-a-discourse-installation-for-a-yearly-event/34670/17) to log out all users, with the possibility of exempting some users:

```ruby
protected_users = ["system", "codinghorror"] # do not process these users

# get all users that should be logged out
affected_users = User.all.select { |u| !(protected_users.include? u.username) }

affected_users.each { |u|
        u.user_auth_tokens.destroy_all
        u.logged_out
};

```

This needs to be run within Rails – pasting it into a rails console (`./launcher enter app`, `rails c`) should be enough.

**Better safe than sorry: Always have a backup ready before going near the Rails console.**

---

<div class="post-metadata">

### Author: ![alehandrof](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alehandrof/32/119526_2.png) [@alehandrof](https://meta.discourse.org/u/alehandrof)
#### Post date: [May 17, 2018, 4:56pm UTC](https://meta.discourse.org/t/how-to-log-out-all-members/63404/5 "2018-05-17T16:56:55Z")

</div>

Will this work with SSO as well?

Sam elsewhere suggests nuking a couple of other values as well:

> [@Is there a way to force a mass logout?](https://meta.discourse.org/t/is-there-a-way-to-force-a-mass-logout/28862/9):
>
> UserAuthToken.destroy\_all would do the trick, you also would want to revoke api keys so that is 2 additional tables to nuke, ApiKey and UserApiKey.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [November 4, 2020, 3:10am UTC](https://meta.discourse.org/t/how-to-log-out-all-members/63404/6 "2020-11-04T03:10:20Z")

</div>


