spree_auth 0.60.6 → 0.70.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/assets/javascripts/admin/spree_auth.js +1 -0
- data/app/assets/javascripts/store/spree_auth.js +1 -0
- data/app/assets/stylesheets/admin/spree_auth.css +3 -0
- data/app/assets/stylesheets/store/spree_auth.css +3 -0
- data/app/controllers/admin_controller_decorator.rb +7 -1
- data/app/controllers/orders_controller_decorator.rb +1 -1
- data/app/controllers/spree/base_controller_decorator.rb +0 -1
- data/app/controllers/user_passwords_controller.rb +16 -1
- data/app/controllers/user_registrations_controller.rb +1 -0
- data/app/models/spree_auth_configuration.rb +1 -1
- data/app/models/user.rb +3 -3
- data/app/overrides/auth_admin_login_navigation_bar.rb +4 -0
- data/app/overrides/auth_shared_login_bar.rb +6 -0
- data/app/views/shared/_user_form.html.erb +1 -1
- data/app/views/user_registrations/new.html.erb +6 -5
- data/app/views/user_sessions/new.html.erb +3 -3
- data/app/views/users/show.html.erb +39 -45
- data/db/{sample → default}/users.rb +3 -1
- data/db/migrate/20101026184950_rename_columns_for_devise.rb +1 -1
- data/db/seeds.rb +5 -0
- data/lib/spree/token_resource.rb +2 -2
- data/lib/spree_auth.rb +5 -10
- data/lib/tasks/auth.rake +1 -1
- metadata +47 -38
- data/lib/spree_auth_hooks.rb +0 -6
- data/lib/tasks/install.rake +0 -23
@@ -0,0 +1 @@
|
|
1
|
+
//= require admin/spree_core
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require store/spree_core
|
@@ -2,6 +2,12 @@ Admin::BaseController.class_eval do
|
|
2
2
|
before_filter :authorize_admin
|
3
3
|
|
4
4
|
def authorize_admin
|
5
|
-
|
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
|
6
12
|
end
|
7
13
|
end
|
@@ -5,7 +5,7 @@ OrdersController.class_eval do
|
|
5
5
|
|
6
6
|
def check_authorization
|
7
7
|
session[:access_token] ||= params[:token]
|
8
|
-
order = Order.find_by_number(params[:id])
|
8
|
+
order = current_order || Order.find_by_number(params[:id])
|
9
9
|
|
10
10
|
if order
|
11
11
|
authorize! :edit, order, session[:access_token]
|
@@ -19,7 +19,6 @@ Spree::BaseController.class_eval do
|
|
19
19
|
flash.now[:error] = I18n.t(:authorization_failure)
|
20
20
|
render 'shared/unauthorized', :layout => 'spree_application'
|
21
21
|
else
|
22
|
-
flash[:error] = I18n.t(:authorization_failure)
|
23
22
|
store_location
|
24
23
|
redirect_to login_path and return
|
25
24
|
end
|
@@ -6,8 +6,23 @@ class UserPasswordsController < Devise::PasswordsController
|
|
6
6
|
super
|
7
7
|
end
|
8
8
|
|
9
|
+
# Temporary Override until next Devise release (i.e after v1.3.4)
|
10
|
+
# line:
|
11
|
+
# respond_with resource, :location => new_session_path(resource_name)
|
12
|
+
# is generating bad url /session/new.user
|
13
|
+
#
|
14
|
+
# overridden to:
|
15
|
+
# respond_with resource, :location => login_path
|
16
|
+
#
|
9
17
|
def create
|
10
|
-
|
18
|
+
self.resource = resource_class.send_reset_password_instructions(params[resource_name])
|
19
|
+
|
20
|
+
if resource.errors.empty?
|
21
|
+
set_flash_message(:notice, :send_instructions) if is_navigational_format?
|
22
|
+
respond_with resource, :location => login_path
|
23
|
+
else
|
24
|
+
respond_with_navigational(resource){ render_with_scope :new }
|
25
|
+
end
|
11
26
|
end
|
12
27
|
|
13
28
|
def edit
|
@@ -18,6 +18,7 @@ class UserRegistrationsController < Devise::RegistrationsController
|
|
18
18
|
logger.debug(@user)
|
19
19
|
if resource.save
|
20
20
|
set_flash_message(:notice, :signed_up)
|
21
|
+
fire_event('spree.user.signup', :user => @user)
|
21
22
|
sign_in_and_redirect(:user, @user)
|
22
23
|
else
|
23
24
|
clean_up_passwords(resource)
|
data/app/models/user.rb
CHANGED
@@ -38,9 +38,9 @@ class User < ActiveRecord::Base
|
|
38
38
|
email =~ /@example.net$/
|
39
39
|
end
|
40
40
|
|
41
|
-
def
|
41
|
+
def send_reset_password_instructions
|
42
42
|
reset_perishable_token!
|
43
|
-
UserMailer.
|
43
|
+
UserMailer.reset_password_instructions(self).deliver
|
44
44
|
end
|
45
45
|
|
46
46
|
protected
|
@@ -63,7 +63,7 @@ class User < ActiveRecord::Base
|
|
63
63
|
|
64
64
|
# Generate a friendly string randomically to be used as token.
|
65
65
|
def self.friendly_token
|
66
|
-
|
66
|
+
SecureRandom.base64(15).tr('+/=', '-_ ').strip.delete("\n")
|
67
67
|
end
|
68
68
|
|
69
69
|
# Generate a token by looping and ensuring does not already exist.
|
@@ -5,19 +5,20 @@
|
|
5
5
|
<div id="new-customer">
|
6
6
|
<h2><%= t("new_customer") %></h2>
|
7
7
|
|
8
|
-
|
8
|
+
<div data-hook="signup">
|
9
9
|
|
10
10
|
<%= form_for(:user, :url => registration_path(@user)) do |f| %>
|
11
11
|
|
12
|
-
|
12
|
+
<div data-hook="signup_inside_form"%>
|
13
13
|
<%= render 'shared/user_form', :f => f %>
|
14
14
|
<p><%= submit_tag t("create"), :class => 'button primary' %></p>
|
15
|
-
|
15
|
+
</div>
|
16
16
|
|
17
17
|
<% end %>
|
18
18
|
<%= t("or") %> <%= link_to t("login_as_existing"), login_path %>
|
19
|
-
|
19
|
+
|
20
|
+
</div>
|
20
21
|
|
21
22
|
</div>
|
22
23
|
|
23
|
-
|
24
|
+
<div data-hook="login_extras"></div>
|
@@ -5,9 +5,9 @@
|
|
5
5
|
<% @body_id = 'login' %>
|
6
6
|
<div id="existing-customer">
|
7
7
|
<h2><%= t("login_as_existing") %></h2>
|
8
|
-
|
8
|
+
<div data-hook="login">
|
9
9
|
<%= render :partial => 'shared/login' %>
|
10
10
|
<%= t("or") %> <%= link_to t("create_a_new_account"), signup_path %> | <%= link_to t("forgot_password"), new_user_password_path %>
|
11
|
-
|
11
|
+
</div>
|
12
12
|
</div>
|
13
|
-
|
13
|
+
<div data-hook="login_extras"></div>
|
@@ -1,50 +1,44 @@
|
|
1
1
|
<h1><%= t("my_account") %></h1>
|
2
2
|
|
3
|
-
|
3
|
+
<div data-hook="account_summary">
|
4
|
+
<dl id="user-info">
|
5
|
+
<dt><%= t("email") %></dt>
|
6
|
+
<dd><%= @user.email %></dd>
|
7
|
+
</dl>
|
8
|
+
<p><%= link_to t('edit'), edit_account_path %></p>
|
9
|
+
</div>
|
4
10
|
|
5
|
-
<
|
6
|
-
<tr>
|
7
|
-
<td><%= t("email") %>:</td>
|
8
|
-
<td>
|
9
|
-
<%= @user.email %>
|
10
|
-
</td>
|
11
|
-
</tr>
|
12
|
-
</table>
|
13
|
-
<p><%= link_to t('edit'), edit_account_path %></p>
|
11
|
+
<div data-hook="account_my_orders">
|
14
12
|
|
15
|
-
|
13
|
+
<h2><%= t("my_orders") %></h2>
|
14
|
+
<% if @orders.present? %>
|
15
|
+
<table class="order-summary" width="545">
|
16
|
+
<thead>
|
17
|
+
<tr>
|
18
|
+
<th><%= t("order_number") %></th>
|
19
|
+
<th><%= t("order_date") %></th>
|
20
|
+
<th><%= t("status") %></th>
|
21
|
+
<th><%= t("payment_state") %></th>
|
22
|
+
<th><%= t("shipment_state") %></th>
|
23
|
+
<th><%= t("total") %></th>
|
24
|
+
</tr>
|
25
|
+
</thead>
|
26
|
+
<tbody>
|
27
|
+
<% @orders.each do |order| %>
|
28
|
+
<tr class="<%= cycle('even', 'odd') %>">
|
29
|
+
<td><%= link_to order.number, order_url(order) %></td>
|
30
|
+
<td><%= l order.created_at.to_date %></td>
|
31
|
+
<td><%= t(order.state).titleize %></td>
|
32
|
+
<td><%= t("payment_states.#{order.payment_state}") if order.payment_state %></td>
|
33
|
+
<td><%= t("shipment_states.#{order.shipment_state}") if order.shipment_state %></td>
|
34
|
+
<td><%= number_to_currency order.total %></td>
|
35
|
+
</tr>
|
36
|
+
<% end %>
|
37
|
+
</tbody>
|
38
|
+
</table>
|
39
|
+
<% else %>
|
40
|
+
<p><%= t(:you_have_no_orders_yet) %></p>
|
41
|
+
<% end %>
|
42
|
+
<br />
|
16
43
|
|
17
|
-
|
18
|
-
|
19
|
-
<h2><%= t("my_orders") %></h2>
|
20
|
-
<% if @orders.present? %>
|
21
|
-
<table class="order-summary" width="545">
|
22
|
-
<thead>
|
23
|
-
<tr>
|
24
|
-
<th><%= t("order_number") %></th>
|
25
|
-
<th><%= t("order_date") %></th>
|
26
|
-
<th><%= t("status") %></th>
|
27
|
-
<th><%= t("payment_state") %></th>
|
28
|
-
<th><%= t("shipment_state") %></th>
|
29
|
-
<th><%= t("total") %></th>
|
30
|
-
</tr>
|
31
|
-
</thead>
|
32
|
-
<tbody>
|
33
|
-
<% @orders.each do |order| %>
|
34
|
-
<tr class="<%= cycle('even', 'odd') %>">
|
35
|
-
<td><%= link_to order.number, order_url(order) %></td>
|
36
|
-
<td><%=order.created_at.to_date%></td>
|
37
|
-
<td><%= t(order.state).titleize %></td>
|
38
|
-
<td><%= t("payment_states.#{order.payment_state}") if order.payment_state %></td>
|
39
|
-
<td><%= t("shipment_states.#{order.shipment_state}") if order.shipment_state %></td>
|
40
|
-
<td><%= number_to_currency order.total %></td>
|
41
|
-
</tr>
|
42
|
-
<% end %>
|
43
|
-
</tbody>
|
44
|
-
</table>
|
45
|
-
<% else %>
|
46
|
-
<p><%= t(:you_have_no_orders_yet) %></p>
|
47
|
-
<% end %>
|
48
|
-
<br />
|
49
|
-
|
50
|
-
<% end %>
|
44
|
+
</div>
|
@@ -14,7 +14,7 @@ class RenameColumnsForDevise < ActiveRecord::Migration
|
|
14
14
|
add_column :users, :authentication_token, :string
|
15
15
|
add_column :users, :unlock_token, :string
|
16
16
|
add_column :users, :locked_at, :datetime
|
17
|
-
remove_column :users, :api_key
|
17
|
+
remove_column :users, :api_key if column_exists?(:users, :api_key)
|
18
18
|
remove_column :users, :openid_identifier
|
19
19
|
end
|
20
20
|
|
data/db/seeds.rb
ADDED
data/lib/spree/token_resource.rb
CHANGED
@@ -10,7 +10,7 @@ module Spree::TokenResource
|
|
10
10
|
|
11
11
|
module InstanceMethods
|
12
12
|
def create_token
|
13
|
-
create_tokenized_permission(:token =>
|
13
|
+
create_tokenized_permission(:token => ::SecureRandom::hex(8))
|
14
14
|
token
|
15
15
|
end
|
16
16
|
end
|
@@ -20,4 +20,4 @@ module Spree::TokenResource
|
|
20
20
|
receiver.send :include, InstanceMethods
|
21
21
|
end
|
22
22
|
|
23
|
-
end
|
23
|
+
end
|
data/lib/spree_auth.rb
CHANGED
@@ -4,22 +4,17 @@ require 'cancan'
|
|
4
4
|
|
5
5
|
require 'spree/auth/config'
|
6
6
|
require 'spree/token_resource'
|
7
|
-
require 'spree_auth_hooks'
|
8
7
|
|
9
8
|
module SpreeAuth
|
10
9
|
class Engine < Rails::Engine
|
10
|
+
engine_name 'spree_auth'
|
11
|
+
|
11
12
|
def self.activate
|
12
13
|
Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")) do |c|
|
13
|
-
Rails.
|
14
|
+
Rails.application.config.cache_classes ? require(c) : load(c)
|
14
15
|
end
|
15
|
-
|
16
|
-
|
17
|
-
# https://github.com/plataformatec/devise/commit/ec5bfe9119d0e1e633629793b0de1f58f89622dc
|
18
|
-
Devise::IndifferentHash.class_eval do
|
19
|
-
def [](key)
|
20
|
-
super(convert_key(key))
|
21
|
-
end
|
22
|
-
def to_hash; Hash.new.update(self) end
|
16
|
+
Dir.glob(File.join(File.dirname(__FILE__), "../app/overrides/*.rb")) do |c|
|
17
|
+
Rails.application.config.cache_classes ? require(c) : load(c)
|
23
18
|
end
|
24
19
|
end
|
25
20
|
|
data/lib/tasks/auth.rake
CHANGED
@@ -2,7 +2,7 @@ namespace :db do
|
|
2
2
|
namespace :admin do
|
3
3
|
desc "Create admin username and password"
|
4
4
|
task :create => :environment do
|
5
|
-
require File.join(
|
5
|
+
require File.join(File.dirname(__FILE__), '..', '..', 'db', 'default', 'users.rb')
|
6
6
|
end
|
7
7
|
end
|
8
8
|
end
|
metadata
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 11094103
|
5
|
+
prerelease: 5
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
|
8
|
+
- 70
|
9
|
+
- RC
|
10
|
+
- 1
|
11
|
+
version: 0.70.RC1
|
11
12
|
platform: ruby
|
12
13
|
authors:
|
13
14
|
- Sean Schofield
|
@@ -15,57 +16,58 @@ autorequire:
|
|
15
16
|
bindir: bin
|
16
17
|
cert_chain: []
|
17
18
|
|
18
|
-
date:
|
19
|
+
date: 2011-09-09 00:00:00 Z
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
|
-
|
22
|
-
type: :runtime
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
22
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
24
23
|
none: false
|
25
24
|
requirements:
|
26
25
|
- - "="
|
27
26
|
- !ruby/object:Gem::Version
|
28
|
-
hash:
|
27
|
+
hash: 11094103
|
29
28
|
segments:
|
30
29
|
- 0
|
31
|
-
-
|
32
|
-
-
|
33
|
-
|
34
|
-
|
30
|
+
- 70
|
31
|
+
- RC
|
32
|
+
- 1
|
33
|
+
version: 0.70.RC1
|
35
34
|
name: spree_core
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
|
-
prerelease: false
|
38
35
|
type: :runtime
|
39
|
-
|
36
|
+
prerelease: false
|
37
|
+
requirement: *id001
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - "="
|
43
43
|
- !ruby/object:Gem::Version
|
44
|
-
hash:
|
44
|
+
hash: 15
|
45
45
|
segments:
|
46
46
|
- 1
|
47
|
-
-
|
48
|
-
-
|
49
|
-
version: 1.
|
50
|
-
version_requirements: *id002
|
47
|
+
- 4
|
48
|
+
- 4
|
49
|
+
version: 1.4.4
|
51
50
|
name: devise
|
52
|
-
- !ruby/object:Gem::Dependency
|
53
|
-
prerelease: false
|
54
51
|
type: :runtime
|
55
|
-
|
52
|
+
prerelease: false
|
53
|
+
requirement: *id002
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
56
56
|
none: false
|
57
57
|
requirements:
|
58
58
|
- - "="
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
hash:
|
60
|
+
hash: 5
|
61
61
|
segments:
|
62
62
|
- 1
|
63
63
|
- 6
|
64
|
-
-
|
65
|
-
version: 1.6.
|
66
|
-
version_requirements: *id003
|
64
|
+
- 5
|
65
|
+
version: 1.6.5
|
67
66
|
name: cancan
|
68
|
-
|
67
|
+
type: :runtime
|
68
|
+
prerelease: false
|
69
|
+
requirement: *id003
|
70
|
+
description: Required dependency for Spree
|
69
71
|
email: sean@railsdog.com
|
70
72
|
executables: []
|
71
73
|
|
@@ -76,6 +78,10 @@ extra_rdoc_files: []
|
|
76
78
|
files:
|
77
79
|
- LICENSE
|
78
80
|
- README.md
|
81
|
+
- app/assets/javascripts/admin/spree_auth.js
|
82
|
+
- app/assets/javascripts/store/spree_auth.js
|
83
|
+
- app/assets/stylesheets/admin/spree_auth.css
|
84
|
+
- app/assets/stylesheets/store/spree_auth.css
|
79
85
|
- app/controllers/admin_controller_decorator.rb
|
80
86
|
- app/controllers/admin_orders_controller_decorator.rb
|
81
87
|
- app/controllers/admin_resource_controller_decorator.rb
|
@@ -95,6 +101,8 @@ files:
|
|
95
101
|
- app/models/tokenized_permission.rb
|
96
102
|
- app/models/user.rb
|
97
103
|
- app/models/user_mailer.rb
|
104
|
+
- app/overrides/auth_admin_login_navigation_bar.rb
|
105
|
+
- app/overrides/auth_shared_login_bar.rb
|
98
106
|
- app/views/checkout/registration.html.erb
|
99
107
|
- app/views/layouts/admin/_login_nav.html.erb
|
100
108
|
- app/views/shared/_flashes.html.erb
|
@@ -117,14 +125,13 @@ files:
|
|
117
125
|
- lib/spree/auth/config.rb
|
118
126
|
- lib/spree/token_resource.rb
|
119
127
|
- lib/spree_auth.rb
|
120
|
-
- lib/spree_auth_hooks.rb
|
121
128
|
- lib/tasks/auth.rake
|
122
|
-
-
|
129
|
+
- db/default/users.rb
|
123
130
|
- db/migrate/20101026184950_rename_columns_for_devise.rb
|
124
131
|
- db/migrate/20101214150824_convert_user_remember_field.rb
|
125
132
|
- db/migrate/20101217012656_create_tokenized_permissions.rb
|
126
133
|
- db/migrate/20101219201531_tokens_for_legacy_orders.rb
|
127
|
-
- db/
|
134
|
+
- db/seeds.rb
|
128
135
|
homepage: http://spreecommerce.com
|
129
136
|
licenses: []
|
130
137
|
|
@@ -147,16 +154,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
147
154
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
155
|
none: false
|
149
156
|
requirements:
|
150
|
-
- - "
|
157
|
+
- - ">"
|
151
158
|
- !ruby/object:Gem::Version
|
152
|
-
hash:
|
159
|
+
hash: 25
|
153
160
|
segments:
|
154
|
-
-
|
155
|
-
|
161
|
+
- 1
|
162
|
+
- 3
|
163
|
+
- 1
|
164
|
+
version: 1.3.1
|
156
165
|
requirements:
|
157
166
|
- none
|
158
167
|
rubyforge_project: spree_auth
|
159
|
-
rubygems_version: 1.8.
|
168
|
+
rubygems_version: 1.8.6
|
160
169
|
signing_key:
|
161
170
|
specification_version: 3
|
162
171
|
summary: Provides authentication and authorization services for use with Spree.
|
data/lib/spree_auth_hooks.rb
DELETED
data/lib/tasks/install.rake
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
namespace :spree_auth do
|
2
|
-
desc "Copies all migrations and assets (NOTE: This will be obsolete with Rails 3.1)"
|
3
|
-
task :install do
|
4
|
-
Rake::Task['spree_auth:install:migrations'].invoke
|
5
|
-
Rake::Task['spree_auth:install:assets'].invoke
|
6
|
-
end
|
7
|
-
|
8
|
-
namespace :install do
|
9
|
-
|
10
|
-
desc "Copies all migrations (NOTE: This will be obsolete with Rails 3.1)"
|
11
|
-
task :migrations do
|
12
|
-
source = File.join(File.dirname(__FILE__), '..', '..', 'db')
|
13
|
-
destination = File.join(Rails.root, 'db')
|
14
|
-
Spree::FileUtilz.mirror_files(source, destination)
|
15
|
-
end
|
16
|
-
|
17
|
-
desc "Copies all assets (NOTE: This will be obsolete with Rails 3.1)"
|
18
|
-
task :assets do
|
19
|
-
# No assets
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
end
|