diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb index 24737777f..07f37ee13 100644 --- a/app/controllers/users/omniauth_callbacks_controller.rb +++ b/app/controllers/users/omniauth_callbacks_controller.rb @@ -1,15 +1,15 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController def twitter - sign_in_with :twitter + sign_in_with :twitter_login, :twitter end def facebook - sign_in_with :facebook + sign_in_with :facebook_login, :facebook end def google_oauth2 - sign_in_with :google_oauth2 + sign_in_with :google_login, :google_oauth2 end def after_sign_in_path_for(resource) @@ -22,7 +22,9 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController 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"] identity = Identity.first_or_create_from_oauth(auth) diff --git a/app/views/devise/_omniauth_form.html.erb b/app/views/devise/_omniauth_form.html.erb index 343743ff3..3167cc1d6 100644 --- a/app/views/devise/_omniauth_form.html.erb +++ b/app/views/devise/_omniauth_form.html.erb @@ -1,12 +1,35 @@ -<% if current_page?(new_user_session_path) %> - <%= 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" %> - <%= link_to t("omniauth.google_oauth2.sign_in"), user_omniauth_authorize_path(:google_oauth2), class: "button-google button radius expand" %> -
-<% elsif current_page?(new_user_registration_path) %> - <%= link_to t("omniauth.twitter.sign_up"), user_omniauth_authorize_path(:twitter), class: "button-twitter button radius expand" %> - <%= 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" %> -

Al hacer login con una red social, usted está aceptando los términos legales.

-
-<% end %> \ No newline at end of file +<% if feature?(:twitter_login) || feature?(:facebook_login) || feature?(:google_login) %> + + <% if current_page?(new_user_session_path) %> + + <% if feature? :twitter_login %> + <%= link_to t("omniauth.twitter.sign_in"), user_omniauth_authorize_path(:twitter), class: "button-twitter button radius expand" %> + <% end %> + + <% if feature? :facebook_login %> + <%= link_to t("omniauth.facebook.sign_in"), user_omniauth_authorize_path(:facebook), class: "button-facebook button radius expand" %> + <% 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 %> + +
+ <% 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 %> + +
+ <% end %> + +<% end %> diff --git a/db/dev_seeds.rb b/db/dev_seeds.rb index 4f638758a..0bee91cb2 100644 --- a/db/dev_seeds.rb +++ b/db/dev_seeds.rb @@ -20,6 +20,9 @@ Setting.create(key: 'org_name', value: 'Consul') Setting.create(key: 'place_name', value: 'City') Setting.create(key: 'feature.debates', 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" ('A'..'Z').each{ |i| Geozone.create(name: "District #{i}") } diff --git a/db/seeds.rb b/db/seeds.rb index 6a6ae6671..659b3b2c0 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -53,3 +53,6 @@ Setting["place_name"] = "Consul-land" # Feature flags Setting['feature.debates'] = true Setting['feature.spending_proposals'] = true +Setting['feature.twitter_login'] = true +Setting['feature.facebook_login'] = true +Setting['feature.google_login'] = true