"Fossies" - the Fresh Open Source Software Archive

Member "discourse-2.8.3/config/initializers/006-ensure_login_hint.rb" (14 Apr 2022, 1176 Bytes) of package /linux/www/discourse-2.8.3.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 # Some sanity checking so we don't count on an unindexed column on boot
    6 begin
    7   if ActiveRecord::Base.connection.table_exists?(:users) &&
    8      User.limit(20).count < 20 &&
    9      User.where(admin: true).human_users.count == 0
   10 
   11     notice =
   12       if GlobalSetting.developer_emails.blank?
   13         "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>."
   14       else
   15         emails = GlobalSetting.developer_emails.split(",")
   16         if emails.length > 1
   17           emails = emails[0..-2].join(', ') << " or #{emails[-1]} "
   18         else
   19           emails = emails[0]
   20         end
   21         "Congratulations, you installed Discourse! Register a new admin account with #{emails} to finalize configuration."
   22       end
   23 
   24     if notice != SiteSetting.global_notice
   25       SiteSetting.global_notice = notice
   26       SiteSetting.has_login_hint = true
   27     end
   28   end
   29 rescue ActiveRecord::NoDatabaseError
   30   # Database might not have been created
   31 end