Allow login to a read-only site

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?

4 лайка

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

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

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?

5 лайков

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).

1 лайк

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.

1 лайк

Со мной сегодня чуть не случилось то же самое.
Я не знал, что после включения этого режима, если случайно закрыть вкладку в режиме инкогнито, не будет никакого способа снова войти!!!

Боже мой!!!

Как же легко было заблокировать себе доступ!!!

И это не меньше чем чудо, что всего через 5 минут (после отключения режима «только для чтения») я наткнулся на этот пост!!!
Теперь хотя бы я постараюсь помнить об этом в будущем, когда захочу поковыряться в настройках администратора!!!

1 лайк

Все, кто читает эту тему: я нашел решение в другой похожей теме здесь.

В случае, если мы заблокированы, мы можем выполнить эту команду в консоли Rails, чтобы отключить режим «только для чтения»:

Discourse.disable_readonly_mode(Discourse::USER_READONLY_MODE_KEY)

4 лайка