Make it easier to add new omniauth buttons
Since we're using the exact same logic for all existing buttons, we can just get the list of available ones and loop through them.
This commit is contained in:
@@ -1,4 +1,13 @@
|
||||
module SettingsHelper
|
||||
def oauth_logins
|
||||
[
|
||||
(:twitter if feature?(:twitter_login)),
|
||||
(:facebook if feature?(:facebook_login)),
|
||||
(:google_oauth2 if feature?(:google_login)),
|
||||
(:wordpress_oauth2 if feature?(:wordpress_login))
|
||||
].compact
|
||||
end
|
||||
|
||||
def feature?(name)
|
||||
setting["feature.#{name}"].presence || setting["process.#{name}"].presence
|
||||
end
|
||||
|
||||
@@ -6,38 +6,11 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% if feature? :twitter_login %>
|
||||
<% oauth_logins.each do |login| %>
|
||||
<div class="small-12 medium-6 large-4 column end">
|
||||
<%= link_to t("omniauth.twitter.name"), user_twitter_omniauth_authorize_path,
|
||||
title: t("omniauth.twitter.#{action}"),
|
||||
class: "button-twitter button expanded",
|
||||
method: :post %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if feature? :facebook_login %>
|
||||
<div class="small-12 medium-6 large-4 column end">
|
||||
<%= link_to t("omniauth.facebook.name"), user_facebook_omniauth_authorize_path,
|
||||
title: t("omniauth.facebook.#{action}"),
|
||||
class: "button-facebook button expanded",
|
||||
method: :post %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if feature? :google_login %>
|
||||
<div class="small-12 medium-6 large-4 column end">
|
||||
<%= link_to t("omniauth.google_oauth2.name"), user_google_oauth2_omniauth_authorize_path,
|
||||
title: t("omniauth.google_oauth2.#{action}"),
|
||||
class: "button-google button expanded",
|
||||
method: :post %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if feature? :wordpress_login %>
|
||||
<div class="small-12 medium-6 large-4 column end">
|
||||
<%= link_to t("omniauth.wordpress_oauth2.name"), user_wordpress_oauth2_omniauth_authorize_path,
|
||||
title: t("omniauth.wordpress_oauth2.#{action}"),
|
||||
class: "button-wordpress button expanded",
|
||||
<%= 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 %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
Reference in New Issue
Block a user