Log back in as admin after locking yourself out with read-only mode or an invalid SSO configuration

:bookmark: This guide explains how to log back into Discourse as an admin when you have been locked out.

:person_raising_hand: Required user level: Administrator

If you’ve locked yourself out of your Discourse instance with an invalid Discourse Connect (SSO) configuration, append /u/admin-login to the end of your forum’s root URL:

https://discourse.example.com/u/admin-login

This will take you to an admin login page:

Enter your admin email address and click Send Email. There is also a Safe Mode checkbox which, when enabled, will disable all themes and plugins when logging in — useful if a broken theme or plugin is causing issues.

You’ll be sent an email with a login link that circumvents Discourse Connect and read-only mode, allowing you to login as needed.

:information_source: If you have 2-factor authentication enabled you’ll still have to enter your auth code.

Alternative method requiring console access

Disable Discourse Connect

cd /var/discourse
./launcher enter app
rails c
irb > SiteSetting.enable_discourse_connect = false
irb > SiteSetting.enable_local_logins = true
irb > exit
exit

Disable read-only mode

cd /var/discourse
./launcher enter app
rails c
irb > Discourse.disable_readonly_mode(Discourse::USER_READONLY_MODE_KEY)
irb > exit
exit

Last edited by @hugh 2024-07-30T05:41:29Z

Last checked by @hugh 2024-07-30T05:41:34Z

Check documentPerform check on document:
18개의 좋아요

Hi, I can’t access to my forum.

I have enabled read-only mode but now I can’t access to admin.

When I go to “/u/admin-login” and I insert my admin email, I receive this error:

{“errors”:[“The site is in read only mode. Interactions are disabled.”],“error_type”:“read_only”}

And also via console access it doesn’t work :slightly_frowning_face:

How can I resolve?

Thank you in advance

2개의 좋아요

I think you can run this in the rails console to turn it off:

정말인가요? 이메일을 입력하고 이메일 보내기를 클릭하면 다음과 같은 메시지가 표시됩니다:

사이트가 읽기 전용 모드입니다. 상호작용이 비활성화되었습니다.

그리고 이메일은 전송되지 않습니다.

3개의 좋아요

@Moin, 보고해 주셔서 감사합니다. 이제 (한 번에, 그리고 영원히) 수정될 것입니다 :crossed_fingers:

5개의 좋아요

매우 유용합니다!
이 게시글 덕분에 제 문제가 해결되었습니다.

2개의 좋아요