Allow login to a read-only site

AI-generated summary

A user, pfaffman, experienced an issue where they were unable to log in to their Discourse site after enabling read-only mode. This was due to the user not being logged in before enabling the mode. codinghorror suggested logging in before enabling read-only mode as a simple solution.

pfaffman pointed out potential issues with this approach, such as cookies being deleted or the person enabling read-only mode being unavailable. steef proposed alternative solutions, including a timer for read-only mode or a special URI to disable it.

pfaffman considered these suggestions and mentioned plans to develop a remote control panel for tasks like disabling read-only mode. Another user, Bathinda, shared a similar experience of accidentally locking themselves out after enabling read-only mode.

Bathinda later found a solution by running a command in the rails console to disable read-only mode, which they shared with the community: Discourse.disable_readonly_mode(Discourse::USER_READONLY_MODE_KEY).

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개의 좋아요