Module: SocialHelper

Defined in:
app/helpers/social_helper.rb

Instance Method Summary collapse

Instance Method Details

#box_classObject



2
3
4
# File 'app/helpers/social_helper.rb', line 2

def box_class
  social_providers_present? ? 'small col-sm-8' : 'large col-sm-12'
end

#facebook_enabled?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'app/helpers/social_helper.rb', line 20

def facebook_enabled?
  Stormpath::Rails.config.web.facebook_app_id
end

#facebook_oauth_urlObject



52
53
54
55
56
57
58
59
60
61
62
# File 'app/helpers/social_helper.rb', line 52

def facebook_oauth_url
  URI::HTTPS.build(
    host: 'www.facebook.com',
    path: '/dialog/oauth',
    query: {
      client_id: Stormpath::Rails.config.web.facebook_app_id,
      redirect_uri: facebook_callback_url,
      scope: Stormpath::Rails.config.web.social.facebook.scope
    }.to_query
  ).to_s
end

#github_enabled?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'app/helpers/social_helper.rb', line 24

def github_enabled?
  Stormpath::Rails.config.web.github_app_id
end

#github_oauth_urlObject



64
65
66
67
68
69
70
71
72
73
74
# File 'app/helpers/social_helper.rb', line 64

def github_oauth_url
  URI::HTTPS.build(
    host: 'www.github.com',
    path: '/login/oauth/authorize',
    query: {
      client_id: Stormpath::Rails.config.web.github_app_id,
      redirect_uri: github_callback_url,
      scope: Stormpath::Rails.config.web.social.github.scope
    }.to_query
  ).to_s
end

#google_enabled?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'app/helpers/social_helper.rb', line 28

def google_enabled?
  Stormpath::Rails.config.web.google_app_id
end

#google_oauth_urlObject



76
77
78
79
80
81
82
83
84
85
86
87
# File 'app/helpers/social_helper.rb', line 76

def google_oauth_url
  URI::HTTPS.build(
    host: 'accounts.google.com',
    path: '/o/oauth2/auth',
    query: {
      client_id: Stormpath::Rails.config.web.google_app_id,
      redirect_uri: google_callback_url,
      scope: Stormpath::Rails.config.web.social.google.scope,
      response_type: 'code'
    }.to_query
  ).to_s
end

#input_classObject



10
11
12
# File 'app/helpers/social_helper.rb', line 10

def input_class
  social_providers_present? ? 'col-sm-12' : 'col-sm-8'
end

#label_classObject



6
7
8
# File 'app/helpers/social_helper.rb', line 6

def label_class
  social_providers_present? ? 'col-sm-12' : 'col-sm-4'
end


36
37
38
# File 'app/helpers/social_helper.rb', line 36

def (url)
  link_to 'Facebook', url, class: 'btn btn-social btn-facebook' if facebook_enabled? && url.present?
end


48
49
50
# File 'app/helpers/social_helper.rb', line 48

def (url)
  link_to 'GitHub', url, class: 'btn btn-social btn-github' if github_enabled? && url.present?
end


40
41
42
# File 'app/helpers/social_helper.rb', line 40

def (url)
  link_to 'Google', url, class: 'btn btn-social btn-google' if google_enabled? && url.present?
end


44
45
46
# File 'app/helpers/social_helper.rb', line 44

def (url)
  link_to 'LinkedIn', url, class: 'btn btn-social btn-linkedin' if linkedin_enabled? && url.present?
end

#linkedin_enabled?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'app/helpers/social_helper.rb', line 32

def linkedin_enabled?
  Stormpath::Rails.config.web.linkedin_app_id
end

#linkedin_oauth_urlObject



89
90
91
92
93
94
95
96
97
98
99
100
# File 'app/helpers/social_helper.rb', line 89

def linkedin_oauth_url
  URI::HTTPS.build(
    host: 'www.linkedin.com',
    path: '/oauth/v2/authorization',
    query: {
      client_id: Stormpath::Rails.config.web.linkedin_app_id,
      redirect_uri: linkedin_callback_url,
      scope: Stormpath::Rails.config.web.social.linkedin.scope,
      response_type: 'code'
    }.to_query
  ).to_s
end

#social_login_v2_enabled?Boolean

Returns:

  • (Boolean)


14
15
16
17
18
# File 'app/helpers/social_helper.rb', line 14

def 
  Stormpath::Rails.config.web.callback.enabled &&
    Stormpath::Rails.config.web.client_api.enabled &&
    Stormpath::Rails.config.web.client_api.domain_name.present?
end