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.

@@ -0,0 +1 @@
1
+ //= require admin/spree_core
@@ -0,0 +1 @@
1
+ //= require store/spree_core
@@ -0,0 +1,3 @@
1
+ /*
2
+ *= require admin/spree_core
3
+ */
@@ -0,0 +1,3 @@
1
+ /*
2
+ *= require store/spree_core
3
+ */
@@ -2,6 +2,12 @@ Admin::BaseController.class_eval do
2
2
  before_filter :authorize_admin
3
3
 
4
4
  def authorize_admin
5
- authorize! :admin, Object
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]) || current_order
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
- super
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)
@@ -1,4 +1,4 @@
1
1
  class SpreeAuthConfiguration < Configuration
2
2
  preference :registration_step, :boolean, :default => true
3
3
  preference :signout_after_password_change, :boolean, :default => true
4
- end
4
+ end
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 deliver_password_reset_instructions!
41
+ def send_reset_password_instructions
42
42
  reset_perishable_token!
43
- UserMailer.password_reset_instructions(self).deliver
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
- ActiveSupport::SecureRandom.base64(15).tr('+/=', '-_ ').strip.delete("\n")
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.
@@ -0,0 +1,4 @@
1
+ Deface::Override.new(:virtual_path => "layouts/admin",
2
+ :name => "auth_admin_login_navigation_bar",
3
+ :replace => "[data-hook='admin_login_navigation_bar'], #admin_login_navigation_bar[data-hook]",
4
+ :partial => "layouts/admin/login_nav")
@@ -0,0 +1,6 @@
1
+ Deface::Override.new(:virtual_path => "shared/_nav_bar",
2
+ :name => "auth_shared_login_bar",
3
+ :insert_after => "li#search-bar",
4
+ :partial => "shared/login_bar",
5
+ :disabled => false)
6
+
@@ -14,4 +14,4 @@
14
14
  </p>
15
15
  </div>
16
16
 
17
- <%= hook :signup_below_password_fields %>
17
+ <div data-hook="signup_below_password_fields"></div>
@@ -5,19 +5,20 @@
5
5
  <div id="new-customer">
6
6
  <h2><%= t("new_customer") %></h2>
7
7
 
8
- <%= hook :signup do %>
8
+ <div data-hook="signup">
9
9
 
10
10
  <%= form_for(:user, :url => registration_path(@user)) do |f| %>
11
11
 
12
- <%= hook :signup_inside_form do %>
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
- <% end %>
15
+ </div>
16
16
 
17
17
  <% end %>
18
18
  <%= t("or") %> <%= link_to t("login_as_existing"), login_path %>
19
- <% end %>
19
+
20
+ </div>
20
21
 
21
22
  </div>
22
23
 
23
- <%= hook :login_extras %>
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
- <%= hook :login do %>
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
- <% end %>
11
+ </div>
12
12
  </div>
13
- <%= hook :login_extras %>
13
+ <div data-hook="login_extras"></div>
@@ -1,50 +1,44 @@
1
1
  <h1><%= t("my_account") %></h1>
2
2
 
3
- <%= hook :account_summary do %>
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
- <table>
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
- <% end %>
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
- <%= hook :account_my_orders do %>
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>
@@ -50,4 +50,6 @@ def create_admin_user
50
50
  end
51
51
  end
52
52
 
53
- create_admin_user if User.where("roles.name" => 'admin').includes(:roles).empty?
53
+ if Rails.env.development?
54
+ create_admin_user if User.where("roles.name" => 'admin').includes(:roles).empty?
55
+ end
@@ -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 rescue Exception
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
@@ -0,0 +1,5 @@
1
+ # Loads seed data out of default dir
2
+ default_path = File.join(File.dirname(__FILE__), 'default')
3
+
4
+ Rake::Task['db:load_dir'].reenable
5
+ Rake::Task["db:load_dir"].invoke( default_path )
@@ -10,7 +10,7 @@ module Spree::TokenResource
10
10
 
11
11
  module InstanceMethods
12
12
  def create_token
13
- create_tokenized_permission(:token => ActiveSupport::SecureRandom::hex(8))
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.env.production? ? require(c) : load(c)
14
+ Rails.application.config.cache_classes ? require(c) : load(c)
14
15
  end
15
-
16
- # monkey patch until new version of devise comes out
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(Rails.root, 'db', 'sample', 'users.rb')
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: 227
5
- prerelease:
4
+ hash: 11094103
5
+ prerelease: 5
6
6
  segments:
7
7
  - 0
8
- - 60
9
- - 6
10
- version: 0.60.6
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: 2012-03-12 00:00:00 Z
19
+ date: 2011-09-09 00:00:00 Z
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
- prerelease: false
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: 227
27
+ hash: 11094103
29
28
  segments:
30
29
  - 0
31
- - 60
32
- - 6
33
- version: 0.60.6
34
- version_requirements: *id001
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
- requirement: &id002 !ruby/object:Gem::Requirement
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: 29
44
+ hash: 15
45
45
  segments:
46
46
  - 1
47
- - 3
48
- - 3
49
- version: 1.3.3
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
- requirement: &id003 !ruby/object:Gem::Requirement
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: 7
60
+ hash: 5
61
61
  segments:
62
62
  - 1
63
63
  - 6
64
- - 4
65
- version: 1.6.4
66
- version_requirements: *id003
64
+ - 5
65
+ version: 1.6.5
67
66
  name: cancan
68
- description: Required dependancy for Spree
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
- - lib/tasks/install.rake
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/sample/users.rb
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: 3
159
+ hash: 25
153
160
  segments:
154
- - 0
155
- version: "0"
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.10
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.
@@ -1,6 +0,0 @@
1
- class SpreeAuthHooks < Spree::ThemeSupport::HookListener
2
-
3
- replace :admin_login_navigation_bar, :partial => "layouts/admin/login_nav"
4
- replace :shared_login_bar, :partial => "shared/login_bar"
5
-
6
- end
@@ -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