Skip to content

Commit

Permalink
Merge pull request #388 from spark-solutions/hotfix/cleanup
Browse files Browse the repository at this point in the history
3.2.0 release
  • Loading branch information
damianlegawiec authored Jun 15, 2017
2 parents d91d50e + e2b8bf1 commit 740ddfc
Show file tree
Hide file tree
Showing 63 changed files with 230 additions and 259 deletions.
14 changes: 11 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
## Spree Auth Devise v3.2.0 (master, unreleased)
## Spree Auth Devise v3.2.0 (2017-06-15)

* Supports `Spree 3.1` and any other newer version lesser than `4.0` (https://github.com/spree/spree_auth_devise/pull/353)
* `devise` updated to `4.0` (https://github.com/spree/spree_auth_devise/pull/344)
* `Rails 5` support
* Supports `Spree 3.1` `Spree 3.2` and any other newer version lesser than `4.0` (https://github.com/spree/spree_auth_devise/pull/353, https://github.com/spree/spree_auth_devise/pull/386)
* `devise` updated to `4.3` (https://github.com/spree/spree_auth_devise/pull/382)
* `devise-encryptable` updated to `0.2.0` (https://github.com/spree/spree_auth_devise/commit/5f51e6e4e81dbf99fe95848dbd4fa9cba03b6910)
* updated development dependencies (https://github.com/spree/spree_auth_devise/pull/351)
* include `Spree::UserMethods` in `Spree::User` (https://github.com/spree/spree_auth_devise/pull/343)
* fixed: Unnecessary breaking changes of I18n key (https://github.com/spree/spree_auth_devise/pull/387)
* fixed: use proper scoping to find translations related to order states (https://github.com/spree/spree_auth_devise/pull/384)
* fixed: spree_api is not required anymore (https://github.com/spree/spree_auth_devise/pull/380)
* Install generator: Add option to skip migrations (https://github.com/spree/spree_auth_devise/pull/378)
* Added Portuguese translation (https://github.com/spree/spree_auth_devise/pull/365)
* Replaced registration_error flash with standard error (https://github.com/spree/spree_auth_devise/pull/361)

## Spree Auth Devise v3.1.0 (2016-04-05)

Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
source 'https://rubygems.org'

gem "rails-controller-testing"
gem 'spree', github: 'spree/spree', branch: 'master'

gemspec
51 changes: 27 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,43 @@

Provides authentication services for Spree, using the Devise gem.


## Installation

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.
1. Add this extension to your Gemfile with this line:

Just add this line to your `Gemfile`:
```ruby
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: 'master'
```
#### Spree >= 3.1

Please ensure you're using the correct branch of `spree_auth_devise` relative to your version of Spree.
```ruby
gem 'spree_auth_devise', github: 'spree/spree_auth_devise'
```

Spree 1.3.x or 1-3-stable:
```ruby
gem 'spree_auth_devise', :github => 'spree/spree_auth_devise', :branch => '1-3-stable'
```
#### Spree 3.0 and Spree 2.x

Spree 1.2.x or 1-2-stable:
```ruby
gem 'spree_auth_devise', :github => 'spree/spree_auth_devise', :branch => '1-2-stable'
```
```ruby
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: 'X-X-stable'
```

Then run `bundle install`. Authentication will then work exactly as it did in previous versions of Spree.
The `branch` option is important: it must match the version of Spree you're using.
For example, use `3-0-stable` if you're using Spree `3-0-stable` or any `3.0.x` version.

If you're installing this in a new Spree 1.2+ application, you'll need to install and run the migrations with
2. Install the gem using Bundler:
```ruby
bundle install
```

bundle exec rake spree_auth:install:migrations
bundle exec rake db:migrate
bundle exec rails g spree:auth:install
3. Copy & run migrations
```ruby
bundle exec rails g spree:auth:install
```

and then, run this command in order to set up the admin user for the application.
## Upgrading from Spree 3.0 to 3.1

bundle exec rake spree_auth:admin:create
If you're upgrading from 3.0 to 3.1 you need to rerun the installer to copy new asset files (javascripts)

```ruby
bundle exec rails g spree:auth:install
```

## Configuration

Expand Down Expand Up @@ -110,6 +115,4 @@ You need to do a quick one-time creation of a test application and then you can

Then run the rspec tests.

bundle exec rake spec

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.
bundle exec rspec
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require 'spree/testing_support/common_rake'

RSpec::Core::RakeTask.new

task :default => :spec
task default: :spec

desc 'Generates a dummy app for testing'
task :test_app do
Expand Down
5 changes: 0 additions & 5 deletions Versionfile

This file was deleted.

12 changes: 6 additions & 6 deletions app/mailers/spree/user_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
module Spree
class UserMailer < BaseMailer
def reset_password_instructions(user, token, *args)
@edit_password_reset_url = spree.edit_spree_user_password_url(:reset_password_token => token, :host => Spree::Store.current.url)
def reset_password_instructions(user, token, *_args)
@edit_password_reset_url = spree.edit_spree_user_password_url(reset_password_token: token, host: Spree::Store.current.url)

mail to: user.email, from: from_address, subject: Spree::Store.current.name + ' ' + I18n.t(:subject, :scope => [:devise, :mailer, :reset_password_instructions])
mail to: user.email, from: from_address, subject: Spree::Store.current.name + ' ' + I18n.t(:subject, scope: [:devise, :mailer, :reset_password_instructions])
end

def confirmation_instructions(user, token, opts={})
@confirmation_url = spree.spree_user_confirmation_url(:confirmation_token => token, :host => Spree::Store.current.url)
def confirmation_instructions(user, token, _opts = {})
@confirmation_url = spree.spree_user_confirmation_url(confirmation_token: token, host: Spree::Store.current.url)
@email = user.email

mail to: user.email, from: from_address, subject: Spree::Store.current.name + ' ' + I18n.t(:subject, :scope => [:devise, :mailer, :confirmation_instructions])
mail to: user.email, from: from_address, subject: Spree::Store.current.name + ' ' + I18n.t(:subject, scope: [:devise, :mailer, :confirmation_instructions])
end
end
end
6 changes: 3 additions & 3 deletions app/models/spree/auth_configuration.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Spree
class AuthConfiguration < Preferences::Configuration
preference :registration_step, :boolean, :default => true
preference :signout_after_password_change, :boolean, :default => true
preference :confirmable, :boolean, :default => false
preference :registration_step, :boolean, default: true
preference :signout_after_password_change, :boolean, default: true
preference :confirmable, :boolean, default: false
end
end
33 changes: 17 additions & 16 deletions app/models/spree/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class User < Spree::Base
include UserPaymentSource

devise :database_authenticatable, :registerable, :recoverable,
:rememberable, :trackable, :validatable, :encryptable, :encryptor => 'authlogic_sha512'
:rememberable, :trackable, :validatable, :encryptable, encryptor: 'authlogic_sha512'
devise :confirmable if Spree::Auth::Config[:confirmable]

acts_as_paranoid
Expand All @@ -27,23 +27,24 @@ def admin?
end

protected
def password_required?
!persisted? || password.present? || password_confirmation.present?
end

def password_required?
!persisted? || password.present? || password_confirmation.present?
end

private

def set_login
# for now force login to be same as email, eventually we will make this configurable, etc.
self.login ||= self.email if self.email
end

def scramble_email_and_password
self.email = SecureRandom.uuid + "@example.net"
self.login = self.email
self.password = SecureRandom.hex(8)
self.password_confirmation = self.password
self.save
end
def set_login
# for now force login to be same as email, eventually we will make this configurable, etc.
self.login ||= email if email
end

def scramble_email_and_password
self.email = SecureRandom.uuid + "@example.net"
self.login = email
self.password = SecureRandom.hex(8)
self.password_confirmation = password
save
end
end
end
13 changes: 6 additions & 7 deletions app/overrides/auth_shared_login_bar.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
Deface::Override.new(:virtual_path => "spree/shared/_nav_bar",
:name => "auth_shared_login_bar",
:insert_before => "li#search-bar",
:partial => "spree/shared/login_bar",
:disabled => false,
:original => 'c00d67dfc0496d21a351b48c41a728412cb5ed2c')

Deface::Override.new(virtual_path: "spree/shared/_nav_bar",
name: "auth_shared_login_bar",
insert_before: "li#search-bar",
partial: "spree/shared/login_bar",
disabled: false,
original: 'c00d67dfc0496d21a351b48c41a728412cb5ed2c')
13 changes: 0 additions & 13 deletions circle.yml

This file was deleted.

2 changes: 1 addition & 1 deletion config.ru
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../spec/dummy/config/environment', __FILE__)
require ::File.expand_path('../spec/dummy/config/environment', __FILE__)
run Dummy::Application
2 changes: 1 addition & 1 deletion config/initializers/devise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
config.http_authenticatable = true

# Set this to true to use Basic Auth for AJAX requests. True by default.
#config.http_authenticatable_on_xhr = false
# config.http_authenticatable_on_xhr = false

# The realm used in Http Basic Authentication
config.http_authentication_realm = 'Spree Application'
Expand Down
4 changes: 2 additions & 2 deletions config/initializers/warden.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Merges users orders to their account after sign in and sign up.
Warden::Manager.after_set_user except: :fetch do |user, auth, opts|
Warden::Manager.after_set_user except: :fetch do |user, auth, _opts|
if auth.cookies.signed[:guest_token].present?
if user.is_a?(Spree::User)
Spree::Order.incomplete.where(guest_token: auth.cookies.signed[:guest_token], user_id: nil).each do |order|
Expand All @@ -9,6 +9,6 @@
end
end

Warden::Manager.before_logout do |user, auth, opts|
Warden::Manager.before_logout do |_user, auth, _opts|
auth.cookies.delete :guest_token
end
35 changes: 17 additions & 18 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
Spree::Core::Engine.add_routes do
devise_for :spree_user,
:class_name => 'Spree::User',
:controllers => { :sessions => 'spree/user_sessions',
:registrations => 'spree/user_registrations',
:passwords => 'spree/user_passwords',
:confirmations => 'spree/user_confirmations' },
:skip => [:unlocks, :omniauth_callbacks],
:path_names => { :sign_out => 'logout' },
:path_prefix => :user
class_name: 'Spree::User',
controllers: { sessions: 'spree/user_sessions',
registrations: 'spree/user_registrations',
passwords: 'spree/user_passwords',
confirmations: 'spree/user_confirmations' },
skip: [:unlocks, :omniauth_callbacks],
path_names: { sign_out: 'logout' },
path_prefix: :user

resources :users, :only => [:edit, :update]
resources :users, only: [:edit, :update]

devise_scope :spree_user do
get '/login' => 'user_sessions#new', :as => :login
Expand All @@ -28,22 +28,21 @@
put '/checkout/registration' => 'checkout#update_registration', :as => :update_checkout_registration

get '/account_link' => 'store#account_link'
resource :account, :controller => 'users'
resource :account, controller: 'users'

namespace :admin, path: Spree.admin_path do
devise_for :spree_user,
:class_name => 'Spree::User',
:controllers => { :sessions => 'spree/admin/user_sessions',
:passwords => 'spree/admin/user_passwords' },
:skip => [:unlocks, :omniauth_callbacks, :registrations],
:path_names => { :sign_out => 'logout' },
:path_prefix => :user
class_name: 'Spree::User',
controllers: { sessions: 'spree/admin/user_sessions',
passwords: 'spree/admin/user_passwords' },
skip: [:unlocks, :omniauth_callbacks, :registrations],
path_names: { sign_out: 'logout' },
path_prefix: :user
devise_scope :spree_user do
get '/authorization_failure', :to => 'user_sessions#authorization_failure', :as => :unauthorized
get '/authorization_failure', to: 'user_sessions#authorization_failure', as: :unauthorized
get '/login' => 'user_sessions#new', :as => :login
post '/login' => 'user_sessions#create', :as => :create_new_session
get '/logout' => 'user_sessions#destroy', :as => :logout
end

end
end
10 changes: 5 additions & 5 deletions db/default/users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ def create_admin_user
email = 'spree@example.com'
else
puts 'Create the admin user (press enter for defaults).'
#name = prompt_for_admin_name unless name
# name = prompt_for_admin_name unless name
email = prompt_for_admin_email
password = prompt_for_admin_password
end
attributes = {
:password => password,
:password_confirmation => password,
:email => email,
:login => email
password: password,
password_confirmation: password,
email: email,
login: email
}

load 'spree/user.rb'
Expand Down
14 changes: 7 additions & 7 deletions db/migrate/20101026184949_create_users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ class CreateUsers < ActiveRecord::Migration; end
CreateUsers.class_eval do
def up
unless data_source_exists?("spree_users")
create_table "spree_users", :force => true do |t|
t.string "crypted_password", :limit => 128
t.string "salt", :limit => 128
create_table "spree_users", force: true do |t|
t.string "crypted_password", limit: 128
t.string "salt", limit: 128
t.string "email"
t.string "remember_token"
t.string "remember_token_expires_at"
t.string "persistence_token"
t.string "single_access_token"
t.string "perishable_token"
t.integer "login_count", :default => 0, :null => false
t.integer "failed_login_count", :default => 0, :null => false
t.integer "login_count", default: 0, null: false
t.integer "failed_login_count", default: 0, null: false
t.datetime "last_request_at"
t.datetime "current_login_at"
t.datetime "last_login_at"
Expand All @@ -25,8 +25,8 @@ def up
t.string "login"
t.integer "ship_address_id"
t.integer "bill_address_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "openid_identifier"
end
end
Expand Down
4 changes: 2 additions & 2 deletions db/migrate/20120605211305_make_users_email_index_unique.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ class MakeUsersEmailIndexUnique < ActiveRecord::Migration; end
end
MakeUsersEmailIndexUnique.class_eval do
def up
add_index "spree_users", ["email"], :name => "email_idx_unique", :unique => true
add_index "spree_users", ["email"], name: "email_idx_unique", unique: true
end

def down
remove_index "spree_users", :name => "email_idx_unique"
remove_index "spree_users", name: "email_idx_unique"
end
end
Loading

0 comments on commit 740ddfc

Please sign in to comment.