Skip to content

Commit

Permalink
Merge pull request #1 from lynndylanhurley/master
Browse files Browse the repository at this point in the history
v0.1.41
  • Loading branch information
dks17 authored May 15, 2017
2 parents 763e8fd + e21cb89 commit 11f1fb2
Show file tree
Hide file tree
Showing 12 changed files with 522 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github_changelog_generator
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
bug-labels=bug,Bug,fix,Fix
enhancement-labels=enhancement,Enhancement,feat,Feat
between-tags=v0.1.38,v0.1.40
somce=tag=v0.1.40
unreleased-label=v0.1.41
base=CHANGELOG.md
486 changes: 486 additions & 0 deletions CHANGELOG.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ GIT
PATH
remote: .
specs:
devise_token_auth (0.1.40)
devise_token_auth (0.1.41)
devise (> 3.5.2, <= 4.2.1)
rails (< 6)

Expand Down Expand Up @@ -86,7 +86,7 @@ GEM
simplecov (>= 0.7.1, < 1.0.0)
coderay (1.1.1)
colorize (0.8.1)
concurrent-ruby (1.0.2)
concurrent-ruby (1.0.5)
descendants_tracker (0.0.4)
thread_safe (~> 0.3, >= 0.3.1)
devise (4.2.0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def set_user_by_token(mapping=nil)
return false unless @token

# mitigate timing attacks by finding by uid instead of auth token
user = uid && rc.find_by_uid(uid)
user = uid && rc.find_by(uid: uid)

if user && user.valid_token?(@token, @client_id)
# sign_in with bypass: true will be deprecated in the next version of Devise
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ def redirect_callbacks
devise_mapping = [request.env['omniauth.params']['namespace_name'],
request.env['omniauth.params']['resource_class'].underscore.gsub('/', '_')].compact.join('_')
path = "#{Devise.mappings[devise_mapping.to_sym].fullpath}/#{params[:provider]}/callback"
redirect_route = URI::HTTP.build(scheme: request.scheme, host: request.host, port: request.port, path: path).to_s
klass = request.scheme == 'https' ? URI::HTTPS : URI::HTTP
redirect_route = klass.build(host: request.host, port: request.port, path: path).to_s

# preserve omniauth info for success route. ignore 'extra' in twitter
# auth response to avoid CookieOverflow.
Expand Down
4 changes: 2 additions & 2 deletions lib/devise_token_auth/controllers/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def authenticate_#{group_name}!(favourite=nil, opts={})
unless current_#{group_name}
return render json: {
errors: ["Authorized users only."]
errors: [I18n.t('devise.failure.unauthenticated')]
}, status: 401
end
end
Expand Down Expand Up @@ -110,7 +110,7 @@ def self.define_helpers(mapping) #:nodoc:
def authenticate_#{mapping}!
unless current_#{mapping}
return render json: {
errors: ["Authorized users only."]
errors: [I18n.t('devise.failure.unauthenticated')]
}, status: 401
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/devise_token_auth/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module DeviseTokenAuth
VERSION = "0.1.40"
VERSION = "0.1.41"
end
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class SessionsController < DeviseTokenAuth::SessionsController
OVERRIDE_PROOF = "(^^,)"

def create
@resource = resource_class.find_by_email(resource_params[:email])
@resource = resource_class.find_by(email: resource_params[:email])

if @resource and valid_params?(:email, resource_params[:email]) and @resource.valid_password?(resource_params[:password]) and @resource.confirmed?
# create client id
Expand Down
2 changes: 0 additions & 2 deletions test/dummy/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,5 @@ class Application < Rails::Application
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
config.autoload_paths << Rails.root.join('lib')

config.active_record.raise_in_transactional_callbacks = true
end
end
9 changes: 7 additions & 2 deletions test/dummy/config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@
config.eager_load = false

# Configure static asset server for tests with Cache-Control for performance.
config.serve_static_files = true
config.static_cache_control = 'public, max-age=3600'
Rails::VERSION::MAJOR == 5 ?
(config.public_file_server.enabled = true) :
(config.serve_static_files = true)

Rails::VERSION::MAJOR == 5 ?
(config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' }) :
(config.static_cache_control = 'public, max-age=3600')

# Show full error reports and disable caching.
config.consider_all_requests_local = true
Expand Down
31 changes: 17 additions & 14 deletions test/lib/generators/devise_token_auth/install_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class InstallGeneratorTest < Rails::Generators::TestCase
end

test 'migration file contains rails version' do
assert_migration 'db/migrate/devise_token_auth_create_users.rb', /4.2/
assert_migration 'db/migrate/devise_token_auth_create_users.rb', /#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}/
end

test 'subsequent runs raise no errors' do
Expand All @@ -48,14 +48,17 @@ class InstallGeneratorTest < Rails::Generators::TestCase
# make dir if not exists
FileUtils.mkdir_p(@dir)

# account for rails version 5
active_record_needle = (Rails::VERSION::MAJOR == 5) ? 'ApplicationRecord' : 'ActiveRecord::Base'

@f = File.open(@fname, 'w') {|f|
f.write <<-RUBY
class User < ActiveRecord::Base
class User < #{active_record_needle}
def whatever
puts 'whatever'
end
end
def whatever
puts 'whatever'
end
end
RUBY
}

Expand Down Expand Up @@ -91,9 +94,9 @@ def whatever

@f = File.open(@fname, 'w') {|f|
f.write <<-RUBY
Rails.application.routes.draw do
patch '/chong', to: 'bong#index'
end
Rails.application.routes.draw do
patch '/chong', to: 'bong#index'
end
RUBY
}

Expand Down Expand Up @@ -151,11 +154,11 @@ def whatever

@f = File.open(@fname, 'w') {|f|
f.write <<-RUBY
class ApplicationController < ActionController::Base
def whatever
'whatever'
end
end
class ApplicationController < ActionController::Base
def whatever
'whatever'
end
end
RUBY
}

Expand Down
6 changes: 2 additions & 4 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
require "codeclimate-test-reporter"
#require 'simplecov'
require 'simplecov'

#SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
#SimpleCov::Formatter::HTMLFormatter,
#CodeClimate::TestReporter::Formatter
#]

#SimpleCov.start 'rails'
CodeClimate::TestReporter.start
SimpleCov.start 'rails'

ENV["RAILS_ENV"] = "test"

Expand Down

0 comments on commit 11f1fb2

Please sign in to comment.