Hide "Sign In Through One Of These Services:" text when no services are available and improve Facebook and Twitter login #25

Closed
wants to merge 4 commits into
from
@@ -1,3 +1,13 @@
class Spree::AuthenticationMethod < ActiveRecord::Base
attr_accessible :provider, :api_key, :api_secret, :environment, :active
+
+ def self.active_authentication_methods?
+ found = false
+ where(:environment => ::Rails.env).each do |method|
+ if method.active
+ found = true
+ end
+ end
+ return found
+ end
end
@@ -4,6 +4,10 @@
devise :omniauthable
def apply_omniauth(omniauth)
+ if omniauth['provider'] == "facebook"
+ self.email = omniauth['info']['email'] if email.blank?
+ end
+
user_authentications.build(:provider => omniauth['provider'], :uid => omniauth['uid'])
end
@@ -9,3 +9,9 @@
:insert_after => "[data-hook='login_extras']",
:partial => "spree/shared/social",
:disabled => false)
+
+Deface::Override.new(:virtual_path => "spree/user_registrations/new",
+ :name => "remove_new_customer_if_seesionomniauth",
+ :replace => "div#new-customer h6",
+ :partial => "spree/users/new-customer",
+ :disabled => false)
@@ -1,4 +1,4 @@
-<% if !current_user || !current_user.user_authentications %>
+<% if (!current_user || !current_user.user_authentications) && Spree::AuthenticationMethod.active_authentication_methods? %>
<h2><%= t(:sign_in_through_one_of_these_services) %>:</h2>
<% end %>
<% Spree::AuthenticationMethod.where(:environment => ::Rails.env).each do |method| %>
@@ -2,16 +2,18 @@
<%= f.label :email, t(:email) %><br />
<%= f.email_field :email, :class => 'title' %>
</p>
-<div id="password-credentials">
- <p>
- <%= f.label :password, t(:password) %><br />
- <%= f.password_field :password, :class => 'title' %>
- </p>
+<% if @user.password_required? %>
+ <div id="password-credentials">
+ <p>
+ <%= f.label :password, t(:password) %><br />
+ <%= f.password_field :password, :class => 'title' %>
+ </p>
- <p>
- <%= f.label :password_confirmation, t(:confirm_password) %><br />
- <%= f.password_field :password_confirmation, :class => 'title' %>
- </p>
-</div>
+ <p>
+ <%= f.label :password_confirmation, t(:confirm_password) %><br />
+ <%= f.password_field :password_confirmation, :class => 'title' %>
+ </p>
+ </div>
+<% end %>
<div data-hook="signup_below_password_fields"></div>
@@ -0,0 +1,7 @@
+<% if session[:omniauth] %>
+ <h6><%=t(:please_confirm_your_email) %></h6>
+<% else %>
+ <h6><%= t(:new_customer) %></h6>
+<% end %>
+
+
@@ -1,3 +1,4 @@
+<% if Spree::AuthenticationMethod.active_authentication_methods? %>
<% @body_id = 'login' %>
<div id="existing-customer">
<table>
@@ -36,3 +37,4 @@
</div>
<div class="clear"></div>
+<% end %>
View
@@ -11,3 +11,4 @@ en:
social_authentication_methods: "Social Authentication Methods"
social_authentication_methods_description: "Setup OAuth Authentication Methods"
social_provider: "Social Provider"
+ please_confirm_your_email: "Please confirm your email address to continue"