adds feature flags for omniauth login buttons/controls
Conflicts: app/controllers/users/omniauth_callbacks_controller.rb app/views/devise/_omniauth_form.html.erb
This commit is contained in:
@@ -1,15 +1,15 @@
|
|||||||
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
||||||
|
|
||||||
def twitter
|
def twitter
|
||||||
sign_in_with :twitter
|
sign_in_with :twitter_login, :twitter
|
||||||
end
|
end
|
||||||
|
|
||||||
def facebook
|
def facebook
|
||||||
sign_in_with :facebook
|
sign_in_with :facebook_login, :facebook
|
||||||
end
|
end
|
||||||
|
|
||||||
def google_oauth2
|
def google_oauth2
|
||||||
sign_in_with :google_oauth2
|
sign_in_with :google_login, :google_oauth2
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_sign_in_path_for(resource)
|
def after_sign_in_path_for(resource)
|
||||||
@@ -22,7 +22,9 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def sign_in_with(provider)
|
def sign_in_with(feature, provider)
|
||||||
|
raise ActionController::RoutingError.new('Not Found') unless Setting["feature.#{feature}"]
|
||||||
|
|
||||||
auth = env["omniauth.auth"]
|
auth = env["omniauth.auth"]
|
||||||
|
|
||||||
identity = Identity.first_or_create_from_oauth(auth)
|
identity = Identity.first_or_create_from_oauth(auth)
|
||||||
|
|||||||
@@ -1,12 +1,35 @@
|
|||||||
<% if current_page?(new_user_session_path) %>
|
<% if feature?(:twitter_login) || feature?(:facebook_login) || feature?(:google_login) %>
|
||||||
<%= link_to t("omniauth.twitter.sign_in"), user_omniauth_authorize_path(:twitter), class: "button-twitter button radius expand" %>
|
|
||||||
<%= link_to t("omniauth.facebook.sign_in"), user_omniauth_authorize_path(:facebook), class: "button-facebook button radius expand" %>
|
<% if current_page?(new_user_session_path) %>
|
||||||
<%= link_to t("omniauth.google_oauth2.sign_in"), user_omniauth_authorize_path(:google_oauth2), class: "button-google button radius expand" %>
|
|
||||||
<hr/>
|
<% if feature? :twitter_login %>
|
||||||
<% elsif current_page?(new_user_registration_path) %>
|
<%= link_to t("omniauth.twitter.sign_in"), user_omniauth_authorize_path(:twitter), class: "button-twitter button radius expand" %>
|
||||||
<%= link_to t("omniauth.twitter.sign_up"), user_omniauth_authorize_path(:twitter), class: "button-twitter button radius expand" %>
|
<% end %>
|
||||||
<%= link_to t("omniauth.facebook.sign_up"), user_omniauth_authorize_path(:facebook), class: "button-facebook button radius expand" %>
|
|
||||||
<%= link_to t("omniauth.google_oauth2.sign_up"), user_omniauth_authorize_path(:google_oauth2), class: "button-google button radius expand" %>
|
<% if feature? :facebook_login %>
|
||||||
<p>Al hacer login con una red social, usted está aceptando los términos legales.</p>
|
<%= link_to t("omniauth.facebook.sign_in"), user_omniauth_authorize_path(:facebook), class: "button-facebook button radius expand" %>
|
||||||
<hr/>
|
<% end %>
|
||||||
<% end %>
|
|
||||||
|
<% if feature? :google_login %>
|
||||||
|
<%= link_to t("omniauth.google_oauth2.sign_in"), user_omniauth_authorize_path(:google_oauth2), class: "button-google button radius expand" %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<hr/>
|
||||||
|
<% elsif current_page?(new_user_registration_path) %>
|
||||||
|
|
||||||
|
<% if feature? :twitter_login %>
|
||||||
|
<%= link_to t("omniauth.twitter.sign_up"), user_omniauth_authorize_path(:twitter), class: "button-twitter button radius expand" %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% if feature? :facebook_login %>
|
||||||
|
<%= link_to t("omniauth.facebook.sign_up"), user_omniauth_authorize_path(:facebook), class: "button-facebook button radius expand" %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% if feature? :google_login %>
|
||||||
|
<%= link_to t("omniauth.google_oauth2.sign_up"), user_omniauth_authorize_path(:google_oauth2), class: "button-google button radius expand" %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<hr/>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% end %>
|
||||||
|
|||||||
@@ -20,6 +20,9 @@ Setting.create(key: 'org_name', value: 'Consul')
|
|||||||
Setting.create(key: 'place_name', value: 'City')
|
Setting.create(key: 'place_name', value: 'City')
|
||||||
Setting.create(key: 'feature.debates', value: "true")
|
Setting.create(key: 'feature.debates', value: "true")
|
||||||
Setting.create(key: 'feature.spending_proposals', value: "true")
|
Setting.create(key: 'feature.spending_proposals', value: "true")
|
||||||
|
Setting.create(key: 'feature.twitter_login', value: "true")
|
||||||
|
Setting.create(key: 'feature.facebook_login', value: "true")
|
||||||
|
Setting.create(key: 'feature.google_login', value: "true")
|
||||||
|
|
||||||
puts "Creating Geozones"
|
puts "Creating Geozones"
|
||||||
('A'..'Z').each{ |i| Geozone.create(name: "District #{i}") }
|
('A'..'Z').each{ |i| Geozone.create(name: "District #{i}") }
|
||||||
|
|||||||
@@ -53,3 +53,6 @@ Setting["place_name"] = "Consul-land"
|
|||||||
# Feature flags
|
# Feature flags
|
||||||
Setting['feature.debates'] = true
|
Setting['feature.debates'] = true
|
||||||
Setting['feature.spending_proposals'] = true
|
Setting['feature.spending_proposals'] = true
|
||||||
|
Setting['feature.twitter_login'] = true
|
||||||
|
Setting['feature.facebook_login'] = true
|
||||||
|
Setting['feature.google_login'] = true
|
||||||
|
|||||||
Reference in New Issue
Block a user