Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit c922580
Author: ‮Artem Kozaev <artemkozaev@gmail.com>
Date:   Tue Dec 8 22:58:00 2020 +0300

    Add email validation errors via add (lynndylanhurley#1445)

commit 72ccd90
Author: Hu Hailin <tony.hu.hailin@gmail.com>
Date:   Wed Dec 9 04:57:39 2020 +0900

    rc causes issue for namespaced class, use mapping directly to keep behavior consistency with devise (lynndylanhurley#1440)

commit 8dba30b
Author: Maicol Bentancor <maicol.bentancor@gmail.com>
Date:   Tue Dec 8 16:57:19 2020 -0300

    Enable rails 6.1 (lynndylanhurley#1446)

commit 575272a
Author: Ali Deishidi <sizief@gmail.com>
Date:   Fri Dec 4 19:20:56 2020 +0330

    Update faq.md (lynndylanhurley#1439)

    Type was missing

commit 2a83ef9
Author: dominikdarnel <dominik.darnel@gmail.com>
Date:   Sun Nov 8 21:51:36 2020 +0100

    Update overrides.md (lynndylanhurley#1437)

    Overrideable methods RegistrationsController#render_destroy_success and RegistrationsController#render_destroy_error were missing from docs.

commit 5ef7197
Author: Avrohom Katz <iambpentameter@gmail.com>
Date:   Sun Nov 1 10:40:30 2020 -0500

    make DTA respect controller overrides it doesn't kow about (lynndylanhurley#1435)

commit 24da31e
Author: Paulo Ribeiro <plribeiro3000@gmail.com>
Date:   Sun Nov 1 12:39:35 2020 -0300

    feat(Route): Accept override (lynndylanhurley#1432)

commit 530b4ba
Author: JP Rosevear <jprosevear@gmail.com>
Date:   Mon Oct 19 17:32:04 2020 -0400

    Remove unnecessary require_relative the file should be autoloaded (lynndylanhurley#1433)

commit 576d0b0
Author: Martin Jaime <50113670+martinjaimem@users.noreply.github.com>
Date:   Mon Oct 19 18:31:44 2020 -0300

    Enhancement: remove unnecessary statement in destroy session (lynndylanhurley#1431)

commit 0c369d6
Author: Maicol Bentancor <maicol.bentancor@gmail.com>
Date:   Sun Oct 4 17:34:44 2020 -0300

    Serialize updated at without to s (lynndylanhurley#1423)

    * working 4.2 version

    * cleanup

    * Lock simplecov to last supported cc version

    codeclimate/test-reporter#413

    Co-authored-by: Brian Dunn <brianpatrickdunn@gmail.com>

commit bb3e3f0
Author: Brent Dearth <brent.dearth@gmail.com>
Date:   Tue Sep 1 11:05:33 2020 -0600

    chore(deps): remove Sprockets requirement (lynndylanhurley#1428)

commit bef1b0b
Author: ngouy <nathangouy@free.fr>
Date:   Sat Jul 25 14:43:00 2020 -0400

    missing space in migration generator (lynndylanhurley#1422)

    So everything is nicely aligned if you uncomment this

commit b409997
Author: Maicol Bentancor <maicol.bentancor@gmail.com>
Date:   Sun Jun 21 21:53:29 2020 -0300

    Avoid failing on undefined variable for invalid record (lynndylanhurley#1416)

commit 30a1aff
Author: Maicol Bentancor <maicol.bentancor@gmail.com>
Date:   Sun Jun 21 21:52:43 2020 -0300

    Avoid nullyfing token when current_user is called before (lynndylanhurley#1417)

commit ae3547c
Author: Charlie Hua <compassion.wisdom@gmail.com>
Date:   Sun Jun 21 04:37:15 2020 +0800

    Memorize current_#{group_name} to avoid error (lynndylanhurley#722)

    Currently current_#{group_name} (ex. current_member) is not memorized as current_#{mapping} (ex. current_user) is.
    Instead, it calls set_user_by_token every time, and this could cause error if current_member is called after token is changed (maybe by some other request) and return nil

commit 849c244
Author: Maicol Bentancor <maicol.bentancor@gmail.com>
Date:   Sat Jun 20 00:39:42 2020 -0300

    Fix parent class name generator for rails 6 (lynndylanhurley#1414)

commit 449a0be
Author: Maicol Bentancor <maicol.bentancor@gmail.com>
Date:   Fri Jun 19 20:09:26 2020 -0300

    Reduce config variables doc table width (lynndylanhurley#1413)

commit 4461a09
Author: Hai Phan Nguyen <pnghai@gmail.com>
Date:   Sat Jun 20 05:27:45 2020 +0700

    Fix crash on devise 4.7.2+ (lynndylanhurley#1412)

    * Ignore sync uid in case confirmable mail changed

    * Update user_omniauth_callbacks.rb

    * Update user_omniauth_callbacks.rb

    * fix crash on devise 4.7.2+

commit bb09616
Author: Hai Phan Nguyen <pnghai@gmail.com>
Date:   Wed Jun 10 20:56:28 2020 +0700

    Ignore sync uid in case confirmable mail changed (lynndylanhurley#1407)

    * Ignore sync uid in case confirmable mail changed

    * Update user_omniauth_callbacks.rb

    * Update user_omniauth_callbacks.rb

commit b3d53b6
Author: Maicol Bentancor <maicol.bentancor@gmail.com>
Date:   Tue Jun 2 15:07:22 2020 -0300

    Bump version to 1.1.4 (lynndylanhurley#1406)

commit 2a01f4f
Author: Jamal Mohammed <jamal@mdjamal.com>
Date:   Tue Jun 2 22:07:49 2020 +0530

    Update faq.md (lynndylanhurley#1401)

    Updated FAQ to add **allow_password_change** column if not already added in existing User model.

commit 387306a
Author: Sai Chander <saichander17@gmail.com>
Date:   Wed Apr 29 08:43:10 2020 +0800

    Issue - 1358 Argument error when converting token updated_at using to_time fixed (lynndylanhurley#1388)

commit a3595f4
Author: David Loukidelis <david@loukidelis.com>
Date:   Tue Apr 28 20:41:32 2020 -0400

    Update omniauth_callbacks_controller.rb (lynndylanhurley#1398)

commit ef965d7
Author: Arun Kumar Mohan <arunmohandm@gmail.com>
Date:   Tue Apr 28 19:39:44 2020 -0500

    Fix grammar (lynndylanhurley#1396)

commit ea697f1
Author: H.Sada <47932189+h-sada@users.noreply.github.com>
Date:   Wed Apr 29 09:39:27 2020 +0900

    fixed not_email in ja.yml (lynndylanhurley#1395)

commit 275da3c
Author: Gabriel Bursztein <gabrielbursztein94@gmail.com>
Date:   Mon Mar 30 08:23:22 2020 -0300

    Fix: Save user authentication token after email confirmation (lynndylanhurley#1391)

commit 4a103ed
Author: Ahmed Magdy <ahmedmagdy711@users.noreply.github.com>
Date:   Mon Mar 30 13:19:16 2020 +0200

    Validate that token is valid for patch request last token (lynndylanhurley#1386)

commit 4d2d702
Author: Leo Kiiski <goalaleo@gmail.com>
Date:   Mon Mar 30 14:18:54 2020 +0300

    Fix token-type header key in testing example (lynndylanhurley#1390)

commit ab050c2
Author: Dylan Lederle-Ensign <dylan.lederle.ensign@gmail.com>
Date:   Mon Mar 30 07:17:57 2020 -0400

    Fix broken link (lynndylanhurley#1392)

commit 8c6ea5a
Author: Olle Jonsson <olle.jonsson@gmail.com>
Date:   Mon Mar 30 13:16:53 2020 +0200

    CI build fix: Pin to pry < 0.13 for 2.3 support, workaround CodeClimate reporter issue (lynndylanhurley#1393)

    * gemfiles: Pin to < 0.13 for 2.3 support

    * Workaround: CodeClimate not supporting SimpleCov

      - 0.18 gives us issues
      - see codeclimate/test-reporter#418

commit 49e7203
Author: K-Sato <32632542+K-Sato1995@users.noreply.github.com>
Date:   Sat Feb 29 08:17:59 2020 +0900

    Fix docs/usage/reset_password.md (lynndylanhurley#1382)

commit 55fcd11
Author: Bartek Fijałkowski <brateq@gmail.com>
Date:   Thu Jan 30 21:35:50 2020 +0100

    Add docs for confirmation endpoint (lynndylanhurley#1365)

commit e0d8dfa
Author: sugiken <ynmk1995@gmail.com>
Date:   Fri Jan 31 05:35:31 2020 +0900

    Remove Trackable option from generator (lynndylanhurley#1362)

commit 8326cc7
Author: Bartek Fijałkowski <brateq@gmail.com>
Date:   Thu Jan 30 21:33:45 2020 +0100

    Add rails 6.0 config to travis (lynndylanhurley#1366)

    * Add rails 6.0 config to travis

    * Exclude Travis Rails 6.0 checks for Ruby below 2.5

    * Updates tests to be compatible with Rails 6

    Rails 6 no longer generates migration with id: :uuid, so I changed the range of two ifs in tests and everything goes well now.

    * Add Ruby 2.7.0 to Travis

    * Exclude travis test for Ruby 2.7.0 with Rails 4.2

    Ruby 2.7 comes with Bundler 2 which is not compatible with Rails 4

    * Add to Travis test for rails 6 + mongoid 7

    * Downgrade mongoid-locker for rails 6 gemfile

    * Allow to change primary key type for Rails 6

commit 880a249
Author: Paweł Łuczak <woochaq@gmail.com>
Date:   Thu Jan 30 21:32:47 2020 +0100

    Fix missing polish and portugese translation errors (lynndylanhurley#1377)

commit 3680fd3
Author: Clément Prod'homme <prodhomme.clement@hotmail.fr>
Date:   Wed Jan 29 05:42:35 2020 +0100

    chore(docs): write complete path for authentication_test_spec (lynndylanhurley#1376)

commit 00d7abc
Author: Nicholas Martin <nicholas.martin@marketdojo.com>
Date:   Thu Jan 9 13:23:36 2020 +0000

    Add case sensitive option required to prevent deprecation warning in rails 6 (lynndylanhurley#1368)
  • Loading branch information
cs0511 committed Nov 9, 2021
1 parent 95efe01 commit 7b58623
Show file tree
Hide file tree
Showing 57 changed files with 481 additions and 209 deletions.
91 changes: 51 additions & 40 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ rvm:
- 2.4.7
- 2.5.6
- 2.6.4
- 2.7.0

gemfile:
- gemfiles/rails_4_2.gemfile
- gemfiles/rails_5_0.gemfile
- gemfiles/rails_5_1.gemfile
- gemfiles/rails_5_2.gemfile
- gemfiles/rails_6_0.gemfile

env:
global:
Expand All @@ -28,51 +30,60 @@ env:

matrix:
include:
- rvm: 2.3.8
gemfile: gemfiles/rails_4_2_mongoid_5.gemfile
env: DEVISE_TOKEN_AUTH_ORM=mongoid
- rvm: 2.3.8
gemfile: gemfiles/rails_5_1_mongoid_6.gemfile
env: DEVISE_TOKEN_AUTH_ORM=mongoid
- rvm: 2.4.7
gemfile: gemfiles/rails_5_1_mongoid_7.gemfile
env: DEVISE_TOKEN_AUTH_ORM=mongoid
- rvm: 2.5.6
gemfile: gemfiles/rails_5_2_mongoid_6.gemfile
env: DEVISE_TOKEN_AUTH_ORM=mongoid
- rvm: 2.5.6
gemfile: gemfiles/rails_5_2_mongoid_7.gemfile
env: DEVISE_TOKEN_AUTH_ORM=mongoid
- rvm: 2.6.4
gemfile: gemfiles/rails_5_2_mongoid_7.gemfile
env: DEVISE_TOKEN_AUTH_ORM=mongoid
- name: Code Climate Test Coverage
rmv: 2.5.6
env:
- CC_TEST_REPORTER_ID=44d7688de8e1b567b4af25ec5083c2cc0a355ab911192a7cbefd1ea25b2ffd3d
- GEMFILE_AR=gemfiles/rails_5_1.gemfile
- GEMFILE_MONGOID=gemfiles/rails_5_1_mongoid_7.gemfile
script:
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- ./cc-test-reporter before-build
# with ActiveRecord
- bundle install --jobs=3 --retry=3 --gemfile $GEMFILE_AR
- BUNDLE_GEMFILE=$GEMFILE_AR bundle exec rake --trace db:migrate
- BUNDLE_GEMFILE=$GEMFILE_AR bundle exec rake
- ./cc-test-reporter format-coverage -t simplecov -o coverage/codeclimate.active_record.json coverage/.resultset.json
# with Mongoid
- bundle install --jobs=3 --retry=3 --gemfile $GEMFILE_MONGOID
- BUNDLE_GEMFILE=$GEMFILE_MONGOID DEVISE_TOKEN_AUTH_ORM=mongoid bundle exec rake
- ./cc-test-reporter format-coverage -t simplecov -o coverage/codeclimate.mongoid.json coverage/.resultset.json
# merge test results
- if [[ "$TRAVIS_TEST_RESULT" == 0 ]]; then
- rvm: 2.3.8
gemfile: gemfiles/rails_4_2_mongoid_5.gemfile
env: DEVISE_TOKEN_AUTH_ORM=mongoid
- rvm: 2.3.8
gemfile: gemfiles/rails_5_1_mongoid_6.gemfile
env: DEVISE_TOKEN_AUTH_ORM=mongoid
- rvm: 2.4.7
gemfile: gemfiles/rails_5_1_mongoid_7.gemfile
env: DEVISE_TOKEN_AUTH_ORM=mongoid
- rvm: 2.5.6
gemfile: gemfiles/rails_5_2_mongoid_6.gemfile
env: DEVISE_TOKEN_AUTH_ORM=mongoid
- rvm: 2.5.6
gemfile: gemfiles/rails_5_2_mongoid_7.gemfile
env: DEVISE_TOKEN_AUTH_ORM=mongoid
- rvm: 2.6.4
gemfile: gemfiles/rails_5_2_mongoid_7.gemfile
env: DEVISE_TOKEN_AUTH_ORM=mongoid
- rvm: 2.7.0
gemfile: gemfiles/rails_6_0_mongoid_7.gemfile
env: DEVISE_TOKEN_AUTH_ORM=mongoid
- name: Code Climate Test Coverage
rvm: 2.5.6
env:
- CC_TEST_REPORTER_ID=44d7688de8e1b567b4af25ec5083c2cc0a355ab911192a7cbefd1ea25b2ffd3d
- GEMFILE_AR=gemfiles/rails_5_1.gemfile
- GEMFILE_MONGOID=gemfiles/rails_5_1_mongoid_7.gemfile
script:
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- ./cc-test-reporter before-build
# with ActiveRecord
- bundle install --jobs=3 --retry=3 --gemfile $GEMFILE_AR
- BUNDLE_GEMFILE=$GEMFILE_AR bundle exec rake --trace db:migrate
- BUNDLE_GEMFILE=$GEMFILE_AR bundle exec rake
- ./cc-test-reporter format-coverage coverage/.resultset.json -t simplecov -o coverage/codeclimate.active_record.json
# with Mongoid
- bundle install --jobs=3 --retry=3 --gemfile $GEMFILE_MONGOID
- BUNDLE_GEMFILE=$GEMFILE_MONGOID DEVISE_TOKEN_AUTH_ORM=mongoid bundle exec rake
- ./cc-test-reporter format-coverage coverage/.resultset.json -t simplecov -o coverage/codeclimate.mongoid.json
# merge test results
- if [[ "$TRAVIS_TEST_RESULT" == 0 ]]; then
./cc-test-reporter sum-coverage coverage/codeclimate.active_record.json coverage/codeclimate.mongoid.json;
./cc-test-reporter upload-coverage;
fi
fi
exclude:
- rvm: 2.6.4
gemfile: gemfiles/rails_4_2.gemfile
- rvm: 2.7.0
gemfile: gemfiles/rails_4_2.gemfile
- rvm: 2.3.8
gemfile: gemfiles/rails_6_0.gemfile
- rvm: 2.4.7
gemfile: gemfiles/rails_6_0.gemfile
fast_finish: true

before_install:
Expand Down
3 changes: 2 additions & 1 deletion Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ end
{ name: '5-1', ruby: '2.4.5', rails: '5.1', mongoid: '7.0' },
{ name: '5-2', ruby: '2.5.5', rails: '5.2', mongoid: '6.4' },
{ name: '5-2', ruby: '2.5.5', rails: '5.2', mongoid: '7.0' },
{ name: '5-2', ruby: '2.6.2', rails: '5.2', mongoid: '7.0' }
{ name: '5-2', ruby: '2.6.2', rails: '5.2', mongoid: '7.0' },
{ name: '6-0', ruby: '2.7.0', rails: '6.0', mongoid: '7.0' }
].each do |set|
appraise "rails-#{set[:name]}-mongoid-#{set[:mongoid][0]}" do
gem 'rails', "~> #{set[:rails]}"
Expand Down
48 changes: 47 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,47 @@
# Changelog

## [v1.1.4](https://github.com/lynndylanhurley/devise_token_auth/tree/v1.1.4) (2020-06-02)

[Full Changelog](https://github.com/lynndylanhurley/devise_token_auth/compare/v1.1.3...v1.1.4)

**Closed issues:**

- possible to disable the self-registration endpoint? [\#1402](https://github.com/lynndylanhurley/devise_token_auth/issues/1402)
- Axios formatting and Rails controller validation? [\#1380](https://github.com/lynndylanhurley/devise_token_auth/issues/1380)
- NoMethodError \(undefined method `client' for "\<token\>":String\) [\#1375](https://github.com/lynndylanhurley/devise_token_auth/issues/1375)
- mation\_instruction [\#1373](https://github.com/lynndylanhurley/devise_token_auth/issues/1373)
- Unpermitted parameter :session when signing in using javascript fetch [\#1361](https://github.com/lynndylanhurley/devise_token_auth/issues/1361)
- How do i authenticate with graphql-ruby? [\#1360](https://github.com/lynndylanhurley/devise_token_auth/issues/1360)
- Using DeviseTokenAuth::Concerns::User breaks Devise::confirmable and Devise::reconfirmable [\#1013](https://github.com/lynndylanhurley/devise_token_auth/issues/1013)

**Merged pull requests:**

- Update faq.md [\#1401](https://github.com/lynndylanhurley/devise_token_auth/pull/1401) ([mdjamal](https://github.com/mdjamal))
- Update assign\_provider\_attrs to strip 'name' field [\#1398](https://github.com/lynndylanhurley/devise_token_auth/pull/1398) ([SpLouk](https://github.com/SpLouk))
- Fix grammar [\#1396](https://github.com/lynndylanhurley/devise_token_auth/pull/1396) ([arku](https://github.com/arku))
- \[Refactor\] fixed "not\_email" setting in ja.yml [\#1395](https://github.com/lynndylanhurley/devise_token_auth/pull/1395) ([h-sada](https://github.com/h-sada))
- CI build fix: Pin to pry \< 0.13 for 2.3 support, workaround CodeClimate reporter issue [\#1393](https://github.com/lynndylanhurley/devise_token_auth/pull/1393) ([olleolleolle](https://github.com/olleolleolle))
- Fix broken link [\#1392](https://github.com/lynndylanhurley/devise_token_auth/pull/1392) ([dlederle](https://github.com/dlederle))
- Fix: Save user authentication token after email confirmation [\#1391](https://github.com/lynndylanhurley/devise_token_auth/pull/1391) ([gabrielbursztein2](https://github.com/gabrielbursztein2))
- Fix token-type header key in testing example docs [\#1390](https://github.com/lynndylanhurley/devise_token_auth/pull/1390) ([goalaleo](https://github.com/goalaleo))
- Issue - 1358 Argument error when converting token updated\_at using to… [\#1388](https://github.com/lynndylanhurley/devise_token_auth/pull/1388) ([saichander17](https://github.com/saichander17))
- Validate that token is valid for patch request last token [\#1386](https://github.com/lynndylanhurley/devise_token_auth/pull/1386) ([ahmedmagdy711](https://github.com/ahmedmagdy711))
- Fix docs/usage/reset\_password.md [\#1382](https://github.com/lynndylanhurley/devise_token_auth/pull/1382) ([K-Sato1995](https://github.com/K-Sato1995))
- Fix missing polish and portugese missing translation errors [\#1377](https://github.com/lynndylanhurley/devise_token_auth/pull/1377) ([woochaq](https://github.com/woochaq))
- \[Documentation\] write complete path for authentication\_test\_spec.rb [\#1376](https://github.com/lynndylanhurley/devise_token_auth/pull/1376) ([cprodhomme](https://github.com/cprodhomme))
- Add case sensitive option required to prevent deprecation warning in … [\#1368](https://github.com/lynndylanhurley/devise_token_auth/pull/1368) ([niciliketo](https://github.com/niciliketo))
- Add rails 6.0 config to travis [\#1366](https://github.com/lynndylanhurley/devise_token_auth/pull/1366) ([brateq](https://github.com/brateq))
- Add docs for confirmation endpoint [\#1365](https://github.com/lynndylanhurley/devise_token_auth/pull/1365) ([brateq](https://github.com/brateq))
- Remove Trackable option from generator [\#1362](https://github.com/lynndylanhurley/devise_token_auth/pull/1362) ([SugiKent](https://github.com/SugiKent))
- Please merge again [\#1350](https://github.com/lynndylanhurley/devise_token_auth/pull/1350) ([exocode](https://github.com/exocode))
- Fix dead link [\#1349](https://github.com/lynndylanhurley/devise_token_auth/pull/1349) ([tegandbiscuits](https://github.com/tegandbiscuits))
- detect Mongoid \(till Mongoid will implement it\) [\#1348](https://github.com/lynndylanhurley/devise_token_auth/pull/1348) ([exocode](https://github.com/exocode))
- feat\(oauth-apple\): support Sign in with Apple as a documented OmniAuth provider [\#1347](https://github.com/lynndylanhurley/devise_token_auth/pull/1347) ([booleanbetrayal](https://github.com/booleanbetrayal))
- Add Korean locale [\#1346](https://github.com/lynndylanhurley/devise_token_auth/pull/1346) ([sdu6342](https://github.com/sdu6342))
- doc: remove duplicated test case on ./docs/usage/testing.md [\#1344](https://github.com/lynndylanhurley/devise_token_auth/pull/1344) ([miyataka](https://github.com/miyataka))
- Fix to be able to use Devise::confirmable module [\#1343](https://github.com/lynndylanhurley/devise_token_auth/pull/1343) ([makicamel](https://github.com/makicamel))
- repeat any query params after a fragment [\#1341](https://github.com/lynndylanhurley/devise_token_auth/pull/1341) ([colmben](https://github.com/colmben))

# Change Log

## [v1.1.3](https://github.com/lynndylanhurley/devise_token_auth/tree/v1.1.3) (2019-09-26)
Expand Down Expand Up @@ -2923,4 +2967,6 @@

\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*

\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*

\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def set_request_start
@used_auth_by_token = true

# initialize instance variables
@token = DeviseTokenAuth::TokenFactory.new
@token ||= DeviseTokenAuth::TokenFactory.new
@resource ||= nil
@is_batch_request ||= nil
end
Expand Down Expand Up @@ -46,7 +46,7 @@ def set_user_by_token(mapping = nil)

# check for an existing user, authenticated via warden/devise, if enabled
if DeviseTokenAuth.enable_standard_devise_support
devise_warden_user = warden.user(rc.to_s.underscore.to_sym)
devise_warden_user = warden.user(mapping)
if devise_warden_user && devise_warden_user.tokens[@token.client].nil?
@used_auth_by_token = false
@resource = devise_warden_user
Expand Down Expand Up @@ -140,7 +140,7 @@ def update_auth_header

else
unless @resource.reload.valid?
@resource = resource_class.find(@resource.to_param) # errors remain after reload
@resource = @resource.class.find(@resource.to_param) # errors remain after reload
# if we left the model in a bad state, something is wrong in our app
unless @resource.valid?
raise DeviseTokenAuth::Errors::InvalidModel, "Cannot set auth token in invalid model. Errors: #{@resource.errors.full_messages}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def show

if signed_in?(resource_name)
token = signed_in_resource.create_token
signed_in_resource.save!

redirect_headers = build_redirect_headers(token.token,
token.client,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ def omniauth_params

# break out provider attribute assignment for easy method extension
def assign_provider_attrs(user, auth_hash)
attrs = auth_hash['info'].slice(*user.attribute_names)
attrs = auth_hash['info'].to_hash
attrs = attrs.slice(*user.attribute_names)
user.assign_attributes(attrs)
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/devise_token_auth/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def create
def destroy
# remove auth instance variables so that after_action does not run
user = remove_instance_variable(:@resource) if @resource
client = @token.client if @token.client
client = @token.client
@token.clear!

if user && client && user.tokens[client]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require_relative 'tokens_serialization'

module DeviseTokenAuth::Concerns::ActiveRecordSupport
extend ActiveSupport::Concern

Expand Down
3 changes: 2 additions & 1 deletion app/models/devise_token_auth/concerns/confirmable_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ def postpone_email_change?
protected

def email_value_in_database
if Devise.rails51? && respond_to?(:email_in_database)
rails51 = Rails.gem_version >= Gem::Version.new("5.1.x")
if rails51 && respond_to?(:email_in_database)
email_in_database
else
email_was
Expand Down
20 changes: 16 additions & 4 deletions app/models/devise_token_auth/concerns/tokens_serialization.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
module DeviseTokenAuth::Concerns::TokensSerialization
extend self
# Serialization hash to json
def self.dump(object)
object.each_value(&:compact!) unless object.nil?
JSON.generate(object)
def dump(object)
JSON.generate(object && object.transform_values do |token|
serialize_updated_at(token).compact
end.compact)
end

# Deserialization json to hash
def self.load(json)
def load(json)
case json
when String
JSON.parse(json)
Expand All @@ -16,4 +18,14 @@ def self.load(json)
json
end
end

private

def serialize_updated_at(token)
updated_at_key = ['updated_at', :updated_at].find(&token.method(:[]))

return token unless token[updated_at_key].respond_to?(:iso8601)

token.merge updated_at_key => token[updated_at_key].iso8601
end
end
6 changes: 3 additions & 3 deletions app/models/devise_token_auth/concerns/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,17 +163,17 @@ def refresh_token_is_current?(refresh_token, client)
def token_can_be_reused?(token, client)
# ghetto HashWithIndifferentAccess
updated_at = tokens[client]['updated_at'] || tokens[client][:updated_at]
last_token = tokens[client]['last_token'] || tokens[client][:last_token]
last_token_hash = tokens[client]['last_token'] || tokens[client][:last_token]

return true if (
# ensure that the last token and its creation time exist
updated_at && last_token &&
updated_at && last_token_hash &&

# ensure that previous token falls within the batch buffer throttle time of the last request
updated_at.to_time > Time.zone.now - DeviseTokenAuth.batch_request_buffer_throttle &&

# ensure that the token is valid
DeviseTokenAuth::TokenFactory.valid_token_hash?(last_token)
DeviseTokenAuth::TokenFactory.token_hash_is_token?(last_token_hash, token)
)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module DeviseTokenAuth::Concerns::UserOmniauthCallbacks
validates_presence_of :uid, unless: :email_provider?

# only validate unique emails among email registration users
validates :email, uniqueness: { scope: :provider }, on: :create, if: :email_provider?
validates :email, uniqueness: { case_sensitive: false, scope: :provider }, on: :create, if: :email_provider?

# keep uid in sync with email
before_save :sync_uid
Expand All @@ -23,6 +23,9 @@ def email_provider?
end

def sync_uid
if devise_modules.include?(:confirmable) && !@bypass_confirmation_postpone
return if postpone_email_change?
end
self.uid = email if email_provider?
end
end
2 changes: 1 addition & 1 deletion app/validators/devise_token_auth_email_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class DeviseTokenAuthEmailValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
unless value =~ /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
record.errors[attribute] << email_invalid_message
record.errors.add(attribute, email_invalid_message)
end
end

Expand Down
2 changes: 1 addition & 1 deletion config/locales/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ja:
messages:
validate_sign_up_params: "リクエストボディに適切なアカウント新規登録データを送信してください。"
validate_account_update_params: "リクエストボディに適切なアカウント更新のデータを送信してください。"
not_email: "はメールアドレスではありません"
not_email: "は有効ではありません"
devise:
mailer:
confirmation_instructions:
Expand Down
7 changes: 4 additions & 3 deletions config/locales/pl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ pl:
missing_passwords: "Musisz wypełnić wszystkie pola z etykietą 'Hasło' oraz 'Potwierdzenie hasła'."
successfully_updated: "Twoje hasło zostało zaktualizowane."
errors:
validate_sign_up_params: "Proszę dostarczyć odpowiednie dane logowania w ciele zapytania."
validate_account_update_params: "Proszę dostarczyć odpowiednie dane aktualizacji konta w ciele zapytania."
not_email: "nie jest prawidłowym adresem e-mail"
messages:
validate_sign_up_params: "Proszę dostarczyć odpowiednie dane logowania w ciele zapytania."
validate_account_update_params: "Proszę dostarczyć odpowiednie dane aktualizacji konta w ciele zapytania."
not_email: "nie jest prawidłowym adresem e-mail"
devise:
mailer:
confirmation_instructions:
Expand Down
7 changes: 4 additions & 3 deletions config/locales/pt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ pt:
missing_passwords: "Preencha a senha e a confirmação de senha."
successfully_updated: "Senha atualizada com sucesso."
errors:
validate_sign_up_params: "Os dados submetidos na requisição de registo são inválidos."
validate_account_update_params: "Os dados submetidos para atualização de conta são inválidos."
not_email: "não é um e-mail"
messages:
validate_sign_up_params: "Os dados submetidos na requisição de registo são inválidos."
validate_account_update_params: "Os dados submetidos para atualização de conta são inválidos."
not_email: "não é um e-mail"
devise:
mailer:
confirmation_instructions:
Expand Down
3 changes: 1 addition & 2 deletions devise_token_auth.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ Gem::Specification.new do |s|

s.required_ruby_version = ">= 2.2.0"

s.add_dependency 'rails', '>= 4.2.0', '< 6.1'
s.add_dependency 'sprockets', '3.7.2' # FIXME: breaking changes in 4.0.0
s.add_dependency 'rails', '>= 4.2.0', '< 6.2'
s.add_dependency 'devise', '> 3.5.2', '< 5'
s.add_dependency 'bcrypt', '~> 3.0'

Expand Down
2 changes: 1 addition & 1 deletion docs/conceptual.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ In this case, it's impossible to update the `access-token` header for the second

![batch request overview](https://github.com/lynndylanhurley/ng-token-auth/raw/master/test/app/images/flow/batch-request-overview.jpg)

The "5 second" buffer in the diagram is the default used this gem.
The "5 second" buffer in the diagram is the default used by this gem.

The following diagram details the relationship between the client, server, and access tokens used over time when dealing with batch requests:

Expand Down
Loading

0 comments on commit 7b58623

Please sign in to comment.