"Fossies" - the Fresh Open Source Software Archive

Member "discourse-3.1.1/config/initializers/006-ensure_login_hint.rb" (12 Sep 2023, 1263 Bytes) of package /linux/www/discourse-3.1.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Ruby source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 # frozen_string_literal: true
    2 
    3 return if GlobalSetting.skip_db?
    4 
    5 Rails.application.config.to_prepare do
    6   # Some sanity checking so we don't count on an unindexed column on boot
    7   begin
    8     if ActiveRecord::Base.connection.table_exists?(:users) && User.limit(20).count < 20 &&
    9          User.where(admin: true).human_users.count == 0
   10       notice =
   11         if GlobalSetting.developer_emails.blank?
   12           "Congratulations, you installed Discourse! Unfortunately, no administrator emails were defined during setup, so finalizing the configuration <a href='https://meta.discourse.org/t/create-admin-account-from-console/17274'>may be difficult</a>."
   13         else
   14           emails = GlobalSetting.developer_emails.split(",")
   15           if emails.length > 1
   16             emails = emails[0..-2].join(", ") << " or #{emails[-1]} "
   17           else
   18             emails = emails[0]
   19           end
   20           "Congratulations, you installed Discourse! Register a new admin account with #{emails} to finalize configuration."
   21         end
   22 
   23       if notice != SiteSetting.global_notice
   24         SiteSetting.global_notice = notice
   25         SiteSetting.has_login_hint = true
   26       end
   27     end
   28   rescue ActiveRecord::NoDatabaseError
   29     # Database might not have been created
   30   end
   31 end