2013-05-24 12:43:47 -04:00
|
|
|
module OauthHelper
|
|
|
|
def ldap_enabled?
|
2014-10-13 07:39:54 -04:00
|
|
|
Gitlab.config.ldap.enabled
|
2013-05-24 12:43:47 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def default_providers
|
2015-02-17 10:59:50 -05:00
|
|
|
[:twitter, :github, :gitlab, :bitbucket, :google_oauth2, :ldap]
|
2013-05-24 12:43:47 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def enabled_oauth_providers
|
|
|
|
Devise.omniauth_providers
|
|
|
|
end
|
2013-05-28 11:00:44 -04:00
|
|
|
|
|
|
|
def enabled_social_providers
|
|
|
|
enabled_oauth_providers.select do |name|
|
2015-02-17 10:59:50 -05:00
|
|
|
[:twitter, :gitlab, :github, :bitbucket, :google_oauth2].include?(name.to_sym)
|
2013-05-28 11:00:44 -04:00
|
|
|
end
|
|
|
|
end
|
2014-12-04 05:55:37 -05:00
|
|
|
|
|
|
|
def additional_providers
|
|
|
|
enabled_oauth_providers.reject{|provider| provider.to_s.starts_with?('ldap')}
|
|
|
|
end
|
2015-03-21 20:44:40 -04:00
|
|
|
|
|
|
|
def oauth_image_tag(provider, size = 64)
|
|
|
|
file_name = "#{provider.to_s.split('_').first}_#{size}.png"
|
|
|
|
image_tag(image_path("authbuttons/#{file_name}"), alt: "Sign in with #{provider.to_s.titleize}")
|
|
|
|
end
|
|
|
|
|
|
|
|
def oauth_active?(provider)
|
|
|
|
current_user.identities.exists?(provider: provider.to_s)
|
|
|
|
end
|
|
|
|
|
2015-02-17 16:52:32 -05:00
|
|
|
extend self
|
2013-05-24 12:43:47 -04:00
|
|
|
end
|