spree_auth 0.70.7 → 1.0.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/LICENSE +2 -2
- data/README.md +0 -4
- data/app/controllers/resource_controller_decorator.rb +13 -13
- data/app/controllers/spree/admin/admin_controller_decorator.rb +19 -0
- data/app/controllers/spree/admin/admin_orders_controller_decorator.rb +14 -0
- data/app/controllers/spree/admin/admin_resource_controller_decorator.rb +3 -0
- data/app/controllers/spree/base_controller_decorator.rb +33 -32
- data/app/controllers/spree/checkout_controller_decorator.rb +41 -0
- data/app/controllers/spree/orders_controller_decorator.rb +15 -0
- data/app/controllers/{user_passwords_controller.rb → spree/user_passwords_controller.rb} +13 -14
- data/app/controllers/{user_registrations_controller.rb → spree/user_registrations_controller.rb} +11 -13
- data/app/controllers/{user_sessions_controller.rb → spree/user_sessions_controller.rb} +15 -17
- data/app/controllers/{users_controller.rb → spree/users_controller.rb} +8 -12
- data/app/helpers/spree/users_helper.rb +15 -0
- data/app/mailers/spree/user_mailer.rb +10 -0
- data/app/models/spree/ability.rb +65 -0
- data/app/models/spree/auth_configuration.rb +6 -0
- data/app/models/{spree_current_order_decorator.rb → spree/current_order_decorator.rb} +1 -3
- data/app/models/{order_decorator.rb → spree/order_decorator.rb} +1 -1
- data/app/models/spree/tokenized_permission.rb +5 -0
- data/app/models/spree/user.rb +87 -0
- data/app/overrides/auth_admin_login_navigation_bar.rb +2 -2
- data/app/overrides/auth_shared_login_bar.rb +2 -2
- data/app/views/spree/checkout/registration.html.erb +20 -0
- data/app/views/spree/layouts/admin/_login_nav.html.erb +8 -0
- data/app/views/{shared → spree/shared}/_flashes.html.erb +0 -0
- data/app/views/{shared → spree/shared}/_login.html.erb +3 -3
- data/app/views/spree/shared/_login_bar.html.erb +6 -0
- data/app/views/{shared → spree/shared}/_user_form.html.erb +1 -1
- data/app/views/{shared → spree/shared}/unauthorized.html.erb +0 -0
- data/app/views/{user_mailer → spree/user_mailer}/reset_password_instructions.text.erb +0 -0
- data/app/views/spree/user_passwords/edit.html.erb +15 -0
- data/app/views/spree/user_passwords/new.html.erb +13 -0
- data/app/views/spree/user_registrations/new.html.erb +22 -0
- data/app/views/{user_sessions → spree/user_sessions}/authorization_failure.html.erb +0 -0
- data/app/views/{user_sessions → spree/user_sessions}/new.html.erb +2 -2
- data/app/views/spree/users/edit.html.erb +11 -0
- data/app/views/{users → spree/users}/show.html.erb +2 -2
- data/config/initializers/devise.rb +6 -6
- data/config/locales/en.yml +5 -5
- data/config/routes.rb +12 -9
- data/db/default/users.rb +22 -12
- data/db/migrate/20101026184950_rename_columns_for_devise.rb +33 -33
- data/db/migrate/20101214150824_convert_user_remember_field.rb +7 -7
- data/db/migrate/20101217012656_create_tokenized_permissions.rb +3 -8
- data/db/migrate/20101219201531_tokens_for_legacy_orders.rb +7 -3
- data/db/migrate/20111007143030_namespace_tokenized_permission.rb +5 -0
- data/db/migrate/20111206075712_migrate_tokenized_permissions.rb +24 -0
- data/db/seeds.rb +1 -1
- data/lib/spree/auth/engine.rb +25 -0
- data/lib/spree/auth.rb +15 -0
- data/lib/spree/token_resource.rb +17 -17
- data/lib/spree_auth.rb +1 -24
- metadata +63 -55
- data/app/controllers/admin_controller_decorator.rb +0 -13
- data/app/controllers/admin_orders_controller_decorator.rb +0 -15
- data/app/controllers/admin_resource_controller_decorator.rb +0 -3
- data/app/controllers/checkout_controller_decorator.rb +0 -42
- data/app/controllers/orders_controller_decorator.rb +0 -17
- data/app/helpers/users_helper.rb +0 -13
- data/app/models/ability.rb +0 -64
- data/app/models/spree_auth_configuration.rb +0 -4
- data/app/models/tokenized_permission.rb +0 -3
- data/app/models/user.rb +0 -85
- data/app/models/user_mailer.rb +0 -13
- data/app/views/checkout/registration.html.erb +0 -20
- data/app/views/layouts/admin/_login_nav.html.erb +0 -8
- data/app/views/shared/_login_bar.html.erb +0 -6
- data/app/views/user_passwords/edit.html.erb +0 -15
- data/app/views/user_passwords/new.html.erb +0 -13
- data/app/views/user_registrations/new.html.erb +0 -22
- data/app/views/users/edit.html.erb +0 -11
- data/config/cucumber.yml +0 -10
- data/lib/spree/auth/config.rb +0 -22
metadata
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 15424055
|
5
|
+
prerelease: 6
|
6
6
|
segments:
|
7
|
+
- 1
|
7
8
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
|
9
|
+
- 0
|
10
|
+
- rc
|
11
|
+
- 1
|
12
|
+
version: 1.0.0.rc1
|
11
13
|
platform: ruby
|
12
14
|
authors:
|
13
15
|
- Sean Schofield
|
@@ -15,7 +17,7 @@ autorequire:
|
|
15
17
|
bindir: bin
|
16
18
|
cert_chain: []
|
17
19
|
|
18
|
-
date:
|
20
|
+
date: 2011-12-23 00:00:00 Z
|
19
21
|
dependencies:
|
20
22
|
- !ruby/object:Gem::Dependency
|
21
23
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|
@@ -23,12 +25,14 @@ dependencies:
|
|
23
25
|
requirements:
|
24
26
|
- - "="
|
25
27
|
- !ruby/object:Gem::Version
|
26
|
-
hash:
|
28
|
+
hash: 15424055
|
27
29
|
segments:
|
30
|
+
- 1
|
28
31
|
- 0
|
29
|
-
-
|
30
|
-
-
|
31
|
-
|
32
|
+
- 0
|
33
|
+
- rc
|
34
|
+
- 1
|
35
|
+
version: 1.0.0.rc1
|
32
36
|
requirement: *id001
|
33
37
|
type: :runtime
|
34
38
|
prerelease: false
|
@@ -39,12 +43,12 @@ dependencies:
|
|
39
43
|
requirements:
|
40
44
|
- - "="
|
41
45
|
- !ruby/object:Gem::Version
|
42
|
-
hash:
|
46
|
+
hash: 23
|
43
47
|
segments:
|
44
48
|
- 1
|
45
49
|
- 4
|
46
|
-
-
|
47
|
-
version: 1.4.
|
50
|
+
- 8
|
51
|
+
version: 1.4.8
|
48
52
|
requirement: *id002
|
49
53
|
type: :runtime
|
50
54
|
prerelease: false
|
@@ -55,12 +59,12 @@ dependencies:
|
|
55
59
|
requirements:
|
56
60
|
- - "="
|
57
61
|
- !ruby/object:Gem::Version
|
58
|
-
hash:
|
62
|
+
hash: 1
|
59
63
|
segments:
|
60
64
|
- 1
|
61
65
|
- 6
|
62
|
-
-
|
63
|
-
version: 1.6.
|
66
|
+
- 7
|
67
|
+
version: 1.6.7
|
64
68
|
requirement: *id003
|
65
69
|
type: :runtime
|
66
70
|
prerelease: false
|
@@ -80,47 +84,47 @@ files:
|
|
80
84
|
- app/assets/javascripts/store/spree_auth.js
|
81
85
|
- app/assets/stylesheets/admin/spree_auth.css
|
82
86
|
- app/assets/stylesheets/store/spree_auth.css
|
83
|
-
- app/controllers/admin_controller_decorator.rb
|
84
|
-
- app/controllers/admin_orders_controller_decorator.rb
|
85
|
-
- app/controllers/admin_resource_controller_decorator.rb
|
86
|
-
- app/controllers/checkout_controller_decorator.rb
|
87
|
-
- app/controllers/orders_controller_decorator.rb
|
88
87
|
- app/controllers/resource_controller_decorator.rb
|
88
|
+
- app/controllers/spree/admin/admin_controller_decorator.rb
|
89
|
+
- app/controllers/spree/admin/admin_orders_controller_decorator.rb
|
90
|
+
- app/controllers/spree/admin/admin_resource_controller_decorator.rb
|
89
91
|
- app/controllers/spree/base_controller_decorator.rb
|
90
|
-
- app/controllers/
|
91
|
-
- app/controllers/
|
92
|
-
- app/controllers/
|
93
|
-
- app/controllers/
|
94
|
-
- app/
|
95
|
-
- app/
|
96
|
-
- app/
|
97
|
-
- app/
|
98
|
-
- app/models/
|
99
|
-
- app/models/
|
100
|
-
- app/models/
|
101
|
-
- app/models/
|
92
|
+
- app/controllers/spree/checkout_controller_decorator.rb
|
93
|
+
- app/controllers/spree/orders_controller_decorator.rb
|
94
|
+
- app/controllers/spree/user_passwords_controller.rb
|
95
|
+
- app/controllers/spree/user_registrations_controller.rb
|
96
|
+
- app/controllers/spree/user_sessions_controller.rb
|
97
|
+
- app/controllers/spree/users_controller.rb
|
98
|
+
- app/helpers/spree/users_helper.rb
|
99
|
+
- app/mailers/spree/user_mailer.rb
|
100
|
+
- app/models/spree/ability.rb
|
101
|
+
- app/models/spree/auth_configuration.rb
|
102
|
+
- app/models/spree/current_order_decorator.rb
|
103
|
+
- app/models/spree/order_decorator.rb
|
104
|
+
- app/models/spree/tokenized_permission.rb
|
105
|
+
- app/models/spree/user.rb
|
102
106
|
- app/overrides/auth_admin_login_navigation_bar.rb
|
103
107
|
- app/overrides/auth_shared_login_bar.rb
|
104
|
-
- app/views/checkout/registration.html.erb
|
105
|
-
- app/views/layouts/admin/_login_nav.html.erb
|
106
|
-
- app/views/shared/_flashes.html.erb
|
107
|
-
- app/views/shared/_login.html.erb
|
108
|
-
- app/views/shared/_login_bar.html.erb
|
109
|
-
- app/views/shared/_user_form.html.erb
|
110
|
-
- app/views/shared/unauthorized.html.erb
|
111
|
-
- app/views/user_mailer/reset_password_instructions.text.erb
|
112
|
-
- app/views/user_passwords/edit.html.erb
|
113
|
-
- app/views/user_passwords/new.html.erb
|
114
|
-
- app/views/user_registrations/new.html.erb
|
115
|
-
- app/views/user_sessions/authorization_failure.html.erb
|
116
|
-
- app/views/user_sessions/new.html.erb
|
117
|
-
- app/views/users/edit.html.erb
|
118
|
-
- app/views/users/show.html.erb
|
119
|
-
- config/cucumber.yml
|
108
|
+
- app/views/spree/checkout/registration.html.erb
|
109
|
+
- app/views/spree/layouts/admin/_login_nav.html.erb
|
110
|
+
- app/views/spree/shared/_flashes.html.erb
|
111
|
+
- app/views/spree/shared/_login.html.erb
|
112
|
+
- app/views/spree/shared/_login_bar.html.erb
|
113
|
+
- app/views/spree/shared/_user_form.html.erb
|
114
|
+
- app/views/spree/shared/unauthorized.html.erb
|
115
|
+
- app/views/spree/user_mailer/reset_password_instructions.text.erb
|
116
|
+
- app/views/spree/user_passwords/edit.html.erb
|
117
|
+
- app/views/spree/user_passwords/new.html.erb
|
118
|
+
- app/views/spree/user_registrations/new.html.erb
|
119
|
+
- app/views/spree/user_sessions/authorization_failure.html.erb
|
120
|
+
- app/views/spree/user_sessions/new.html.erb
|
121
|
+
- app/views/spree/users/edit.html.erb
|
122
|
+
- app/views/spree/users/show.html.erb
|
120
123
|
- config/initializers/devise.rb
|
121
124
|
- config/locales/en.yml
|
122
125
|
- config/routes.rb
|
123
|
-
- lib/spree/auth/
|
126
|
+
- lib/spree/auth/engine.rb
|
127
|
+
- lib/spree/auth.rb
|
124
128
|
- lib/spree/token_resource.rb
|
125
129
|
- lib/spree_auth.rb
|
126
130
|
- lib/tasks/auth.rake
|
@@ -129,6 +133,8 @@ files:
|
|
129
133
|
- db/migrate/20101214150824_convert_user_remember_field.rb
|
130
134
|
- db/migrate/20101217012656_create_tokenized_permissions.rb
|
131
135
|
- db/migrate/20101219201531_tokens_for_legacy_orders.rb
|
136
|
+
- db/migrate/20111007143030_namespace_tokenized_permission.rb
|
137
|
+
- db/migrate/20111206075712_migrate_tokenized_permissions.rb
|
132
138
|
- db/seeds.rb
|
133
139
|
homepage: http://spreecommerce.com
|
134
140
|
licenses: []
|
@@ -152,15 +158,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
152
158
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
159
|
none: false
|
154
160
|
requirements:
|
155
|
-
- - "
|
161
|
+
- - ">"
|
156
162
|
- !ruby/object:Gem::Version
|
157
|
-
hash:
|
163
|
+
hash: 25
|
158
164
|
segments:
|
159
|
-
-
|
160
|
-
|
165
|
+
- 1
|
166
|
+
- 3
|
167
|
+
- 1
|
168
|
+
version: 1.3.1
|
161
169
|
requirements:
|
162
170
|
- none
|
163
|
-
rubyforge_project:
|
171
|
+
rubyforge_project:
|
164
172
|
rubygems_version: 1.8.10
|
165
173
|
signing_key:
|
166
174
|
specification_version: 3
|
@@ -1,13 +0,0 @@
|
|
1
|
-
Admin::BaseController.class_eval do
|
2
|
-
before_filter :authorize_admin
|
3
|
-
|
4
|
-
def authorize_admin
|
5
|
-
begin
|
6
|
-
model = controller_name.classify.constantize
|
7
|
-
rescue
|
8
|
-
model = Object
|
9
|
-
end
|
10
|
-
authorize! :admin, model
|
11
|
-
authorize! params[:action].to_sym, model
|
12
|
-
end
|
13
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
Admin::OrdersController.class_eval do
|
2
|
-
before_filter :check_authorization
|
3
|
-
|
4
|
-
private
|
5
|
-
|
6
|
-
def check_authorization
|
7
|
-
load_order
|
8
|
-
session[:access_token] ||= params[:token]
|
9
|
-
|
10
|
-
resource = @order || Order
|
11
|
-
action = params[:action].to_sym
|
12
|
-
|
13
|
-
authorize! action, resource, session[:access_token]
|
14
|
-
end
|
15
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
CheckoutController.class_eval do
|
2
|
-
before_filter :check_authorization
|
3
|
-
before_filter :check_registration, :except => [:registration, :update_registration]
|
4
|
-
|
5
|
-
helper :users
|
6
|
-
|
7
|
-
def registration
|
8
|
-
@user = User.new
|
9
|
-
end
|
10
|
-
|
11
|
-
def update_registration
|
12
|
-
# hack - temporarily change the state to something other than cart so we can validate the order email address
|
13
|
-
current_order.state = "address"
|
14
|
-
if current_order.update_attributes(params[:order])
|
15
|
-
redirect_to checkout_path
|
16
|
-
else
|
17
|
-
@user = User.new
|
18
|
-
render 'registration'
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
def check_authorization
|
24
|
-
authorize!(:edit, current_order, session[:access_token])
|
25
|
-
end
|
26
|
-
|
27
|
-
# Introduces a registration step whenever the +registration_step+ preference is true.
|
28
|
-
def check_registration
|
29
|
-
return unless Spree::Auth::Config[:registration_step]
|
30
|
-
return if current_user or current_order.email
|
31
|
-
store_location
|
32
|
-
redirect_to checkout_registration_path
|
33
|
-
end
|
34
|
-
|
35
|
-
# Overrides the equivalent method defined in spree_core. This variation of the method will ensure that users
|
36
|
-
# are redirected to the tokenized order url unless authenticated as a registered user.
|
37
|
-
def completion_route
|
38
|
-
return order_path(@order) if current_user
|
39
|
-
token_order_path(@order, @order.token)
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
OrdersController.class_eval do
|
2
|
-
before_filter :check_authorization
|
3
|
-
|
4
|
-
private
|
5
|
-
|
6
|
-
def check_authorization
|
7
|
-
session[:access_token] ||= params[:token]
|
8
|
-
order = Order.find_by_number(params[:id]) || current_order
|
9
|
-
|
10
|
-
if order
|
11
|
-
authorize! :edit, order, session[:access_token]
|
12
|
-
else
|
13
|
-
authorize! :create, Order
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
data/app/helpers/users_helper.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
module UsersHelper
|
2
|
-
def password_style(user)
|
3
|
-
ActiveSupport::Deprecation.warn "[SPREE] Password style has be depreciated due to the removal of OpenID from the Auth Gem. "
|
4
|
-
"Please install the spree_social gem to regain this functionality and more."
|
5
|
-
""
|
6
|
-
end
|
7
|
-
def openid_style(user)
|
8
|
-
ActiveSupport::Deprecation.warn "[SPREE] Password style has be depreciated due to the removal of OpenID from the Auth Gem. "
|
9
|
-
"Please install the spree_social gem to regain this functionality and more."
|
10
|
-
"display:none"
|
11
|
-
end
|
12
|
-
|
13
|
-
end
|
data/app/models/ability.rb
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
# Implementation class for Cancan gem. Instead of overriding this class, consider adding new permissions
|
2
|
-
# using the special +register_ability+ method which allows extensions to add their own abilities.
|
3
|
-
#
|
4
|
-
# See http://github.com/ryanb/cancan for more details on cancan.
|
5
|
-
class Ability
|
6
|
-
include CanCan::Ability
|
7
|
-
|
8
|
-
class_attribute :abilities
|
9
|
-
self.abilities = Set.new
|
10
|
-
|
11
|
-
# Allows us to go beyond the standard cancan initialize method which makes it difficult for engines to
|
12
|
-
# modify the default +Ability+ of an application. The +ability+ argument must be a class that includes
|
13
|
-
# the +CanCan::Ability+ module. The registered ability should behave properly as a stand-alone class
|
14
|
-
# and therefore should be easy to test in isolation.
|
15
|
-
def self.register_ability(ability)
|
16
|
-
self.abilities.add(ability)
|
17
|
-
end
|
18
|
-
|
19
|
-
def initialize(user)
|
20
|
-
self.clear_aliased_actions
|
21
|
-
|
22
|
-
# override cancan default aliasing (we don't want to differentiate between read and index)
|
23
|
-
alias_action :edit, :to => :update
|
24
|
-
alias_action :new, :to => :create
|
25
|
-
alias_action :new_action, :to => :create
|
26
|
-
alias_action :show, :to => :read
|
27
|
-
|
28
|
-
user ||= User.new
|
29
|
-
if user.has_role? 'admin'
|
30
|
-
can :manage, :all
|
31
|
-
else
|
32
|
-
#############################
|
33
|
-
can :read, User do |resource|
|
34
|
-
resource == user
|
35
|
-
end
|
36
|
-
can :update, User do |resource|
|
37
|
-
resource == user
|
38
|
-
end
|
39
|
-
can :create, User
|
40
|
-
#############################
|
41
|
-
can :read, Order do |order, token|
|
42
|
-
order.user == user || order.token && token == order.token
|
43
|
-
end
|
44
|
-
can :update, Order do |order, token|
|
45
|
-
order.user == user || order.token && token == order.token
|
46
|
-
end
|
47
|
-
can :create, Order
|
48
|
-
#############################
|
49
|
-
can :read, Product
|
50
|
-
can :index, Product
|
51
|
-
#############################
|
52
|
-
can :read, Taxon
|
53
|
-
can :index, Taxon
|
54
|
-
#############################
|
55
|
-
end
|
56
|
-
|
57
|
-
#include any abilities registered by extensions, etc.
|
58
|
-
Ability.abilities.each do |clazz|
|
59
|
-
ability = clazz.send(:new, user)
|
60
|
-
@rules = rules + ability.send(:rules)
|
61
|
-
end
|
62
|
-
|
63
|
-
end
|
64
|
-
end
|
data/app/models/user.rb
DELETED
@@ -1,85 +0,0 @@
|
|
1
|
-
class User < ActiveRecord::Base
|
2
|
-
|
3
|
-
devise :database_authenticatable, :token_authenticatable, :registerable, :recoverable,
|
4
|
-
:rememberable, :trackable, :validatable, :encryptable, :encryptor => "authlogic_sha512"
|
5
|
-
|
6
|
-
has_many :orders
|
7
|
-
has_and_belongs_to_many :roles
|
8
|
-
belongs_to :ship_address, :foreign_key => "ship_address_id", :class_name => "Address"
|
9
|
-
belongs_to :bill_address, :foreign_key => "bill_address_id", :class_name => "Address"
|
10
|
-
|
11
|
-
before_save :check_admin
|
12
|
-
before_validation :set_login
|
13
|
-
|
14
|
-
# Setup accessible (or protected) attributes for your model
|
15
|
-
attr_accessible :email, :password, :password_confirmation, :remember_me, :persistence_token
|
16
|
-
|
17
|
-
scope :admin, lambda { includes(:roles).where("roles.name" => "admin") }
|
18
|
-
scope :registered, where("users.email NOT LIKE ?", "%@example.net")
|
19
|
-
|
20
|
-
# has_role? simply needs to return true or false whether a user has a role or not.
|
21
|
-
def has_role?(role_in_question)
|
22
|
-
roles.any? { |role| role.name == role_in_question.to_s }
|
23
|
-
end
|
24
|
-
|
25
|
-
# Creates an anonymous user. An anonymous user is basically an auto-generated +User+ account that is created for the customer
|
26
|
-
# behind the scenes and its completely transparently to the customer. All +Orders+ must have a +User+ so this is necessary
|
27
|
-
# when adding to the "cart" (which is really an order) and before the customer has a chance to provide an email or to register.
|
28
|
-
def self.anonymous!
|
29
|
-
token = User.generate_token(:persistence_token)
|
30
|
-
User.create(:email => "#{token}@example.net", :password => token, :password_confirmation => token, :persistence_token => token)
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.admin_created?
|
34
|
-
User.admin.count > 0
|
35
|
-
end
|
36
|
-
|
37
|
-
def anonymous?
|
38
|
-
email =~ /@example.net$/
|
39
|
-
end
|
40
|
-
|
41
|
-
def send_reset_password_instructions
|
42
|
-
generate_reset_password_token!
|
43
|
-
UserMailer.reset_password_instructions(self).deliver
|
44
|
-
end
|
45
|
-
|
46
|
-
protected
|
47
|
-
def password_required?
|
48
|
-
!persisted? || password.present? || password_confirmation.present?
|
49
|
-
end
|
50
|
-
|
51
|
-
private
|
52
|
-
|
53
|
-
def check_admin
|
54
|
-
return if self.class.admin_created?
|
55
|
-
admin_role = Role.find_or_create_by_name "admin"
|
56
|
-
self.roles << admin_role
|
57
|
-
end
|
58
|
-
|
59
|
-
def set_login
|
60
|
-
# for now force login to be same as email, eventually we will make this configurable, etc.
|
61
|
-
self.login ||= self.email if self.email
|
62
|
-
end
|
63
|
-
|
64
|
-
# Generate a friendly string randomically to be used as token.
|
65
|
-
def self.friendly_token
|
66
|
-
SecureRandom.base64(15).tr('+/=', '-_ ').strip.delete("\n")
|
67
|
-
end
|
68
|
-
|
69
|
-
# Generate a token by looping and ensuring does not already exist.
|
70
|
-
def self.generate_token(column)
|
71
|
-
loop do
|
72
|
-
token = friendly_token
|
73
|
-
break token unless find(:first, :conditions => { column => token })
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def self.current
|
78
|
-
Thread.current[:user]
|
79
|
-
end
|
80
|
-
|
81
|
-
def self.current=(user)
|
82
|
-
Thread.current[:user] = user
|
83
|
-
end
|
84
|
-
|
85
|
-
end
|
data/app/models/user_mailer.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
class UserMailer < ActionMailer::Base
|
2
|
-
|
3
|
-
def reset_password_instructions(user)
|
4
|
-
default_url_options[:host] = Spree::Config[:site_url]
|
5
|
-
|
6
|
-
@edit_password_reset_url = edit_user_password_url(:reset_password_token => user.reset_password_token)
|
7
|
-
|
8
|
-
mail(:to => user.email,
|
9
|
-
:subject => Spree::Config[:site_name] + ' ' + I18n.t("password_reset_instructions"))
|
10
|
-
end
|
11
|
-
|
12
|
-
end
|
13
|
-
|
@@ -1,20 +0,0 @@
|
|
1
|
-
<%= render 'shared/error_messages', :target => @user %>
|
2
|
-
<h2><%= t(:registration)%></h2>
|
3
|
-
<div id="registration">
|
4
|
-
<div id="account">
|
5
|
-
<%= render :file => 'user_sessions/new' %>
|
6
|
-
</div>
|
7
|
-
<% if Spree::Config[:allow_guest_checkout] %>
|
8
|
-
<div id="guest_checkout">
|
9
|
-
<%= render 'shared/error_messages', :target => @order %>
|
10
|
-
<h2><%= t(:guest_user_account) %></h2>
|
11
|
-
<%= form_for @order, :url => update_checkout_registration_path, :html => { :method => :put, :id => 'checkout_form_registration'} do |f| %>
|
12
|
-
<p>
|
13
|
-
<%= f.label :email, t(:email) %><br />
|
14
|
-
<%= f.text_field :email, :class => 'title' %>
|
15
|
-
</p>
|
16
|
-
<p><%= f.submit t(:continue), :class => 'button primary' %></p>
|
17
|
-
<% end %>
|
18
|
-
</div>
|
19
|
-
<% end %>
|
20
|
-
</div>
|
@@ -1,8 +0,0 @@
|
|
1
|
-
<% if current_user %>
|
2
|
-
<ul id="login-nav">
|
3
|
-
<li><%= t(:logged_in_as) %>: <%= current_user.email %></li>
|
4
|
-
<li><%= link_to t(:account), edit_user_path(current_user) %></li>
|
5
|
-
<li><%= link_to t(:logout), destroy_user_session_path %></li>
|
6
|
-
<li><%= link_to t(:store), products_path %></li>
|
7
|
-
</ul>
|
8
|
-
<% end %>
|
@@ -1,15 +0,0 @@
|
|
1
|
-
<%= render 'shared/error_messages', :target => @user %>
|
2
|
-
<h1><%= t(:change_my_password) %></h1>
|
3
|
-
|
4
|
-
<%= form_for @user, :url => user_password_path, :html => {:method => :put} do |f| %>
|
5
|
-
<p>
|
6
|
-
<%= f.label :password %><br />
|
7
|
-
<%= f.password_field :password %><br />
|
8
|
-
</p>
|
9
|
-
<p>
|
10
|
-
<%= f.label :password_confirmation %><br />
|
11
|
-
<%= f.password_field :password_confirmation %><br />
|
12
|
-
</p>
|
13
|
-
<%= f.hidden_field :reset_password_token %>
|
14
|
-
<%= f.submit t(:update_password) %>
|
15
|
-
<% end %>
|
@@ -1,13 +0,0 @@
|
|
1
|
-
<h1><%= t(:forgot_password) %></h1>
|
2
|
-
|
3
|
-
<p><%= t(:instructions_to_reset_password) %></p>
|
4
|
-
|
5
|
-
<%= form_for User.new, :as => :user, :url => user_password_path do |f| %>
|
6
|
-
<p>
|
7
|
-
<%= f.label :email, t(:email) %>:<br />
|
8
|
-
<%= f.email_field :email %>
|
9
|
-
</p>
|
10
|
-
<p>
|
11
|
-
<%= f.submit t(:reset_password) %>
|
12
|
-
</p>
|
13
|
-
<% end %>
|
@@ -1,22 +0,0 @@
|
|
1
|
-
<% @body_id = 'signup' %>
|
2
|
-
|
3
|
-
<%= render 'shared/error_messages', :target => @user %>
|
4
|
-
|
5
|
-
<div id="new-customer">
|
6
|
-
<h2><%= t(:new_customer) %></h2>
|
7
|
-
|
8
|
-
<div data-hook="signup">
|
9
|
-
|
10
|
-
<%= form_for :user, :url => registration_path(@user) do |f| %>
|
11
|
-
<div data-hook="signup_inside_form"%>
|
12
|
-
<%= render 'shared/user_form', :f => f %>
|
13
|
-
<p><%= f.submit t(:create), :class => 'button primary' %></p>
|
14
|
-
</div>
|
15
|
-
<% end %>
|
16
|
-
<%= t(:or) %> <%= link_to t(:login_as_existing), login_path %>
|
17
|
-
|
18
|
-
</div>
|
19
|
-
|
20
|
-
</div>
|
21
|
-
|
22
|
-
<div data-hook="login_extras"></div>
|
data/config/cucumber.yml
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
<%
|
2
|
-
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
|
3
|
-
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
|
4
|
-
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} --strict --tags ~@wip"
|
5
|
-
ci_opts = "--format progress --strict"
|
6
|
-
%>
|
7
|
-
default: <%= std_opts %> features
|
8
|
-
wip: --tags @wip:3 --wip features
|
9
|
-
ci: <%= ci_opts %> features CI=true
|
10
|
-
rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
|
data/lib/spree/auth/config.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
module Spree
|
2
|
-
module Auth
|
3
|
-
# Singleton class to access the shipping configuration object (ActiveShippingConfiguration.first by default) and it's preferences.
|
4
|
-
#
|
5
|
-
# Usage:
|
6
|
-
# Spree::Auth::Config[:foo] # Returns the foo preference
|
7
|
-
# Spree::Auth::Config[] # Returns a Hash with all the tax preferences
|
8
|
-
# Spree::Auth::Config.instance # Returns the configuration object (AuthConfiguration.first)
|
9
|
-
# Spree::Auth::Config.set(preferences_hash) # Set the spree auth preferences as especified in +preference_hash+
|
10
|
-
class Config
|
11
|
-
include Singleton
|
12
|
-
include Spree::PreferenceAccess
|
13
|
-
|
14
|
-
class << self
|
15
|
-
def instance
|
16
|
-
return nil unless ActiveRecord::Base.connection.tables.include?('configurations')
|
17
|
-
SpreeAuthConfiguration.find_or_create_by_name("Default spree_auth configuration")
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|