How to change a site setting via the Console


(cpradio) #1

So while investigating

I enabled SSO, then logged out (yikes!), and now I can’t log back in, as it wants me to use SSO to do so :frowning:

How can I disable the enable_sso site setting so I can get back into my local environment?


(Régis Hanol) #2

in your /discourse

bundle exec rails c
SiteSetting.enable_sso = false

:wink:


LinkedIn OAuth2 Plugin
(cpradio) #3

Ah, I did it a different route, but yours is easier. :smile:

I ended up doing

s = SiteSetting.find_by(name: 'enable_sso')  
s.value = 'f'  
s.save!  

I was just about to post that here and saw your response. Thanks! Now I can at least constantly get back to a good state between tests :smile: (or maybe I should setup an actual SSO…)


(Felix Freiberger) #4

For future reference, there is also a method that does not need command line access.


(Jeff Atwood) #5

Yeah just use /users/admin-login


(Bohuslav Svancara) #6

I did

SiteSetting.enable_sso = false

But I ended up with this login form:

How can I log-in please?


(Kane York) #7

Looks like you have no login methods available.

Do SiteSetting.enable_local_logins = true .


(Bohuslav Svancara) #8

Yes!

Thank you very much!


(EW 👌) #9

After running : "bundle exec rails c"
I’m getting an error : “Could not locate Gemfile”

How to fix it?


No login/signup form
(Felix Freiberger) #10

Are you running this from inside your container (./launcher enter app)?


(EW 👌) #11

No I wasn’t :blush: since its wasn’t mentioned. Sorry a lot of things to learn yet :alien:


(EW 👌) #12

So I did these commands:

cd /var/discourse
./launcher enter app

then
bundle exec rails c

and I’ve got the following errors:

URGENT: FATAL: Peer authentication failed for user "discourse"
Failed to initialize site default
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in initialize': FATAL: Peer authentication failed for user "discourse" (PG::ConnectionBad) from /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:innew’
from /var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `connect’


… many folders list

I did ./launcher rebuild app and tried again. The same errors!


After I’d pissed of these problems. I did restored my droplet from a previous snapshot I had and started from scratch.

I did enabled FORCE_HTTPS without a problem.


Discourse lost the ability to login for all accounts
(SMHassanAlavi) #14

Can we change the discourse language in bundle exec rails c console?
How can we change the language of our site to english?


Installed OK. Working fine for one day. Suddenly stopped working
(SMHassanAlavi) #15

changing language can be done in database in site_settings column.
just search the current language and replace new language:
below code change language from Farsi to english:
UPDATE site_setting SET value = 'en' where value = 'fa_IR'
I have typed this code after typing : rails db


(Dražen Lučanin) #16

I had a problem with the force_https option (couldn’t login after enabling it). I fixed it by doing:

cd /var/discourse/
./launcher enter app
rails c
[1] pry(main)> SiteSetting.force_https = false
=> false