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 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:

You’ll be sent an email with a login link that circumvents SSO 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 SSO

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

フォーラムにアクセスできません。

読み取り専用モードを有効にしましたが、管理画面にアクセスできなくなりました。

「/u/admin-login」にアクセスして管理者メールアドレスを入力すると、次のエラーが表示されます。

{"errors":["サイトは読み取り専用モードです。操作は無効になっています。"],"error_type":"read_only"}

コンソールアクセスでも機能しません :slightly_frowning_face:

どうすれば解決できますか?

よろしくお願いします。

「いいね!」 2

レールコンソールでこれを実行して無効にできると思います。

本当ですか? メールアドレスを入力して「メールを送信」をクリックすると、次のように表示されます。

サイトは読み取り専用モードです。操作は無効になっています。

そして、メールは送信されません。

「いいね!」 3

Moinさん、レポートありがとうございます。これで(これで最後だといいのですが :crossed_fingers:)修正されるはずです。

「いいね!」 5

とても役に立ちました!
この投稿で問題が解決しました。

「いいね!」 2