# Allow login to a read-only site

**URL:** https://meta.discourse.org/t/allow-login-to-a-read-only-site/54270
**Category:** Feature
**Tags:** read-only
**Created:** [2016年十二月14日 22:30 UTC](https://meta.discourse.org/t/allow-login-to-a-read-only-site/54270 "2016-12-14T22:30:30Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2016年十二月14日 22:30 UTC](https://meta.discourse.org/t/allow-login-to-a-read-only-site/54270/1 "2016-12-14T22:30:30Z")

</div>

I did an import of some Wordpress data to an already active site. I thought it would be a Good Idea to put the site in read-only mode while I was doing the import so that people wouldn’t add data to the site that would get erased when the site + import\_data was uploaded.

That’s a Bad Idea. Now I can’t log in. On a self-hosted site, you can fix this from the rails console, on a hosted site, however, you’re stuck (I just emailed team). I tried `/users/admin-login`, but it can’t work either (obvious in retrospect).

This doesn’t seem like that much of an edge case, shouldn’t there be a way to freeze a site that still allows admins to log in?

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2016年十二月14日 22:55 UTC](https://meta.discourse.org/t/allow-login-to-a-read-only-site/54270/2 "2016-12-14T22:55:33Z")

</div>

Just log in _before_ you start read only. Seems simple enough?

Certainly simpler than “we must invent a time machine!”

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2016年十二月14日 22:59 UTC](https://meta.discourse.org/t/allow-login-to-a-read-only-site/54270/3 "2016-12-14T22:59:16Z")

</div>

> [@codinghorror](#):
>
> Just log in before you start read only. Seems simple enough?

Yeah, but somehow my cookies must have been deleted or something. Or what if the guy who put the site in read-only got hit by a bus?

---

<div class="post-metadata">

### Author: ![steef](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/steef/32/121150_2.png) [@steef](https://meta.discourse.org/u/steef)
#### Post date: [2016年十二月15日 18:49 UTC](https://meta.discourse.org/t/allow-login-to-a-read-only-site/54270/4 "2016-12-15T18:49:32Z")

</div>

As an alternative (or addition), perhaps a way to set a timer when enabling Read Only? Something like: Enable Read Only for: X hours.

Or maybe a special URI specifically to disable read only mode? Something like /admin/read-only which displays a login box for an administrator account and then disables read only when the credentials are correct. That wouldn’t need write-access to the database I imagine (only read to check the credentials).

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2016年十二月15日 19:22 UTC](https://meta.discourse.org/t/allow-login-to-a-read-only-site/54270/5 "2016-12-15T19:22:19Z")

</div>

> [@steef](#):
>
> Or maybe a special URI specifically to disable read only mode?

Yeah. If I’d thought ahead to have an API key I probably could have fixed it that way. One of my plans is a remote control panel to do things like that. I think that there are a handful of tasks that it would be handy to be able to do via API calls via a remote web interface. Things like:

- Creating sets of categories with certain colors and permissions for a particular purpose
- control settings for sets of users
- help to walk a user through Wordpress integration

It seems a little bizarre to build a web interface to remotely control a web app, but plugins get stale, and hosted people can’t install them anyway.

---

<div class="post-metadata">

### Author: ![Bathinda](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bathinda/32/135888_2.png) [@Bathinda](https://meta.discourse.org/u/Bathinda)
#### Post date: [2020年四月12日 13:19 UTC](https://meta.discourse.org/t/allow-login-to-a-read-only-site/54270/6 "2020-04-12T13:19:24Z")

</div>

[quote=“pfaffman, 帖子 1, 主题 54270”]  
这是个糟糕的主意。现在我无法登录了。在自托管网站上，你可以从 Rails 控制台修复这个问题；但在托管网站上，你却束手无策（我刚给团队发了邮件）。我尝试过 `/users/admin-login`，但这也不行（现在回想起来显而易见）。[/quote]

今天这差点就发生在我身上了。  
我不知道一旦启用此模式，如果不小心关闭了那个无痕模式标签页，就根本无法重新登录！！！

天哪！！！

把自己锁在门外是多么容易啊！！！

更不可思议的是，就在禁用“只读模式”的 5 分钟内，我竟然偶然发现了这个帖子！！！  
现在，至少以后每当我想调整一些管理员设置时，我会记住这件事。

---

<div class="post-metadata">

### Author: ![Bathinda](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bathinda/32/135888_2.png) [@Bathinda](https://meta.discourse.org/u/Bathinda)
#### Post date: [2020年四月12日 13:57 UTC](https://meta.discourse.org/t/allow-login-to-a-read-only-site/54270/7 "2020-04-12T13:57:17Z")

</div>

阅读此主题的任何人，我在另一个类似主题中找到了一个解决方案 [这里](https://meta.discourse.org/t/shut-down-the-forum-turn-off-posting/89542/8?u=bathinda)。

如果我们被锁在外面，可以在 Rails 控制台中运行以下命令来禁用“只读”模式：

`Discourse.disable_readonly_mode(Discourse::USER_READONLY_MODE_KEY)`
