spree_auth_devise 1.3.1 → 3.0.5

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_devise might be problematic. Click here for more details.

Files changed (144) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.rspec +3 -0
  4. data/.travis.yml +11 -0
  5. data/Gemfile +5 -0
  6. data/{LICENSE → LICENSE.md} +1 -1
  7. data/README.md +86 -10
  8. data/Rakefile +15 -0
  9. data/Versionfile +5 -0
  10. data/app/controllers/metal_decorator.rb +6 -0
  11. data/app/mailers/spree/user_mailer.rb +12 -5
  12. data/app/models/spree/auth_configuration.rb +1 -0
  13. data/app/models/spree/user.rb +17 -50
  14. data/app/overrides/spree/admin/shared/_header/auth_admin_login_navigation_bar.html.erb.deface +4 -0
  15. data/bin/rails +7 -0
  16. data/circle.yml +11 -0
  17. data/config.ru +4 -0
  18. data/config/initializers/devise.rb +3 -8
  19. data/config/initializers/warden.rb +14 -0
  20. data/config/locales/de.yml +40 -37
  21. data/config/locales/en.yml +48 -39
  22. data/config/locales/es.yml +49 -0
  23. data/config/locales/fr.yml +49 -0
  24. data/config/locales/it.yml +76 -0
  25. data/config/locales/nl.yml +41 -46
  26. data/config/locales/pt-BR.yml +51 -0
  27. data/config/locales/tr.yml +49 -0
  28. data/config/routes.rb +32 -15
  29. data/db/default/users.rb +13 -6
  30. data/db/migrate/20140904000425_add_deleted_at_to_users.rb +6 -0
  31. data/db/migrate/20141002154641_add_confirmable_to_users.rb +7 -0
  32. data/lib/assets/javascripts/spree/backend/spree_auth.js.erb +1 -0
  33. data/lib/assets/javascripts/spree/frontend/spree_auth.js.erb +1 -0
  34. data/lib/assets/stylesheets/spree/backend/spree_auth.css.erb +3 -0
  35. data/lib/assets/stylesheets/spree/frontend/spree_auth.css.erb +3 -0
  36. data/lib/controllers/backend/spree/admin/admin_controller_decorator.rb +26 -0
  37. data/lib/controllers/backend/spree/admin/admin_orders_controller_decorator.rb +20 -0
  38. data/{app/controllers → lib/controllers/backend}/spree/admin/admin_resource_controller_decorator.rb +0 -0
  39. data/{app/controllers/spree/admin/admin_orders_controller_decorator.rb → lib/controllers/backend/spree/admin/orders/customer_details_controller_decorator.rb} +3 -2
  40. data/lib/controllers/backend/spree/admin/user_passwords_controller.rb +42 -0
  41. data/lib/controllers/backend/spree/admin/user_sessions_controller.rb +53 -0
  42. data/{app/controllers → lib/controllers/frontend}/spree/checkout_controller_decorator.rb +8 -15
  43. data/lib/controllers/frontend/spree/user_confirmations_controller.rb +14 -0
  44. data/{app/controllers → lib/controllers/frontend}/spree/user_passwords_controller.rb +10 -9
  45. data/{app/controllers → lib/controllers/frontend}/spree/user_registrations_controller.rb +18 -15
  46. data/lib/controllers/frontend/spree/user_sessions_controller.rb +46 -0
  47. data/{app/controllers → lib/controllers/frontend}/spree/users_controller.rb +13 -9
  48. data/lib/generators/spree/auth/install/install_generator.rb +26 -0
  49. data/lib/generators/spree/auth/install/templates/config/initializers/devise.rb +1 -0
  50. data/lib/spree/auth.rb +2 -1
  51. data/lib/spree/auth/devise.rb +7 -0
  52. data/lib/spree/auth/engine.rb +57 -2
  53. data/lib/spree/authentication_helpers.rb +1 -1
  54. data/lib/spree_auth_devise.rb +3 -0
  55. data/lib/views/backend/spree/admin/user_passwords/edit.html.erb +15 -0
  56. data/lib/views/backend/spree/admin/user_passwords/new.html.erb +17 -0
  57. data/lib/views/backend/spree/admin/user_sessions/authorization_failure.html.erb +4 -0
  58. data/lib/views/backend/spree/admin/user_sessions/new.html.erb +38 -0
  59. data/lib/views/backend/spree/layouts/admin/_login_nav.html.erb +33 -0
  60. data/lib/views/backend/spree/layouts/login.html.erb +25 -0
  61. data/lib/views/frontend/spree/checkout/_new_user.html.erb +20 -0
  62. data/lib/views/frontend/spree/checkout/registration.html.erb +27 -0
  63. data/{app/views → lib/views/frontend}/spree/shared/_flashes.html.erb +0 -0
  64. data/lib/views/frontend/spree/shared/_login.html.erb +18 -0
  65. data/lib/views/frontend/spree/shared/_login_bar.html.erb +6 -0
  66. data/lib/views/frontend/spree/shared/_user_form.html.erb +13 -0
  67. data/lib/views/frontend/spree/user_mailer/confirmation_instructions.text.erb +5 -0
  68. data/lib/views/frontend/spree/user_mailer/reset_password_instructions.text.erb +10 -0
  69. data/lib/views/frontend/spree/user_passwords/edit.html.erb +22 -0
  70. data/lib/views/frontend/spree/user_passwords/new.html.erb +21 -0
  71. data/lib/views/frontend/spree/user_registrations/new.html.erb +22 -0
  72. data/lib/views/frontend/spree/user_sessions/new.html.erb +20 -0
  73. data/lib/views/frontend/spree/users/edit.html.erb +17 -0
  74. data/lib/views/frontend/spree/users/show.html.erb +43 -0
  75. data/spec/controllers/spree/admin/orders_controller_spec.rb +14 -0
  76. data/spec/controllers/spree/checkout_controller_spec.rb +141 -0
  77. data/spec/controllers/spree/products_controller_spec.rb +21 -0
  78. data/spec/controllers/spree/user_passwords_controller_spec.rb +44 -0
  79. data/spec/controllers/spree/user_registrations_controller_spec.rb +13 -0
  80. data/spec/controllers/spree/user_sessions_controller_spec.rb +56 -0
  81. data/spec/controllers/spree/users_controller_spec.rb +38 -0
  82. data/spec/factories/confirmed_user.rb +7 -0
  83. data/spec/features/account_spec.rb +58 -0
  84. data/spec/features/admin/orders_spec.rb +28 -0
  85. data/spec/features/admin/password_reset_spec.rb +24 -0
  86. data/spec/features/admin/products_spec.rb +9 -0
  87. data/spec/features/admin/sign_in_spec.rb +45 -0
  88. data/spec/features/admin/sign_out_spec.rb +22 -0
  89. data/spec/features/admin_permissions_spec.rb +46 -0
  90. data/spec/features/change_email_spec.rb +24 -0
  91. data/spec/features/checkout_spec.rb +160 -0
  92. data/spec/features/confirmation_spec.rb +28 -0
  93. data/spec/features/order_spec.rb +62 -0
  94. data/spec/features/password_reset_spec.rb +24 -0
  95. data/spec/features/sign_in_spec.rb +54 -0
  96. data/spec/features/sign_out_spec.rb +25 -0
  97. data/spec/features/sign_up_spec.rb +30 -0
  98. data/spec/mailers/user_mailer_spec.rb +46 -0
  99. data/spec/models/order_spec.rb +26 -0
  100. data/spec/models/user_spec.rb +58 -0
  101. data/spec/spec_helper.rb +24 -0
  102. data/spec/support/ability.rb +15 -0
  103. data/spec/support/authentication_helpers.rb +14 -0
  104. data/spec/support/capybara.rb +7 -0
  105. data/spec/support/confirm_helpers.rb +11 -0
  106. data/spec/support/database_cleaner.rb +18 -0
  107. data/spec/support/email.rb +5 -0
  108. data/spec/support/factory_girl.rb +5 -0
  109. data/spec/support/spree.rb +26 -0
  110. data/spree_auth_devise.gemspec +48 -0
  111. metadata +441 -79
  112. data/app/assets/javascripts/admin/spree_auth.js +0 -1
  113. data/app/assets/javascripts/store/spree_auth.js +0 -1
  114. data/app/assets/stylesheets/admin/spree_auth.css +0 -3
  115. data/app/assets/stylesheets/store/spree_auth.css +0 -3
  116. data/app/controllers/spree/admin/admin_controller_decorator.rb +0 -7
  117. data/app/controllers/spree/admin/admin_users_controller_decorator.rb +0 -21
  118. data/app/controllers/spree/admin/users_controller.rb +0 -77
  119. data/app/controllers/spree/base_controller_decorator.rb +0 -18
  120. data/app/controllers/spree/orders_controller_decorator.rb +0 -15
  121. data/app/controllers/spree/user_sessions_controller.rb +0 -54
  122. data/app/helpers/spree/users_helper.rb +0 -15
  123. data/app/models/spree/current_order_decorator.rb +0 -12
  124. data/app/overrides/admin_tab.rb +0 -6
  125. data/app/overrides/auth_admin_login_navigation_bar.rb +0 -5
  126. data/app/overrides/auth_user_login_form.rb +0 -6
  127. data/app/views/spree/admin/users/_form.html.erb +0 -37
  128. data/app/views/spree/admin/users/edit.html.erb +0 -28
  129. data/app/views/spree/admin/users/index.html.erb +0 -53
  130. data/app/views/spree/admin/users/new.html.erb +0 -23
  131. data/app/views/spree/admin/users/show.html.erb +0 -21
  132. data/app/views/spree/layouts/admin/_login_nav.html.erb +0 -8
  133. data/app/views/spree/shared/_login.html.erb +0 -20
  134. data/app/views/spree/shared/_login_bar.html.erb +0 -6
  135. data/app/views/spree/shared/_user_form.html.erb +0 -17
  136. data/app/views/spree/user_mailer/reset_password_instructions.text.erb +0 -10
  137. data/app/views/spree/user_passwords/edit.html.erb +0 -15
  138. data/app/views/spree/user_passwords/new.html.erb +0 -15
  139. data/app/views/spree/user_registrations/new.html.erb +0 -22
  140. data/app/views/spree/user_sessions/authorization_failure.html.erb +0 -4
  141. data/app/views/spree/user_sessions/new.html.erb +0 -13
  142. data/app/views/spree/users/edit.html.erb +0 -11
  143. data/app/views/spree/users/show.html.erb +0 -43
  144. data/config/initializers/spree.rb +0 -1
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e8d33a18b8879913709314cd4046b18ee1518627
4
+ data.tar.gz: aaf7a78332ae2badc7f69ccc3773605d91713d0c
5
+ SHA512:
6
+ metadata.gz: 1bcc4fdd327f2adfe7ca449333f643e42d004e3e6ccf4adb70306deb4c04157fcc66628889e8bb38d956f6358a471ae33f81d4f53b0dfbae0ea2a88136f5ce7f
7
+ data.tar.gz: 430bf537bbf294bf7e6cdce733e68cad0f1f0efeade91c181798cd6b7103c27ca1ac5930dfefc83ebc2b2b2c004d690162d725bd78d17d79f1472ac5ecf8016f
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ spec/dummy
2
+ .sass-cache
3
+ coverage
4
+ Gemfile.lock
5
+ *.swp
6
+ .rvmrc
7
+ .ruby-gemset
8
+ .ruby-version
9
+ .bundle
10
+ .DS_Store
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ -r spec_helper
3
+ -f documentation
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ before_script:
2
+ - bundle exec rake test_app
3
+ - export DISPLAY=:99.0
4
+ - sh -e /etc/init.d/xvfb start
5
+ env:
6
+ - DB=mysql
7
+ - DB=postgres
8
+ language: ruby
9
+ rvm:
10
+ - 2.1.5
11
+ sudo: false
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'spree', github: 'spree/spree', branch: '3-0-stable'
4
+
5
+ gemspec
@@ -1,4 +1,4 @@
1
- Copyright (c) 2007-2012, Spree Commerce, Inc. and other contributors
1
+ Copyright (c) 2014, Spree Commerce, Inc. and other contributors
2
2
  All rights reserved.
3
3
 
4
4
  Redistribution and use in source and binary forms, with or without modification,
data/README.md CHANGED
@@ -1,14 +1,30 @@
1
1
  # Spree Auth (Devise)
2
2
 
3
+ [![Build Status](https://secure.travis-ci.org/spree/spree_auth_devise.png?branch=master)](https://travis-ci.org/spree/spree_auth_devise)
4
+ [![Code Climate](https://codeclimate.com/github/spree/spree_auth_devise.png)](https://codeclimate.com/github/spree/spree_auth_devise)
5
+
3
6
  Provides authentication services for Spree, using the Devise gem.
4
7
 
5
8
  ## Installation
6
9
 
7
- At one stage in the past, this used to be the auth component for Spree. If that's the feature that you're now finding lacking from Spree, that's easy fixed.
10
+ At one stage in the past, this used to be the auth component for Spree. If that's the feature that you're now finding lacking from Spree, that's easily fixed.
11
+
12
+ Just add this line to your `Gemfile`:
13
+ ```ruby
14
+ gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: 'master'
15
+ ```
16
+
17
+ Please ensure you're using the correct branch of `spree_auth_devise` relative to your version of Spree.
8
18
 
9
- Just add this line to your Gemfile:
19
+ Spree 1.3.x or 1-3-stable:
20
+ ```ruby
21
+ gem 'spree_auth_devise', :github => 'spree/spree_auth_devise', :branch => '1-3-stable'
22
+ ```
10
23
 
11
- gem "spree_auth_devise", :git => "git://github.com/spree/spree_auth_devise"
24
+ Spree 1.2.x or 1-2-stable:
25
+ ```ruby
26
+ gem 'spree_auth_devise', :github => 'spree/spree_auth_devise', :branch => '1-2-stable'
27
+ ```
12
28
 
13
29
  Then run `bundle install`. Authentication will then work exactly as it did in previous versions of Spree.
14
30
 
@@ -16,14 +32,75 @@ If you're installing this in a new Spree 1.2+ application, you'll need to instal
16
32
 
17
33
  bundle exec rake spree_auth:install:migrations
18
34
  bundle exec rake db:migrate
35
+ bundle exec rails g spree:auth:install
36
+
37
+ and then, run this command in order to set up the admin user for the application.
38
+
39
+ bundle exec rake spree_auth:admin:create
40
+
41
+ ## Configuration
42
+
43
+ ### Confirmable
44
+
45
+ To enable Devise's Confirmable module, which will send the user an email with a link to confirm their account, you must do the following:
46
+
47
+ * Add this line to an initializer in your Rails project (typically `config/initializers/spree.rb`):
48
+ ```ruby
49
+ Spree::Auth::Config[:confirmable] = true
50
+ ```
51
+
52
+ * Add a Devise initializer to your Rails project (typically `config/initializers/devise.rb`):
53
+ ```ruby
54
+ Devise.setup do |config|
55
+ # Required so users don't lose their carts when they need to confirm.
56
+ config.allow_unconfirmed_access_for = 1.days
57
+
58
+ # Fixes the bug where Confirmation errors result in a broken page.
59
+ config.router_name = :spree
60
+
61
+ # Add any other devise configurations here, as they will override the defaults provided by spree_auth_devise.
62
+ end
63
+ ```
64
+
65
+ ## Using in an existing Rails application
66
+
67
+ If you are installing Spree inside of a host application in which you want your own permission setup, you can do this using spree_auth_devise's register_ability method.
68
+
69
+ First create your own CanCan Ability class following the CanCan documentation.
70
+
71
+ For example: app/models/your_ability_class.rb
72
+
73
+ ```ruby
74
+ class YourAbilityClass
75
+ include CanCan::Ability
76
+
77
+ def initialize user
78
+ # direct permissions
79
+ can :create, SomeRailsObject
80
+
81
+ # or permissions by group
82
+ if spree_user.has_spree_role? "admin"
83
+ can :create, SomeRailsAdminObject
84
+ end
85
+ end
86
+ end
87
+ ```
88
+
89
+ Then register your class in your spree initializer: config/initializers/spree.rb
90
+ ```ruby
91
+ Spree::Ability.register_ability(YourAbilityClass)
92
+ ```
19
93
 
20
- and then, run `bundle exec rake spree_auth:admin:create` in order to set up the admin user for the application.
94
+ Inside of your host application you can then use CanCan like you normally would.
95
+ ```ruby
96
+ <% if can? :show SomeRailsObject %>
21
97
 
22
- If you're updating a Spree 1.1 application, run these to migrate the database:
98
+ <% end %>
99
+ ```
23
100
 
24
- rake railties:install:migrations
25
- rake db:migrate
101
+ ### Adding Permissions to Gems
26
102
 
103
+ This methodology can also be used by gems that extend spree and want/need to add permissions.
27
104
 
28
105
  ## Testing
29
106
 
@@ -31,9 +108,8 @@ You need to do a quick one-time creation of a test application and then you can
31
108
 
32
109
  bundle exec rake test_app
33
110
 
34
- Then run the rspec tests
111
+ Then run the rspec tests.
35
112
 
36
113
  bundle exec rake spec
37
114
 
38
- If everything doesn't pass on your machine (using Ruby (1.8.7 or 1.9.3) and (MySQL or PostgreSQL or SQLite3)) then we would consider that a bug. Please file a bug report on the issues page for this project with your test output
39
- and we will investigate it.
115
+ If everything doesn't pass on your machine (using Ruby (1.9.3 or 2.0.0) and (MySQL or PostgreSQL or SQLite3)) then we would consider that a bug. Please file a bug report on the issues page for this project with your test output and we will investigate it.
data/Rakefile ADDED
@@ -0,0 +1,15 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rspec/core/rake_task'
5
+ require 'spree/testing_support/common_rake'
6
+
7
+ RSpec::Core::RakeTask.new
8
+
9
+ task :default => :spec
10
+
11
+ desc 'Generates a dummy app for testing'
12
+ task :test_app do
13
+ ENV['LIB_NAME'] = 'spree/auth'
14
+ Rake::Task['common:test_app'].invoke("Spree::User")
15
+ end
data/Versionfile ADDED
@@ -0,0 +1,5 @@
1
+ "2.2.x" => { :branch => "2-2-stable" }
2
+ "2.1.x" => { :branch => "2-1-stable" }
3
+ "2.0.x" => { :branch => "2-0-stable" }
4
+ "1.3.x" => { :branch => "1-3-stable" }
5
+ "1.2.x" => { :branch => "1-2-stable" }
@@ -0,0 +1,6 @@
1
+ # For the API
2
+ ActionController::Metal.class_eval do
3
+ def spree_current_user
4
+ @spree_current_user ||= env['warden'].user
5
+ end
6
+ end
@@ -1,8 +1,15 @@
1
- class Spree::UserMailer < ActionMailer::Base
2
- def reset_password_instructions(user)
3
- @edit_password_reset_url = spree.edit_user_password_url(:reset_password_token => user.reset_password_token)
1
+ module Spree
2
+ class UserMailer < BaseMailer
3
+ def reset_password_instructions(user, token, *args)
4
+ @edit_password_reset_url = spree.edit_spree_user_password_url(:reset_password_token => token, :host => Spree::Store.current.url)
4
5
 
5
- mail(:to => user.email,
6
- :subject => Spree::Config[:site_name] + ' ' + I18n.t(:password_reset_instructions))
6
+ mail to: user.email, from: from_address, subject: Spree::Store.current.name + ' ' + I18n.t(:subject, :scope => [:devise, :mailer, :reset_password_instructions])
7
+ end
8
+
9
+ def confirmation_instructions(user, token, opts={})
10
+ @confirmation_url = spree.spree_user_confirmation_url(:confirmation_token => token, :host => Spree::Store.current.url)
11
+
12
+ mail to: user.email, from: from_address, subject: Spree::Store.current.name + ' ' + I18n.t(:subject, :scope => [:devise, :mailer, :confirmation_instructions])
13
+ end
7
14
  end
8
15
  end
@@ -2,5 +2,6 @@ module Spree
2
2
  class AuthConfiguration < Preferences::Configuration
3
3
  preference :registration_step, :boolean, :default => true
4
4
  preference :signout_after_password_change, :boolean, :default => true
5
+ preference :confirmable, :boolean, :default => false
5
6
  end
6
7
  end
@@ -1,48 +1,30 @@
1
1
  module Spree
2
- class User < ActiveRecord::Base
3
- include Core::UserBanners
2
+ class User < Spree::Base
3
+ include UserAddress
4
+ include UserPaymentSource
4
5
 
5
- devise :database_authenticatable, :token_authenticatable, :registerable, :recoverable,
6
+ devise :database_authenticatable, :registerable, :recoverable,
6
7
  :rememberable, :trackable, :validatable, :encryptable, :encryptor => 'authlogic_sha512'
8
+ devise :confirmable if Spree::Auth::Config[:confirmable]
9
+
10
+ acts_as_paranoid
11
+ after_destroy :scramble_email_and_password
7
12
 
8
13
  has_many :orders
9
- belongs_to :ship_address, :foreign_key => 'ship_address_id', :class_name => 'Spree::Address'
10
- belongs_to :bill_address, :foreign_key => 'bill_address_id', :class_name => 'Spree::Address'
11
14
 
12
- before_save :check_admin
13
15
  before_validation :set_login
14
- before_destroy :check_completed_orders
15
-
16
- # Setup accessible (or protected) attributes for your model
17
- attr_accessible :email, :password, :password_confirmation, :remember_me, :persistence_token, :login, :spree_role_ids
18
16
 
19
17
  users_table_name = User.table_name
20
18
  roles_table_name = Role.table_name
21
19
 
22
- scope :admin, lambda { includes(:spree_roles).where("#{roles_table_name}.name" => "admin") }
23
- scope :registered, where("#{users_table_name}.email NOT LIKE ?", "%@example.net")
24
-
25
- class DestroyWithOrdersError < StandardError; end
26
-
27
- # Creates an anonymous user. An anonymous user is basically an auto-generated +User+ account that is created for the customer
28
- # behind the scenes and its completely transparently to the customer. All +Orders+ must have a +User+ so this is necessary
29
- # when adding to the "cart" (which is really an order) and before the customer has a chance to provide an email or to register.
30
- def self.anonymous!
31
- token = User.generate_token(:persistence_token)
32
- User.create(:email => "#{token}@example.net", :password => token, :password_confirmation => token, :persistence_token => token)
33
- end
20
+ scope :admin, -> { includes(:spree_roles).where("#{roles_table_name}.name" => "admin") }
34
21
 
35
22
  def self.admin_created?
36
23
  User.admin.count > 0
37
24
  end
38
25
 
39
- def anonymous?
40
- email =~ /@example.net$/ ? true : false
41
- end
42
-
43
- def send_reset_password_instructions
44
- generate_reset_password_token!
45
- UserMailer.reset_password_instructions(self).deliver
26
+ def admin?
27
+ has_spree_role?('admin')
46
28
  end
47
29
 
48
30
  protected
@@ -52,32 +34,17 @@ module Spree
52
34
 
53
35
  private
54
36
 
55
- def check_completed_orders
56
- raise DestroyWithOrdersError if orders.complete.present?
57
- end
58
-
59
- def check_admin
60
- return if self.class.admin_created?
61
- admin_role = Role.find_or_create_by_name 'admin'
62
- self.spree_roles << admin_role
63
- end
64
-
65
37
  def set_login
66
38
  # for now force login to be same as email, eventually we will make this configurable, etc.
67
39
  self.login ||= self.email if self.email
68
40
  end
69
41
 
70
- # Generate a friendly string randomically to be used as token.
71
- def self.friendly_token
72
- SecureRandom.base64(15).tr('+/=', '-_ ').strip.delete("\n")
73
- end
74
-
75
- # Generate a token by looping and ensuring does not already exist.
76
- def self.generate_token(column)
77
- loop do
78
- token = friendly_token
79
- break token unless find(:first, :conditions => { column => token })
80
- end
42
+ def scramble_email_and_password
43
+ self.email = SecureRandom.uuid + "@example.net"
44
+ self.login = self.email
45
+ self.password = SecureRandom.hex(8)
46
+ self.password_confirmation = self.password
47
+ self.save
81
48
  end
82
49
  end
83
50
  end
@@ -0,0 +1,4 @@
1
+ <!-- insert_top "[data-hook='admin_login_navigation_bar'], #admin_login_navigation_bar[data-hook]"
2
+ original '841227d0aedf7909d62237d8778df99100087715' -->
3
+
4
+ <%= render partial: "spree/layouts/admin/login_nav" %>
data/bin/rails ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ENGINE_ROOT = File.expand_path('../..', __FILE__)
4
+ ENGINE_PATH = File.expand_path('../../lib/spree/auth/engine', __FILE__)
5
+
6
+ require 'rails/all'
7
+ require 'rails/engine/commands'
data/circle.yml ADDED
@@ -0,0 +1,11 @@
1
+ machine:
2
+ environment:
3
+ DB: postgres
4
+ services:
5
+ - postgresql
6
+ ruby:
7
+ version: '2.2'
8
+
9
+ dependencies:
10
+ post:
11
+ - bundle exec rake test_app
data/config.ru ADDED
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../spec/dummy/config/environment', __FILE__)
4
+ run Dummy::Application
@@ -40,7 +40,7 @@ Devise.setup do |config|
40
40
  config.stretches = 20
41
41
 
42
42
  # Setup a pepper to generate the encrypted password.
43
- config.pepper = '0bfa9e2cb4a5efd0d976518a3d82e345060547913d2fd1dd2f32b0c8dbbbb5d3dc20b86d0fed31aca9513bccdf51643700ea277d9c64d9ce8ef886bf39293453'
43
+ config.pepper = Rails.configuration.secret_token
44
44
 
45
45
  # ==> Configuration for :confirmable
46
46
  # The time you want to give your user to confirm his account. During this time
@@ -65,9 +65,6 @@ Devise.setup do |config|
65
65
  # Range for password length
66
66
  # config.password_length = 6..20
67
67
 
68
- # Regex to use to validate the email address
69
- config.email_regexp = /^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i
70
-
71
68
  # ==> Configuration for :timeoutable
72
69
  # The time you want to timeout the user session without activity. After this
73
70
  # time the user will be asked for credentials again.
@@ -93,10 +90,6 @@ Devise.setup do |config|
93
90
  # Time interval to unlock the account if :time is enabled as unlock_strategy.
94
91
  # config.unlock_in = 1.hour
95
92
 
96
- # ==> Configuration for :token_authenticatable
97
- # Defines name of the authentication token params key
98
- config.token_authentication_key = :auth_token
99
-
100
93
  # ==> Scopes configuration
101
94
  # Turn scoped views on. Before rendering 'sessions/new', it will first check for
102
95
  # 'users/sessions/new'. It's turned off by default because it's slower if you
@@ -139,4 +132,6 @@ Devise.setup do |config|
139
132
  # change their passwords.
140
133
  config.reset_password_within = 6.hours
141
134
  config.sign_out_via = :get
135
+
136
+ config.case_insensitive_keys = [:email]
142
137
  end
@@ -0,0 +1,14 @@
1
+ # Merges users orders to their account after sign in and sign up.
2
+ Warden::Manager.after_set_user except: :fetch do |user, auth, opts|
3
+ if auth.cookies.signed[:guest_token].present?
4
+ if user.is_a?(Spree::User)
5
+ Spree::Order.where(email: user.email, guest_token: auth.cookies.signed[:guest_token], user_id: nil).each do |order|
6
+ order.associate_user!(user)
7
+ end
8
+ end
9
+ end
10
+ end
11
+
12
+ Warden::Manager.before_logout do |user, auth, opts|
13
+ auth.cookies.delete :guest_token
14
+ end
@@ -1,46 +1,49 @@
1
+ ---
1
2
  de:
2
- errors:
3
- messages:
4
- not_found: 'nicht gefunden'
5
- already_confirmed: 'wurde berreits bestätigt'
6
- not_locked: 'war nicht gesperrt'
7
- not_saved:
8
- one: '1 Fehler verhindert das Speichern von %{resource}:'
9
- other: '%{count} Fehler verhindern das Speichern von %{resource}:'
10
3
  devise:
4
+ confirmations:
5
+ confirmed: Ihr Konto wurde erfolgreich aktiviert.
6
+ send_instructions: 'In ein paar Minuten erhalten Sie eine E-Mail mit Anweisungen, um Ihr Konto zu aktivieren.'
11
7
  failure:
8
+ inactive: Ihr Konto wurde noch nicht aktiviert.
9
+ invalid: Ungültige E-Mail-Adresse oder Passwort.
10
+ invalid_token: Ungültiger Authentifizierungsschlüssel.
11
+ locked: Ihr Konto ist gesperrt.
12
+ timeout: 'Ihre Sitzung ist abgelaufen. Bitte melden Sie sich erneut an, um fortzufahren.'
12
13
  unauthenticated: 'Sie müssen sich anmelden oder registrieren, bevor Sie fortfahren.'
13
14
  unconfirmed: 'Sie müssen Ihre Registrierung bestätigen, bevor Sie fortfahren.'
14
- locked: 'Ihr Konto ist gesperrt.'
15
- invalid: 'Ungültige E-Mail-Adresse oder Passwort.'
16
- invalid_token: 'Ungültiger Authentifizierungsschlüssel.'
17
- timeout: 'Ihre Sitzung ist abgelaufen. Bitte melden Sie sich erneut an, um fortzufahren.'
18
- inactive: 'Ihr Konto wurde noch nicht aktiviert.'
19
- user_passwords:
20
- user:
21
- send_instructions: 'In ein paar Minuten erhalten Sie eine E-Mail mit Anweisungen um Ihr Passwort zurücksetzen.'
22
- updated: 'Ihr Passwort wurde erfolgreich geändert.'
23
- confirmations:
24
- send_instructions: 'In ein paar Minuten erhalten Sie eine E-Mail mit Anweisungen, um Ihr Konto zu aktivieren.'
25
- confirmed: 'Ihr Konto wurde erfolgreich aktiviert.'
26
- user_registrations:
27
- signed_up: 'Herzlich Willkommen! Sie haben sich erfolgreich registriert.'
28
- inactive_signed_up: 'Sie haben sich erfolgreich registriert. Wir konnten Sie jedoch nicht anmelden, da Ihr Konto %{reason} ist.'
29
- updated: 'Sie haben Ihr Konto erfolgreich aktualisiert.'
30
- destroyed: 'Ihr Konto wurde erfolgreich gelöscht. Auf Wiedersehen!'
31
- user_sessions:
32
- signed_in: 'Erfolgreich angemeldet.'
33
- signed_out: 'Erfolgreich abgemeldet.'
34
- unlocks:
35
- send_instructions: 'In ein paar Minuten erhalten Sie eine E-Mail mit Anweisungen um Ihr Konto freizuschalten.'
36
- unlocked: 'Ihr Konto wurde erfolgreich freigeschaltet.'
37
- oauth_callbacks:
38
- success: 'Erfolgreich autorisiert durch %{kind} Konto.'
39
- failure: 'Autorisierung durch %{kind} fehlgeschlagen aufgrund von "%{reason}".'
40
15
  mailer:
41
16
  confirmation_instructions:
42
- subject: 'Bestätigen Sie Ihre Registrierung'
17
+ subject: Bestätigen Sie Ihre Registrierung
43
18
  reset_password_instructions:
44
- subject: 'Passwort zurücksetzen'
19
+ subject: Passwort zurücksetzen
45
20
  unlock_instructions:
46
- subject: 'Konto freischalten'
21
+ subject: Konto freischalten
22
+ oauth_callbacks:
23
+ failure: 'Autorisierung durch %{kind} fehlgeschlagen aufgrund von %{reason}.'
24
+ success: 'Erfolgreich autorisiert durch %{kind} Konto.'
25
+ unlocks:
26
+ send_instructions: In ein paar Minuten erhalten Sie eine E-Mail mit Anweisungen um Ihr Konto freizuschalten.
27
+ unlocked: Ihr Konto wurde erfolgreich freigeschaltet.
28
+ user_passwords:
29
+ spree_user:
30
+ cannot_be_blank: Ihr Passwort darf nicht leer sein.
31
+ send_instructions: In ein paar Minuten erhalten Sie eine E-Mail mit Anweisungen um Ihr Passwort zurücksetzen.
32
+ updated: Ihr Passwort wurde erfolgreich geändert.
33
+ user_registrations:
34
+ destroyed: Ihr Konto wurde erfolgreich gelöscht. Auf Wiedersehen!
35
+ inactive_signed_up: 'Sie haben sich erfolgreich registriert. Wir konnten Sie jedoch nicht anmelden, da Ihr Konto %{reason} ist.'
36
+ signed_up: Herzlich Willkommen! Sie haben sich erfolgreich registriert.
37
+ updated: Sie haben Ihr Konto erfolgreich aktualisiert.
38
+ user_sessions:
39
+ signed_in: Erfolgreich angemeldet.
40
+ signed_out: Erfolgreich abgemeldet.
41
+ errors:
42
+ messages:
43
+ already_confirmed: wurde berreits bestätigt
44
+ email_is_invalid: E-Mail-Adresse darf nicht leer sein
45
+ not_found: nicht gefunden
46
+ not_locked: war nicht gesperrt
47
+ not_saved:
48
+ one: '1 Fehler verhindert das Speichern von %{resource}:'
49
+ other: '%{count} Fehler verhindern das Speichern von %{resource}:'