* Hooked "Enable" button to hidden checkbox * Hooked "Close" button to close email settings and show "Enable/Edit" button * Additional hookups * Start building generalized Modal blocks * Everything hooked up except styling and a few Qs * last of the hookups; ensure logic flow * clean up * specs to cover email auth refactor * Fix bug surfaced by Vaidehi * Incorporate PR feedback * prevent email auth disable if invite-only-mode * adjust emailAuthModal body text * Sundry improvements * Last-mile tweaks * Trying to get 3rd party auth deselect to work * delete unnecssary function * remove superfluous comment * Move inline styling into CSS file * Incorporate PR feedback * Incorporate more PR feedback * Make Confirm btn intent clearer * Add TODO comment
55 lines
1.7 KiB
Ruby
55 lines
1.7 KiB
Ruby
module AuthenticationHelper
|
|
def authentication_provider(provider_name)
|
|
Authentication::Providers.get!(provider_name)
|
|
end
|
|
|
|
def authentication_available_providers
|
|
Authentication::Providers.available.map do |provider_name|
|
|
Authentication::Providers.const_get(provider_name.to_s.titleize)
|
|
end
|
|
end
|
|
|
|
def authentication_enabled_providers
|
|
Authentication::Providers.enabled.map do |provider_name|
|
|
Authentication::Providers.get!(provider_name)
|
|
end
|
|
end
|
|
|
|
def authentication_enabled_providers_for_user(user = current_user)
|
|
Authentication::Providers.enabled_for_user(user)
|
|
end
|
|
|
|
def recaptcha_configured_and_enabled?
|
|
SiteConfig.recaptcha_secret_key.present? &&
|
|
SiteConfig.recaptcha_site_key.present? &&
|
|
SiteConfig.require_captcha_for_email_password_registration
|
|
end
|
|
|
|
def forem_creator_flow_enabled?
|
|
Flipper.enabled?(:creator_onboarding) && waiting_on_first_user?
|
|
end
|
|
|
|
def waiting_on_first_user?
|
|
SiteConfig.waiting_on_first_user
|
|
end
|
|
|
|
def disable_email_tooltip_class
|
|
SiteConfig.invite_only_mode || authentication_enabled_providers.none? ? "crayons-tooltip" : ""
|
|
end
|
|
|
|
def disable_email_tooltip_content
|
|
SiteConfig.invite_only_mode || authentication_enabled_providers.none? ? disable_email_auth_tooltip_text : ""
|
|
end
|
|
|
|
def disable_button_class
|
|
SiteConfig.invite_only_mode || authentication_enabled_providers.none? ? "disabled" : ""
|
|
end
|
|
|
|
def disable_email_auth_tooltip_text
|
|
if SiteConfig.invite_only_mode
|
|
"You cannot do this until you disable Invite Only Mode"
|
|
elsif authentication_enabled_providers.none?
|
|
"You cannot do this until you enable at least one other registration option"
|
|
end
|
|
end
|
|
end
|