spree_auth 1.0.7 → 1.1.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of spree_auth might be problematic. Click here for more details.
- data/app/controllers/spree/admin/admin_users_controller_decorator.rb +16 -0
- data/app/controllers/spree/base_controller_decorator.rb +1 -1
- data/app/controllers/spree/user_passwords_controller.rb +3 -1
- data/app/controllers/spree/user_registrations_controller.rb +2 -2
- data/app/controllers/spree/user_sessions_controller.rb +1 -1
- data/app/controllers/spree/users_controller.rb +1 -0
- data/app/mailers/spree/user_mailer.rb +0 -2
- data/app/models/spree/user.rb +1 -1
- data/app/overrides/admin_payment_methods_index.rb +6 -0
- data/app/overrides/auth_admin_user_roles.rb +5 -0
- data/app/overrides/auth_user_login_form.rb +5 -0
- data/app/views/spree/admin/banners/_gateway.html.erb +14 -0
- data/app/views/spree/admin/users/_roles.html.erb +12 -0
- data/app/views/spree/shared/_login.html.erb +2 -2
- data/app/views/spree/user_registrations/new.html.erb +1 -1
- data/config/initializers/devise.rb +6 -1
- data/db/migrate/20101219201531_tokens_for_legacy_orders.rb +3 -1
- data/db/migrate/20120203010234_add_reset_password_sent_at_to_spree_users.rb +5 -0
- data/lib/spree/token_resource.rb +5 -6
- metadata +23 -36
- data/app/views/spree/checkout/registration.html.erb +0 -20
@@ -1,5 +1,21 @@
|
|
1
1
|
require File.expand_path('../../base_controller_decorator', __FILE__)
|
2
2
|
Spree::Admin::UsersController.class_eval do
|
3
3
|
rescue_from Spree::User::DestroyWithOrdersError, :with => :user_destroy_with_orders_error
|
4
|
+
|
5
|
+
update.after :sign_in_if_change_own_password
|
6
|
+
|
7
|
+
before_filter :load_roles, :only => [:edit, :new, :update, :create]
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def sign_in_if_change_own_password
|
12
|
+
if current_user == @user && @user.password.present?
|
13
|
+
sign_in(@user, :event => :authentication, :bypass => true)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def load_roles
|
18
|
+
@roles = Spree::Role.scoped
|
19
|
+
end
|
4
20
|
end
|
5
21
|
|
@@ -19,7 +19,7 @@ Spree::BaseController.class_eval do
|
|
19
19
|
format.html do
|
20
20
|
if current_user
|
21
21
|
flash.now[:error] = t(:authorization_failure)
|
22
|
-
render 'spree/shared/unauthorized', :layout => '/spree/layouts/spree_application'
|
22
|
+
render 'spree/shared/unauthorized', :layout => '/spree/layouts/spree_application', :status => 401
|
23
23
|
else
|
24
24
|
store_location
|
25
25
|
redirect_to spree.login_path and return
|
@@ -2,6 +2,8 @@ class Spree::UserPasswordsController < Devise::PasswordsController
|
|
2
2
|
include Spree::Core::ControllerHelpers
|
3
3
|
helper 'spree/users', 'spree/base'
|
4
4
|
|
5
|
+
ssl_required
|
6
|
+
|
5
7
|
after_filter :associate_user
|
6
8
|
|
7
9
|
def new
|
@@ -23,7 +25,7 @@ class Spree::UserPasswordsController < Devise::PasswordsController
|
|
23
25
|
set_flash_message(:notice, :send_instructions) if is_navigational_format?
|
24
26
|
respond_with resource, :location => spree.login_path
|
25
27
|
else
|
26
|
-
respond_with_navigational(resource){
|
28
|
+
respond_with_navigational(resource) { render :new }
|
27
29
|
end
|
28
30
|
end
|
29
31
|
|
@@ -18,11 +18,11 @@ class Spree::UserRegistrationsController < Devise::RegistrationsController
|
|
18
18
|
if resource.save
|
19
19
|
set_flash_message(:notice, :signed_up)
|
20
20
|
sign_in(:user, @user)
|
21
|
-
fire_event('spree.user.signup', :user => @user)
|
21
|
+
fire_event('spree.user.signup', :user => @user, :order => current_order(true))
|
22
22
|
sign_in_and_redirect(:user, @user)
|
23
23
|
else
|
24
24
|
clean_up_passwords(resource)
|
25
|
-
|
25
|
+
render :new
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -1,7 +1,5 @@
|
|
1
1
|
class Spree::UserMailer < ActionMailer::Base
|
2
2
|
def reset_password_instructions(user)
|
3
|
-
default_url_options[:host] = Spree::Config[:site_url]
|
4
|
-
|
5
3
|
@edit_password_reset_url = spree.edit_user_password_url(:reset_password_token => user.reset_password_token)
|
6
4
|
|
7
5
|
mail(:to => user.email,
|
data/app/models/spree/user.rb
CHANGED
@@ -15,7 +15,7 @@ module Spree
|
|
15
15
|
before_destroy :check_completed_orders
|
16
16
|
|
17
17
|
# Setup accessible (or protected) attributes for your model
|
18
|
-
attr_accessible :email, :password, :password_confirmation, :remember_me, :persistence_token
|
18
|
+
attr_accessible :email, :password, :password_confirmation, :remember_me, :persistence_token, :login, :role_ids
|
19
19
|
|
20
20
|
users_table_name = User.table_name
|
21
21
|
roles_table_name = Role.table_name
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<% if !current_user.dismissed_banner?(:gateway) &&
|
2
|
+
Spree::PaymentMethod.production.where("type != 'Spree::Gateway::Bogus'").empty? %>
|
3
|
+
|
4
|
+
<div class="banner payment_banner">
|
5
|
+
<p class="message">
|
6
|
+
<%= t(:payment_processor_choose_banner_text)%>
|
7
|
+
<%= link_to t(:payment_processor_choose_link), "http://spreecommerce.com/products/payment_processing", :target => '_blank' %>
|
8
|
+
</p>
|
9
|
+
|
10
|
+
<%= link_to t(:dismiss_banner), dismiss_banner_admin_user_path(current_user, :banner_id => :gateway),
|
11
|
+
:remote => true, :method => :post, :class => 'dismiss' %>
|
12
|
+
</div>
|
13
|
+
|
14
|
+
<% end %>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<div data-hook="admin_user_form_roles">
|
2
|
+
<p>
|
3
|
+
<%= label_tag nil, t(:roles) %><br />
|
4
|
+
<% @roles.each do |role| %>
|
5
|
+
<label class="sub">
|
6
|
+
<%= check_box_tag 'user[role_ids][]', role.id, @user.roles.include?(role), :id => "user_role_#{role.name}" %>
|
7
|
+
<%= role.name %>
|
8
|
+
</label>
|
9
|
+
<% end %>
|
10
|
+
<%= hidden_field_tag 'user[role_ids][]', '' %>
|
11
|
+
</p>
|
12
|
+
</div>
|
@@ -2,11 +2,11 @@
|
|
2
2
|
<div id="password-credentials">
|
3
3
|
<p>
|
4
4
|
<%= f.label :email, t(:email) %><br />
|
5
|
-
<%= f.email_field :email, :class => 'title' %>
|
5
|
+
<%= f.email_field :email, :class => 'title', :tabindex => 1 %>
|
6
6
|
</p>
|
7
7
|
<p>
|
8
8
|
<%= f.label :password, t(:password) %><br />
|
9
|
-
<%= f.password_field :password, :class => 'title' %>
|
9
|
+
<%= f.password_field :password, :class => 'title', :tabindex => 2 %>
|
10
10
|
</p>
|
11
11
|
</div>
|
12
12
|
<p>
|
@@ -8,7 +8,7 @@
|
|
8
8
|
<div data-hook="signup">
|
9
9
|
|
10
10
|
<%= form_for :user, :url => spree.user_registration_path(@user) do |f| %>
|
11
|
-
<div data-hook="signup_inside_form"
|
11
|
+
<div data-hook="signup_inside_form">
|
12
12
|
<%= render :partial => 'spree/shared/user_form', :locals => { :f => f } %>
|
13
13
|
<p><%= f.submit t(:create), :class => 'button primary' %></p>
|
14
14
|
</div>
|
@@ -133,4 +133,9 @@ Devise.setup do |config|
|
|
133
133
|
# end
|
134
134
|
# manager.default_strategies(:scope => :user).unshift :twitter_oauth
|
135
135
|
# end
|
136
|
-
|
136
|
+
#
|
137
|
+
# Time interval you can reset your password with a reset password key.
|
138
|
+
# Don't put a too small interval or your users won't have the time to
|
139
|
+
# change their passwords.
|
140
|
+
config.reset_password_within = 6.hours
|
141
|
+
end
|
@@ -5,7 +5,9 @@ class TokensForLegacyOrders < ActiveRecord::Migration
|
|
5
5
|
# add token permissions for legacy orders (stop relying on user persistence token)
|
6
6
|
Spree::Order.all.each do |order|
|
7
7
|
next unless order.user
|
8
|
-
|
8
|
+
permission = order.build_tokenized_permission
|
9
|
+
permission.token = order.user.persistence_token
|
10
|
+
permission.save!
|
9
11
|
end
|
10
12
|
|
11
13
|
Spree::TokenizedPermission.table_name = 'spree_tokenized_permissions'
|
data/lib/spree/token_resource.rb
CHANGED
@@ -8,16 +8,15 @@ module Spree
|
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
def create_token
|
12
|
+
permission = build_tokenized_permission
|
13
|
+
permission.token = token = ::SecureRandom::hex(8)
|
14
|
+
permission.save!
|
15
|
+
token
|
16
16
|
end
|
17
17
|
|
18
18
|
def self.included(receiver)
|
19
19
|
receiver.extend ClassMethods
|
20
|
-
receiver.send :include, InstanceMethods
|
21
20
|
end
|
22
21
|
end
|
23
22
|
end
|
metadata
CHANGED
@@ -1,64 +1,49 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.1.0.rc1
|
5
|
+
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Sean Schofield
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-04-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: spree_core
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70158929553040 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - =
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.0.
|
21
|
+
version: 1.1.0.rc1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - '='
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 1.0.7
|
24
|
+
version_requirements: *70158929553040
|
30
25
|
- !ruby/object:Gem::Dependency
|
31
26
|
name: devise
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
27
|
+
requirement: &70158929566060 !ruby/object:Gem::Requirement
|
33
28
|
none: false
|
34
29
|
requirements:
|
35
|
-
- -
|
30
|
+
- - ~>
|
36
31
|
- !ruby/object:Gem::Version
|
37
|
-
version:
|
32
|
+
version: '2.0'
|
38
33
|
type: :runtime
|
39
34
|
prerelease: false
|
40
|
-
version_requirements:
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - '='
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: 1.5.3
|
35
|
+
version_requirements: *70158929566060
|
46
36
|
- !ruby/object:Gem::Dependency
|
47
37
|
name: cancan
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
38
|
+
requirement: &70158929563020 !ruby/object:Gem::Requirement
|
49
39
|
none: false
|
50
40
|
requirements:
|
51
|
-
- -
|
41
|
+
- - =
|
52
42
|
- !ruby/object:Gem::Version
|
53
43
|
version: 1.6.7
|
54
44
|
type: :runtime
|
55
45
|
prerelease: false
|
56
|
-
version_requirements:
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - '='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 1.6.7
|
46
|
+
version_requirements: *70158929563020
|
62
47
|
description: Required dependency for Spree
|
63
48
|
email: sean@spreecommerce.com
|
64
49
|
executables: []
|
@@ -90,9 +75,13 @@ files:
|
|
90
75
|
- app/models/spree/order_decorator.rb
|
91
76
|
- app/models/spree/tokenized_permission.rb
|
92
77
|
- app/models/spree/user.rb
|
78
|
+
- app/overrides/admin_payment_methods_index.rb
|
93
79
|
- app/overrides/auth_admin_login_navigation_bar.rb
|
80
|
+
- app/overrides/auth_admin_user_roles.rb
|
94
81
|
- app/overrides/auth_shared_login_bar.rb
|
95
|
-
- app/
|
82
|
+
- app/overrides/auth_user_login_form.rb
|
83
|
+
- app/views/spree/admin/banners/_gateway.html.erb
|
84
|
+
- app/views/spree/admin/users/_roles.html.erb
|
96
85
|
- app/views/spree/layouts/admin/_login_nav.html.erb
|
97
86
|
- app/views/spree/shared/_flashes.html.erb
|
98
87
|
- app/views/spree/shared/_login.html.erb
|
@@ -122,6 +111,7 @@ files:
|
|
122
111
|
- db/migrate/20101219201531_tokens_for_legacy_orders.rb
|
123
112
|
- db/migrate/20111007143030_namespace_tokenized_permission.rb
|
124
113
|
- db/migrate/20111206075712_migrate_tokenized_permissions.rb
|
114
|
+
- db/migrate/20120203010234_add_reset_password_sent_at_to_spree_users.rb
|
125
115
|
- db/seeds.rb
|
126
116
|
homepage: http://spreecommerce.com
|
127
117
|
licenses: []
|
@@ -138,16 +128,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
138
128
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
129
|
none: false
|
140
130
|
requirements:
|
141
|
-
- - ! '
|
131
|
+
- - ! '>'
|
142
132
|
- !ruby/object:Gem::Version
|
143
|
-
version:
|
144
|
-
segments:
|
145
|
-
- 0
|
146
|
-
hash: 3901928345748841813
|
133
|
+
version: 1.3.1
|
147
134
|
requirements:
|
148
135
|
- none
|
149
136
|
rubyforge_project:
|
150
|
-
rubygems_version: 1.8.
|
137
|
+
rubygems_version: 1.8.10
|
151
138
|
signing_key:
|
152
139
|
specification_version: 3
|
153
140
|
summary: Provides authentication and authorization services for use with Spree.
|
@@ -1,20 +0,0 @@
|
|
1
|
-
<%= render :partial => 'spree/shared/error_messages', :locals => { :target => @user } %>
|
2
|
-
<h2><%= t(:registration) %></h2>
|
3
|
-
<div id="registration">
|
4
|
-
<div id="account" class="columns alpha eight">
|
5
|
-
<%= render :file => 'spree/user_sessions/new' %>
|
6
|
-
</div>
|
7
|
-
<% if Spree::Config[:allow_guest_checkout] %>
|
8
|
-
<div id="guest_checkout" class="columns omega eight">
|
9
|
-
<%= render :partial => 'spree/shared/error_messages', :locals => { :target => @order } %>
|
10
|
-
<h6><%= t(:guest_user_account) %></h6>
|
11
|
-
<%= form_for @order, :url => spree.update_checkout_registration_path, :method => :put, :html => { :id => 'checkout_form_registration' } do |f| %>
|
12
|
-
<p>
|
13
|
-
<%= f.label :email, t(:email) %><br />
|
14
|
-
<%= f.email_field :email, :class => 'title' %>
|
15
|
-
</p>
|
16
|
-
<p><%= f.submit t(:continue), :class => 'button primary' %></p>
|
17
|
-
<% end %>
|
18
|
-
</div>
|
19
|
-
<% end %>
|
20
|
-
</div>
|