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.

@@ -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){ render_with_scope :new }
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
- render_with_scope(:new)
25
+ render :new
26
26
  end
27
27
  end
28
28
 
@@ -35,7 +35,7 @@ class Spree::UserSessionsController < Devise::SessionsController
35
35
  end
36
36
 
37
37
  def destroy
38
- cookies.clear if cookies.respond_to?(:clear)
38
+ cookies.clear
39
39
  session.clear
40
40
  super
41
41
  end
@@ -1,4 +1,5 @@
1
1
  class Spree::UsersController < Spree::BaseController
2
+ ssl_required
2
3
  prepend_before_filter :load_object, :only => [:show, :edit, :update]
3
4
  prepend_before_filter :authorize_actions, :only => :new
4
5
 
@@ -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,
@@ -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,6 @@
1
+ Deface::Override.new(:virtual_path => "spree/admin/payment_methods/index",
2
+ :name => "gateway_banner",
3
+ :insert_after => "#listing_payment_methods",
4
+ :partial => "spree/admin/banners/gateway")
5
+
6
+
@@ -0,0 +1,5 @@
1
+ Deface::Override.new(:virtual_path => "spree/admin/users/_form",
2
+ :name => "auth_admin_user_roles",
3
+ :insert_after => "[data-hook='admin_user_form_fields']",
4
+ :partial => "spree/admin/users/roles",
5
+ :disabled => false)
@@ -0,0 +1,5 @@
1
+ Deface::Override.new(:virtual_path => "spree/checkout/registration",
2
+ :name => "auth_user_login_form",
3
+ :replace_contents => "[data-hook='registration'] #account, #registration[data-hook] #account",
4
+ :template => "spree/user_sessions/new",
5
+ :disabled => false)
@@ -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> &nbsp;
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
- end
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
- order.create_tokenized_permission(:token => order.user.persistence_token)
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'
@@ -0,0 +1,5 @@
1
+ class AddResetPasswordSentAtToSpreeUsers < ActiveRecord::Migration
2
+ def change
3
+ add_column :spree_users, :reset_password_sent_at, :datetime
4
+ end
5
+ end
@@ -8,16 +8,15 @@ module Spree
8
8
  end
9
9
  end
10
10
 
11
- module InstanceMethods
12
- def create_token
13
- create_tokenized_permission(:token => ::SecureRandom::hex(8))
14
- token
15
- end
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.7
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: 2013-02-04 00:00:00.000000000 Z
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.7
21
+ version: 1.1.0.rc1
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
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: 1.5.3
32
+ version: '2.0'
38
33
  type: :runtime
39
34
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
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: !ruby/object:Gem::Requirement
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/views/spree/checkout/registration.html.erb
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: '0'
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.23
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>