-
-
- <%= t("omniauth.info_sign_up") %>
-
+ <% oauth_logins.each do |login| %>
+
+ <%= link_to t("omniauth.#{login}.name"), send("user_#{login}_omniauth_authorize_path"),
+ title: t("omniauth.#{login}.#{action}"),
+ class: "button-#{login.to_s.delete_suffix("_oauth2")} button expanded",
+ method: :post %>
+ <% end %>
- <% if feature? :twitter_login %>
-
- <%= link_to t("omniauth.twitter.name"), user_twitter_omniauth_authorize_path,
- title: t("omniauth.twitter.sign_up"),
- class: "button-twitter button expanded",
- method: :post %>
-
- <% end %>
-
- <% if feature? :facebook_login %>
-
- <%= link_to t("omniauth.facebook.name"), user_facebook_omniauth_authorize_path,
- title: t("omniauth.facebook.sign_up"),
- class: "button-facebook button expanded",
- method: :post %>
-
- <% end %>
-
- <% if feature? :google_login %>
-
- <%= link_to t("omniauth.google_oauth2.name"), user_google_oauth2_omniauth_authorize_path,
- title: t("omniauth.google_oauth2.sign_up"),
- class: "button-google button expanded",
- method: :post %>
-
-
- <% end %>
-
- <% if feature? :wordpress_login %>
-
- <%= link_to t("omniauth.wordpress_oauth2.name"), user_wordpress_oauth2_omniauth_authorize_path,
- title: t("omniauth.wordpress_oauth2.sign_up"),
- class: "button-wordpress button expanded",
- method: :post %>
-
- <% end %>
-
-
- <%= t("omniauth.or_fill") %>
-
+
+ <%= t("omniauth.or_fill") %>
- <% end %>
-
+
<% end %>
diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb
index d0d219c62..85ae3d320 100644
--- a/app/views/devise/sessions/new.html.erb
+++ b/app/views/devise/sessions/new.html.erb
@@ -1,7 +1,7 @@
<% provide :title do %><%= t("devise_views.sessions.new.title") %><% end %>
<%= t("devise_views.sessions.new.title") %>
-<%= render "devise/omniauth_form" %>
+<%= render "devise/omniauth_form", action: "sign_in" %>
<%= sanitize(t("devise_views.shared.links.signup",
diff --git a/app/views/users/registrations/new.html.erb b/app/views/users/registrations/new.html.erb
index f296d3b69..7dafa264f 100644
--- a/app/views/users/registrations/new.html.erb
+++ b/app/views/users/registrations/new.html.erb
@@ -1,7 +1,7 @@
<% provide :title do %><%= t("devise_views.users.registrations.new.title") %><% end %>
<%= t("devise_views.users.registrations.new.title") %>
-<%= render "devise/omniauth_form" %>
+<%= render "devise/omniauth_form", action: "sign_up" %>
<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
<%= render "shared/errors", resource: resource %>
diff --git a/config/locales/en/general.yml b/config/locales/en/general.yml
index 24fb4fe6f..23dc76513 100644
--- a/config/locales/en/general.yml
+++ b/config/locales/en/general.yml
@@ -299,8 +299,9 @@ en:
sign_in: Sign in with Twitter
sign_up: Sign up with Twitter
name: Twitter
- info_sign_in: "Sign in with:"
- info_sign_up: "Sign up with:"
+ info:
+ sign_in: "Sign in with:"
+ sign_up: "Sign up with:"
or_fill: "Or fill the following form:"
proposals:
create:
diff --git a/config/locales/es/general.yml b/config/locales/es/general.yml
index 92de921d8..dda320025 100644
--- a/config/locales/es/general.yml
+++ b/config/locales/es/general.yml
@@ -299,8 +299,9 @@ es:
sign_in: Entra con Twitter
sign_up: Regístrate con Twitter
name: Twitter
- info_sign_in: "Entra con:"
- info_sign_up: "Regístrate con:"
+ info:
+ sign_in: "Entra con:"
+ sign_up: "Regístrate con:"
or_fill: "O rellena el siguiente formulario:"
proposals:
create:
diff --git a/spec/system/users_auth_spec.rb b/spec/system/users_auth_spec.rb
index 4b38b80ec..63663ca7c 100644
--- a/spec/system/users_auth_spec.rb
+++ b/spec/system/users_auth_spec.rb
@@ -100,6 +100,103 @@ describe "Users" do
end
context "OAuth authentication" do
+ context "Form buttons" do
+ before do
+ Setting["feature.facebook_login"] = false
+ Setting["feature.twitter_login"] = false
+ Setting["feature.google_login"] = false
+ Setting["feature.wordpress_login"] = false
+ end
+
+ scenario "No button will appear if all features are disabled" do
+ visit new_user_registration_path
+
+ expect(page).not_to have_link "Twitter"
+ expect(page).not_to have_link "Facebook"
+ expect(page).not_to have_link "Google"
+ expect(page).not_to have_link "Wordpress"
+
+ visit new_user_session_path
+
+ expect(page).not_to have_link "Twitter"
+ expect(page).not_to have_link "Facebook"
+ expect(page).not_to have_link "Google"
+ expect(page).not_to have_link "Wordpress"
+ end
+
+ scenario "Twitter login button will appear if feature is enabled" do
+ Setting["feature.twitter_login"] = true
+
+ visit new_user_registration_path
+
+ expect(page).to have_link "Twitter"
+ expect(page).not_to have_link "Facebook"
+ expect(page).not_to have_link "Google"
+ expect(page).not_to have_link "Wordpress"
+
+ visit new_user_session_path
+
+ expect(page).to have_link "Twitter"
+ expect(page).not_to have_link "Facebook"
+ expect(page).not_to have_link "Google"
+ expect(page).not_to have_link "Wordpress"
+ end
+
+ scenario "Facebook login button will appear if feature is enabled" do
+ Setting["feature.facebook_login"] = true
+
+ visit new_user_registration_path
+
+ expect(page).not_to have_link "Twitter"
+ expect(page).to have_link "Facebook"
+ expect(page).not_to have_link "Google"
+ expect(page).not_to have_link "Wordpress"
+
+ visit new_user_session_path
+
+ expect(page).not_to have_link "Twitter"
+ expect(page).to have_link "Facebook"
+ expect(page).not_to have_link "Google"
+ expect(page).not_to have_link "Wordpress"
+ end
+
+ scenario "Google login button will appear if feature is enabled" do
+ Setting["feature.google_login"] = true
+
+ visit new_user_registration_path
+
+ expect(page).not_to have_link "Twitter"
+ expect(page).not_to have_link "Facebook"
+ expect(page).to have_link "Google"
+ expect(page).not_to have_link "Wordpress"
+
+ visit new_user_session_path
+
+ expect(page).not_to have_link "Twitter"
+ expect(page).not_to have_link "Facebook"
+ expect(page).to have_link "Google"
+ expect(page).not_to have_link "Wordpress"
+ end
+
+ scenario "Wordpress login button will appear if feature is enabled" do
+ Setting["feature.wordpress_login"] = true
+
+ visit new_user_registration_path
+
+ expect(page).not_to have_link "Twitter"
+ expect(page).not_to have_link "Facebook"
+ expect(page).not_to have_link "Google"
+ expect(page).to have_link "Wordpress"
+
+ visit new_user_session_path
+
+ expect(page).not_to have_link "Twitter"
+ expect(page).not_to have_link "Facebook"
+ expect(page).not_to have_link "Google"
+ expect(page).to have_link "Wordpress"
+ end
+ end
+
context "Twitter" do
let(:twitter_hash) { { provider: "twitter", uid: "12345", info: { name: "manuela" }} }
let(:twitter_hash_with_email) { { provider: "twitter", uid: "12345", info: { name: "manuela", email: "manuelacarmena@example.com" }} }