Skip to content
This repository has been archived by the owner on Nov 15, 2018. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'spree_social/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
damdiginess committed Apr 7, 2012
2 parents 285f453 + 967ca36 commit a603702
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 11 deletions.
10 changes: 10 additions & 0 deletions app/models/spree/authentication_method.rb
Original file line number Diff line number Diff line change
@@ -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 changes: 4 additions & 0 deletions app/models/spree/user_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions app/overrides/user_registrations_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,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)
2 changes: 1 addition & 1 deletion app/views/spree/shared/_social.html.erb
Original file line number Diff line number Diff line change
@@ -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| %>
Expand Down
22 changes: 12 additions & 10 deletions app/views/spree/shared/_user_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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>
7 changes: 7 additions & 0 deletions app/views/spree/users/_new-customer.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<% if session[:omniauth] %>
<h6><%=t(:please_confirm_your_email) %></h6>
<% else %>
<h6><%= t(:new_customer) %></h6>
<% end %>


2 changes: 2 additions & 0 deletions app/views/spree/users/_social.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<% if Spree::AuthenticationMethod.active_authentication_methods? %>
<% @body_id = 'login' %>
<div id="existing-customer">
<table>
Expand Down Expand Up @@ -36,3 +37,4 @@
</div>

<div class="clear"></div>
<% end %>
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,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"

0 comments on commit a603702

Please sign in to comment.