forked from External/greenlight
		
	master #1
@@ -39,6 +39,7 @@ class User < ApplicationRecord
 | 
				
			|||||||
                   format: { without: %r{https?://}i }
 | 
					                   format: { without: %r{https?://}i }
 | 
				
			||||||
  validates :provider, presence: true
 | 
					  validates :provider, presence: true
 | 
				
			||||||
  validate :check_if_email_can_be_blank
 | 
					  validate :check_if_email_can_be_blank
 | 
				
			||||||
 | 
					  validate :check_domain, if: :greenlight_account?, on: :create
 | 
				
			||||||
  validates :email, length: { maximum: 256 }, allow_blank: true,
 | 
					  validates :email, length: { maximum: 256 }, allow_blank: true,
 | 
				
			||||||
                    uniqueness: { case_sensitive: false, scope: :provider },
 | 
					                    uniqueness: { case_sensitive: false, scope: :provider },
 | 
				
			||||||
                    format: { with: /\A[\w+\-'.]+@[a-z\d\-.]+\.[a-z]+\z/i }
 | 
					                    format: { with: /\A[\w+\-'.]+@[a-z\d\-.]+\.[a-z]+\z/i }
 | 
				
			||||||
@@ -234,6 +235,13 @@ class User < ApplicationRecord
 | 
				
			|||||||
    Role.create_default_roles(role_provider) if Role.where(provider: role_provider).count.zero?
 | 
					    Role.create_default_roles(role_provider) if Role.where(provider: role_provider).count.zero?
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  def check_domain
 | 
				
			||||||
 | 
					    if Rails.configuration.require_email_domain.any? && !email.end_with?(*Rails.configuration.require_email_domain)
 | 
				
			||||||
 | 
					      errors.add(:email, I18n.t("errors.messages.domain",
 | 
				
			||||||
 | 
					        email_domain: Rails.configuration.require_email_domain.join('" ' + I18n.t("modal.login.or") + ' "')))
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def check_if_email_can_be_blank
 | 
					  def check_if_email_can_be_blank
 | 
				
			||||||
    if email.blank?
 | 
					    if email.blank?
 | 
				
			||||||
      if Rails.configuration.loadbalanced_configuration && greenlight_account?
 | 
					      if Rails.configuration.loadbalanced_configuration && greenlight_account?
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -94,6 +94,9 @@ module Greenlight
 | 
				
			|||||||
    # Determine if GreenLight should enable email verification
 | 
					    # Determine if GreenLight should enable email verification
 | 
				
			||||||
    config.enable_email_verification = parse_bool(ENV['ALLOW_MAIL_NOTIFICATIONS'])
 | 
					    config.enable_email_verification = parse_bool(ENV['ALLOW_MAIL_NOTIFICATIONS'])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # Determine if GreenLight should require a certain mail-domain
 | 
				
			||||||
 | 
					    config.require_email_domain = ENV["GREENLIGHT_ACCOUNT_HD"].to_s.split(",")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Determine if GreenLight should allow non-omniauth signup/login.
 | 
					    # Determine if GreenLight should allow non-omniauth signup/login.
 | 
				
			||||||
    config.allow_user_signup = parse_bool(ENV['ALLOW_GREENLIGHT_ACCOUNTS'])
 | 
					    config.allow_user_signup = parse_bool(ENV['ALLOW_GREENLIGHT_ACCOUNTS'])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -269,6 +269,7 @@ en:
 | 
				
			|||||||
      accepted: must be accepted
 | 
					      accepted: must be accepted
 | 
				
			||||||
      confirmation: doesn't match %{attribute}
 | 
					      confirmation: doesn't match %{attribute}
 | 
				
			||||||
      inclusion: is not included in the list
 | 
					      inclusion: is not included in the list
 | 
				
			||||||
 | 
					      domain: must end with "%{email_domain}"
 | 
				
			||||||
    no_provider:
 | 
					    no_provider:
 | 
				
			||||||
      message: The site you are trying to access is not enabled
 | 
					      message: The site you are trying to access is not enabled
 | 
				
			||||||
      help: Please contact your system administrator to setup Greenlight
 | 
					      help: Please contact your system administrator to setup Greenlight
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -105,6 +105,12 @@ LDAP_ATTRIBUTE_MAPPING=
 | 
				
			|||||||
#
 | 
					#
 | 
				
			||||||
ALLOW_GREENLIGHT_ACCOUNTS=true
 | 
					ALLOW_GREENLIGHT_ACCOUNTS=true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# "hosted domain" part of the Email-Address required for signup for a greenlight account
 | 
				
			||||||
 | 
					#    domain.com matches also mail.domain.com
 | 
				
			||||||
 | 
					#    @domain.com does NOT match @mail.domain.com
 | 
				
			||||||
 | 
					#    multiple domains can be separated by comma (with no whitespace!)
 | 
				
			||||||
 | 
					#GREENLIGHT_ACCOUNT_HD=@domain.com,subdomain-allowed.net
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# To enable reCaptcha on the user sign up, define these 2 keys
 | 
					# To enable reCaptcha on the user sign up, define these 2 keys
 | 
				
			||||||
# You can obtain these keys by registering your domain using the following url:
 | 
					# You can obtain these keys by registering your domain using the following url:
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user