mirror of
https://github.com/heartcombo/devise.git
synced 2026-01-09 23:58:06 -05:00
Compare commits
157 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4be9389dcb | ||
|
|
2fde07b9be | ||
|
|
70c5f4bfaf | ||
|
|
0a2e67878a | ||
|
|
c381c916f3 | ||
|
|
9999072620 | ||
|
|
34238e9f18 | ||
|
|
a1c493b009 | ||
|
|
e7f9805fd4 | ||
|
|
8956d4caa1 | ||
|
|
b85911dee3 | ||
|
|
2d1a961c1b | ||
|
|
195cbfb9e5 | ||
|
|
96a3153c23 | ||
|
|
64238fc80e | ||
|
|
afaad713ff | ||
|
|
f48b6f1651 | ||
|
|
34ed989725 | ||
|
|
b52e642c01 | ||
|
|
098345aace | ||
|
|
caa1a55d17 | ||
|
|
fee43f3c11 | ||
|
|
fad60747d5 | ||
|
|
5ceef2d4de | ||
|
|
6635caf12e | ||
|
|
e051360ea2 | ||
|
|
6bb74c5abf | ||
|
|
a79057070c | ||
|
|
12fc5b76d8 | ||
|
|
ad5892391d | ||
|
|
df43a3560a | ||
|
|
9aa17eec07 | ||
|
|
45cc668683 | ||
|
|
19045a483d | ||
|
|
f618b88f91 | ||
|
|
81cb5b00f4 | ||
|
|
54fb582269 | ||
|
|
44f7325a91 | ||
|
|
4ab54943ad | ||
|
|
45245df16a | ||
|
|
63ea6533de | ||
|
|
aedc9b7696 | ||
|
|
28248e3167 | ||
|
|
612e30258c | ||
|
|
76c888268b | ||
|
|
07f2712a22 | ||
|
|
75e8555035 | ||
|
|
a823e510f3 | ||
|
|
2d53cf4424 | ||
|
|
e91b8ee0ba | ||
|
|
eced9b015b | ||
|
|
dbc3c4f08f | ||
|
|
0d56ae2705 | ||
|
|
c1e4031e3b | ||
|
|
964ae53e5b | ||
|
|
2e5b5fcd70 | ||
|
|
241e8077e3 | ||
|
|
55e726e4a7 | ||
|
|
f9d13f015a | ||
|
|
e704221842 | ||
|
|
2a6d608bd8 | ||
|
|
b2dc388556 | ||
|
|
214ce91bf7 | ||
|
|
a460d79b08 | ||
|
|
2f3a59640b | ||
|
|
1102600720 | ||
|
|
4e4e42e1ae | ||
|
|
20e299bce0 | ||
|
|
5be5220e5a | ||
|
|
fcb04f5302 | ||
|
|
45016829d6 | ||
|
|
337db5a3a2 | ||
|
|
a921c10e6a | ||
|
|
101e50f9df | ||
|
|
6064ca8b73 | ||
|
|
2dd322579f | ||
|
|
e72839f4bc | ||
|
|
45438fcfc4 | ||
|
|
f3329110ba | ||
|
|
369ba267ef | ||
|
|
a42033cb04 | ||
|
|
1aab449933 | ||
|
|
ee65cd60c9 | ||
|
|
c000b58c56 | ||
|
|
40e8812d75 | ||
|
|
cc6046b8cc | ||
|
|
6b1ead8654 | ||
|
|
518f6f39bf | ||
|
|
6edbeb82cd | ||
|
|
a8d0a8f63d | ||
|
|
62703943be | ||
|
|
e3a00b27d1 | ||
|
|
8266e85576 | ||
|
|
4372dd402b | ||
|
|
6e4b0b94bc | ||
|
|
bf74a506c8 | ||
|
|
e01fb8bb22 | ||
|
|
14785afe8d | ||
|
|
66a96ab9d6 | ||
|
|
76b87dc0e8 | ||
|
|
cb663e96a3 | ||
|
|
1192c76f62 | ||
|
|
ecd2187652 | ||
|
|
d1571627b7 | ||
|
|
52b24e41de | ||
|
|
5f62f28d6e | ||
|
|
c84169122f | ||
|
|
bafc23eae5 | ||
|
|
aa6cb411bc | ||
|
|
354df3bc65 | ||
|
|
6f140faf0d | ||
|
|
05bf574799 | ||
|
|
40f02ae69b | ||
|
|
3aedbf0a4d | ||
|
|
fa067b31c6 | ||
|
|
517010e2c5 | ||
|
|
4adc792422 | ||
|
|
0640b318ca | ||
|
|
95fad8b408 | ||
|
|
94adec3cee | ||
|
|
87b73540a4 | ||
|
|
25f908ad9c | ||
|
|
4656e96d9e | ||
|
|
389cd85d47 | ||
|
|
3b0bc08ec6 | ||
|
|
2eca92f950 | ||
|
|
acc45c5a44 | ||
|
|
e4dd1509c4 | ||
|
|
b8f644198d | ||
|
|
715192a770 | ||
|
|
31aceeb104 | ||
|
|
af8f7e9797 | ||
|
|
6c916488af | ||
|
|
246a50876a | ||
|
|
8866b8e5eb | ||
|
|
1c8e97c75a | ||
|
|
cd9ad848fb | ||
|
|
be15116426 | ||
|
|
9d90a559ce | ||
|
|
d98f38cf5f | ||
|
|
f99636da76 | ||
|
|
6260c29a86 | ||
|
|
45481df14a | ||
|
|
7eccd4e9c6 | ||
|
|
2cf18f99e0 | ||
|
|
bcbea08187 | ||
|
|
b20de505ab | ||
|
|
20bde34981 | ||
|
|
e9abba797a | ||
|
|
dac90eeb80 | ||
|
|
f220b992c3 | ||
|
|
2bb8e1c236 | ||
|
|
e44a8b2d43 | ||
|
|
268bd69164 | ||
|
|
d750709250 | ||
|
|
c9a2d0654e | ||
|
|
26723d9bbc |
45
.travis.yml
45
.travis.yml
@@ -1,49 +1,40 @@
|
||||
language: ruby
|
||||
|
||||
rvm:
|
||||
- 2.1.10
|
||||
- 2.2.8
|
||||
- 2.3.5
|
||||
- 2.4.2
|
||||
- 2.5.0
|
||||
- 2.3.8
|
||||
- 2.4.5
|
||||
- 2.5.3
|
||||
- 2.6.0
|
||||
- ruby-head
|
||||
|
||||
gemfile:
|
||||
- Gemfile
|
||||
- gemfiles/Gemfile.rails-5.2-rc1
|
||||
- gemfiles/Gemfile.rails-6.0-stable
|
||||
- gemfiles/Gemfile.rails-5.2-stable
|
||||
- gemfiles/Gemfile.rails-5.0-stable
|
||||
- gemfiles/Gemfile.rails-4.2-stable
|
||||
- gemfiles/Gemfile.rails-4.1-stable
|
||||
|
||||
matrix:
|
||||
exclude:
|
||||
- rvm: 2.1.10
|
||||
gemfile: Gemfile
|
||||
- rvm: 2.1.10
|
||||
gemfile: gemfiles/Gemfile.rails-5.2-rc1
|
||||
- rvm: 2.5.0
|
||||
gemfile: gemfiles/Gemfile.rails-4.1-stable
|
||||
- rvm: 2.4.2
|
||||
gemfile: gemfiles/Gemfile.rails-4.1-stable
|
||||
- rvm: ruby-head
|
||||
gemfile: gemfiles/Gemfile.rails-4.1-stable
|
||||
- rvm: 2.1.10
|
||||
gemfile: gemfiles/Gemfile.rails-5.0-stable
|
||||
- rvm: 2.1.10
|
||||
gemfile: Gemfile
|
||||
- rvm: 2.3.8
|
||||
gemfile: gemfiles/Gemfile.rails-6.0-stable
|
||||
- rvm: 2.4.5
|
||||
gemfile: gemfiles/Gemfile.rails-6.0-stable
|
||||
- rvm: 2.5.3
|
||||
- env: DEVISE_ORM=mongoid
|
||||
gemfile: Gemfile
|
||||
- env: DEVISE_ORM=mongoid
|
||||
gemfile: gemfiles/Gemfile.rails-5.0-stable
|
||||
- env: DEVISE_ORM=mongoid
|
||||
gemfile: gemfiles/Gemfile.rails-5.2-rc1
|
||||
gemfile: gemfiles/Gemfile.rails-5.2-stable
|
||||
- env: DEVISE_ORM=mongoid
|
||||
gemfile: gemfiles/Gemfile.rails-6.0-stable
|
||||
allow_failures:
|
||||
- rvm: ruby-head
|
||||
- gemfile: gemfiles/Gemfile.rails-6.0-stable
|
||||
|
||||
services:
|
||||
- mongodb
|
||||
|
||||
sudo: false
|
||||
|
||||
cache: bundler
|
||||
|
||||
env:
|
||||
@@ -51,9 +42,7 @@ env:
|
||||
- DEVISE_ORM=active_record
|
||||
- DEVISE_ORM=mongoid
|
||||
|
||||
before_install:
|
||||
- "rm ${BUNDLE_GEMFILE}.lock"
|
||||
- gem update --system
|
||||
before_install: "rm ${BUNDLE_GEMFILE}.lock"
|
||||
|
||||
before_script: "bundle update"
|
||||
|
||||
|
||||
95
CHANGELOG.md
95
CHANGELOG.md
@@ -1,4 +1,95 @@
|
||||
### 5.0.0-rc
|
||||
|
||||
* enhancements
|
||||
* Suport multiple translations according to unlock strategy (by @sivagollapalli)
|
||||
* Use `ActiveSupport::SecurityUtils.secure_compare` inside `Devise.secure_compare` (by @shrirambalakrishnan)
|
||||
* Update trackable fields only in a database sign in (by @waiting-for-dev)
|
||||
|
||||
* deprecations
|
||||
* Remove Rails 4, Ruby 2.1 and Ruby 2.2 support (by @feliperenan)
|
||||
|
||||
### Unreleased
|
||||
* enhancements
|
||||
* Increase default stretches to 12 (by @sergey-alekseev)
|
||||
|
||||
### 4.7.1 - 2019-09-06
|
||||
|
||||
* bug fixes
|
||||
* Fix an edge case where records with a blank `confirmation_token` could be confirmed (by @tegon)
|
||||
* Fix typo inside `update_needs_confirmation` i18n key (by @lslm)
|
||||
|
||||
### 4.7.0 - 2019-08-19
|
||||
|
||||
* enhancements
|
||||
* Support Rails 6.0
|
||||
* Update CI to rails 6.0.0.beta3 (by @tunnes)
|
||||
* refactor method name to be more consistent (by @saiqulhaq)
|
||||
* Fix rails 6.0.rc1 email uniqueness validation deprecation warning (by @Vasfed)
|
||||
|
||||
* bug fixes
|
||||
* Add `autocomplete="new-password"` to `password_confirmation` fields (by @ferrl)
|
||||
* Fix rails_51_and_up? method for Rails 6.rc1 (by @igorkasyanchuk)
|
||||
|
||||
### 4.6.2 - 2019-03-26
|
||||
|
||||
* bug fixes
|
||||
* Revert "Set `encrypted_password` to `nil` when `password` is set to `nil`" since it broke backward compatibility with existing applications. See more on https://github.com/plataformatec/devise/issues/5033#issuecomment-476386275 (by @mracos)
|
||||
|
||||
### 4.6.1 - 2019-02-11
|
||||
|
||||
* bug fixes
|
||||
* Check if `root_path` is defined with `#respond_to?` instead of `#present` (by @tegon)
|
||||
|
||||
### 4.6.0 - 2019-02-07
|
||||
|
||||
* enhancements
|
||||
* Allow to skip email and password change notifications (by @iorme1)
|
||||
* Include the use of `nil` for `allow_unconfirmed_access_for` in the docs (by @joaumg)
|
||||
* Ignore useless files into the `.gem` file (by @huacnlee)
|
||||
* Explain the code that prevents enumeration attacks inside `Devise::Strategies::DatabaseAuthenticatable` (by @tegon)
|
||||
* Refactor the `devise_error_messages!` helper to render a partial (by @prograhamer)
|
||||
* Add an option (`Devise.sign_in_after_change_password`) to not automatically sign in a user after changing a password (by @knjko)
|
||||
|
||||
* bug fixes
|
||||
* Fix missing comma in Simple Form generator (by @colinross)
|
||||
* Fix error with migration generator in Rails 6 (by @oystersauce8)
|
||||
* Set `encrypted_password` to `nil` when `password` is set to `nil` (by @sivagollapalli)
|
||||
* Consider whether the request supports flash messages inside `Devise::Controllers::Helpers#is_flashing_format?` (by @colinross)
|
||||
* Fix typo inside `Devise::Generators::ControllersGenerator` (by @kopylovvlad)
|
||||
* Sanitize parameters inside `Devise::Models::Authenticatable#find_or_initialize_with_errors` (by @rlue)
|
||||
* `#after_database_authentication` callback was not called after authentication on password reset (by @kanmaniselvan)
|
||||
* Fix corner case when `#confirmation_period_valid?` was called at the same second as `confirmation_sent_at` was set. Mostly true for date types that only have second precisions. (by @stanhu)
|
||||
* Fix unclosed `li` tag in `error_messages` partial (by @mracos)
|
||||
* Fix Routes issue when devise engine is mounted in another engine on Rails versions lower than 5.1 (by @a-barbieri)
|
||||
* Make `#increment_failed_attempts` concurrency safe (by @tegon)
|
||||
* Apply Test Helper fix to Rails 6.0 as well as 5.x (by @matthewrudy)
|
||||
|
||||
|
||||
* deprecations
|
||||
* The second argument of `DatabaseAuthenticatable`'s `#update_with_password` and `#update_without_password` is deprecated and will be removed in the next major version. It was added to support a feature deprecated in Rails 4, so you can safely remove it from your code. (by @ihatov08)
|
||||
* The `DeviseHelper.devise_error_messages!` is deprecated and will be removed in the next major version. Use the `devise/shared/error_messages` partial instead. (by @mracos)
|
||||
|
||||
### 4.5.0 - 2018-08-15
|
||||
|
||||
* enhancements
|
||||
* Use `before_action` instead of `before_filter` (by @edenthecat)
|
||||
* Allow people to extend devise failure app, through invoking `ActiveSupport.run_load_hooks` once `Devise::FailureApp` is loaded (by @wnm)
|
||||
* Use `update` instead of `update_attributes` (by @koic)
|
||||
* Split IP resolution from `update_tracked_fields` (by @mckramer)
|
||||
* upgrade dependencies for rails and responders (by @lancecarlson)
|
||||
* Add `autocomplete="new-password"` to new password fields (by @gssbzn)
|
||||
* Add `autocomplete="current-password"` to current password fields (by @gssbzn)
|
||||
* Remove redundant `self` from `database_authenticatable` module (by @abhishekkanojia)
|
||||
* Update `simple_form` templates with changes from https://github.com/plataformatec/devise/commit/16b3d6d67c7e017d461ea17ed29ea9738dc77e83 and https://github.com/plataformatec/devise/commit/6260c29a867b9a656f1e1557abe347a523178fab (by @gssbzn)
|
||||
* Remove `:trackable` from the default modules in the generators, to be more GDPR-friendly (by @fakenine)
|
||||
|
||||
* bug fixes
|
||||
* Use same string on failed login regardless of whether account exists when in paranoid mode (by @TonyMK9068)
|
||||
* Fix error when params is not a hash inside `Devise::ParameterSanitizer` (by @b0nn1e)
|
||||
* Look for `secret_key_base` inside `Rails.application` (by @gencer)
|
||||
* Ensure `Devise::ParameterFilter` does not add missing keys when called with a hash that has a `default` / `default_proc`
|
||||
configured (by @joshpencheon)
|
||||
* Adds `is_navigational_format?` check to `after_sign_up_path_for` to keep consistency (by @iorme1)
|
||||
|
||||
### 4.4.3 - 2018-03-17
|
||||
|
||||
@@ -44,7 +135,7 @@
|
||||
* Validations were being ignored on singup in the `Trackable#update_tracked_fields!` method. (by @AshleyFoster)
|
||||
* Do not modify options for `#serializable_hash`. (by @guigs)
|
||||
* Email confirmations were being sent on sign in/sign out for application using `mongoid` and `mongoid-paperclip` gems. This is because previously we were checking if a model is from Active Record by checking if the method `after_commit` was defined - since `mongoid` doesn' have one - but `mongoid-paperclip` gem does define one, which cause this issue. (by @fjg)
|
||||
|
||||
|
||||
### 4.3.0 - 2017-05-14
|
||||
|
||||
* Enhancements
|
||||
@@ -233,7 +324,7 @@
|
||||
end
|
||||
```
|
||||
|
||||
You can check more examples and explanations on the [README section](/plataformatec/devise#strong-parameters)
|
||||
You can check more examples and explanations on the [README section](README.md#strong-parameters)
|
||||
and on the [ParameterSanitizer docs](lib/devise/parameter_sanitizer.rb).
|
||||
|
||||
Please check [3-stable](https://github.com/plataformatec/devise/blob/3-stable/CHANGELOG.md)
|
||||
|
||||
@@ -64,7 +64,7 @@ open issues to help troubleshoot and fix existing bugs on Devise. Here is what
|
||||
you can do:
|
||||
|
||||
* Help ensure that existing issues follows the recommendations from the
|
||||
_[Reporting Issues](#reporting-issues)_ section, providing feeback to the issue's
|
||||
_[Reporting Issues](#reporting-issues)_ section, providing feedback to the issue's
|
||||
author on what might be missing.
|
||||
* Review and update the existing content of our [Wiki](https://github.com/plataformatec/devise/wiki)
|
||||
with up to date instructions and code samples - the wiki was grown with several
|
||||
|
||||
7
Gemfile
7
Gemfile
@@ -4,7 +4,7 @@ source "https://rubygems.org"
|
||||
|
||||
gemspec
|
||||
|
||||
gem "rails", "~> 5.1"
|
||||
gem "rails", "~> 5.2"
|
||||
gem "omniauth", "~> 1.3"
|
||||
gem "oauth2"
|
||||
gem "omniauth-oauth2"
|
||||
@@ -14,11 +14,12 @@ gem "activemodel-serializers-xml", github: "rails/activemodel-serializers-xml"
|
||||
|
||||
gem "rails-controller-testing"
|
||||
|
||||
gem "responders", "~> 2.1"
|
||||
gem "responders", "~> 2.4"
|
||||
|
||||
group :test do
|
||||
gem "omniauth-facebook"
|
||||
gem "omniauth-openid"
|
||||
gem "timecop"
|
||||
gem "webrat", "0.7.3", require: false
|
||||
gem "mocha", "~> 1.1", require: false
|
||||
end
|
||||
@@ -30,7 +31,7 @@ platforms :jruby do
|
||||
end
|
||||
|
||||
platforms :ruby do
|
||||
gem "sqlite3"
|
||||
gem "sqlite3", "~> 1.3.6"
|
||||
end
|
||||
|
||||
# TODO:
|
||||
|
||||
163
Gemfile.lock
163
Gemfile.lock
@@ -10,91 +10,99 @@ GIT
|
||||
PATH
|
||||
remote: .
|
||||
specs:
|
||||
devise (4.4.3)
|
||||
devise (4.7.1)
|
||||
bcrypt (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
railties (>= 4.1.0, < 6.0)
|
||||
railties (>= 5.0)
|
||||
responders
|
||||
warden (~> 1.2.3)
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
actioncable (5.1.0)
|
||||
actionpack (= 5.1.0)
|
||||
actioncable (5.2.0)
|
||||
actionpack (= 5.2.0)
|
||||
nio4r (~> 2.0)
|
||||
websocket-driver (~> 0.6.1)
|
||||
actionmailer (5.1.0)
|
||||
actionpack (= 5.1.0)
|
||||
actionview (= 5.1.0)
|
||||
activejob (= 5.1.0)
|
||||
websocket-driver (>= 0.6.1)
|
||||
actionmailer (5.2.0)
|
||||
actionpack (= 5.2.0)
|
||||
actionview (= 5.2.0)
|
||||
activejob (= 5.2.0)
|
||||
mail (~> 2.5, >= 2.5.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
actionpack (5.1.0)
|
||||
actionview (= 5.1.0)
|
||||
activesupport (= 5.1.0)
|
||||
actionpack (5.2.0)
|
||||
actionview (= 5.2.0)
|
||||
activesupport (= 5.2.0)
|
||||
rack (~> 2.0)
|
||||
rack-test (~> 0.6.3)
|
||||
rack-test (>= 0.6.3)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||
actionview (5.1.0)
|
||||
activesupport (= 5.1.0)
|
||||
actionview (5.2.0)
|
||||
activesupport (= 5.2.0)
|
||||
builder (~> 3.1)
|
||||
erubi (~> 1.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
||||
activejob (5.1.0)
|
||||
activesupport (= 5.1.0)
|
||||
activejob (5.2.0)
|
||||
activesupport (= 5.2.0)
|
||||
globalid (>= 0.3.6)
|
||||
activemodel (5.1.0)
|
||||
activesupport (= 5.1.0)
|
||||
activerecord (5.1.0)
|
||||
activemodel (= 5.1.0)
|
||||
activesupport (= 5.1.0)
|
||||
arel (~> 8.0)
|
||||
activesupport (5.1.0)
|
||||
activemodel (5.2.0)
|
||||
activesupport (= 5.2.0)
|
||||
activerecord (5.2.0)
|
||||
activemodel (= 5.2.0)
|
||||
activesupport (= 5.2.0)
|
||||
arel (>= 9.0)
|
||||
activestorage (5.2.0)
|
||||
actionpack (= 5.2.0)
|
||||
activerecord (= 5.2.0)
|
||||
marcel (~> 0.3.1)
|
||||
activesupport (5.2.0)
|
||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||
i18n (~> 0.7)
|
||||
i18n (>= 0.7, < 2)
|
||||
minitest (~> 5.1)
|
||||
tzinfo (~> 1.1)
|
||||
arel (8.0.0)
|
||||
bcrypt (3.1.11)
|
||||
arel (9.0.0)
|
||||
bcrypt (3.1.13)
|
||||
builder (3.2.3)
|
||||
concurrent-ruby (1.0.5)
|
||||
erubi (1.6.0)
|
||||
crass (1.0.4)
|
||||
erubi (1.7.1)
|
||||
faraday (0.11.0)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
globalid (0.4.0)
|
||||
globalid (0.4.1)
|
||||
activesupport (>= 4.2.0)
|
||||
hashie (3.5.5)
|
||||
i18n (0.8.1)
|
||||
hashie (3.5.7)
|
||||
i18n (1.0.0)
|
||||
concurrent-ruby (~> 1.0)
|
||||
jwt (1.5.6)
|
||||
loofah (2.0.3)
|
||||
loofah (2.2.2)
|
||||
crass (~> 1.0.2)
|
||||
nokogiri (>= 1.5.9)
|
||||
mail (2.6.5)
|
||||
mime-types (>= 1.16, < 4)
|
||||
mail (2.7.0)
|
||||
mini_mime (>= 0.1.1)
|
||||
marcel (0.3.2)
|
||||
mimemagic (~> 0.3.2)
|
||||
metaclass (0.0.4)
|
||||
method_source (0.8.2)
|
||||
mime-types (3.1)
|
||||
mime-types-data (~> 3.2015)
|
||||
mime-types-data (3.2016.0521)
|
||||
mini_portile2 (2.1.0)
|
||||
minitest (5.10.1)
|
||||
method_source (0.9.0)
|
||||
mimemagic (0.3.2)
|
||||
mini_mime (1.0.0)
|
||||
mini_portile2 (2.3.0)
|
||||
minitest (5.11.3)
|
||||
mocha (1.2.1)
|
||||
metaclass (~> 0.0.1)
|
||||
multi_json (1.12.1)
|
||||
multi_xml (0.6.0)
|
||||
multipart-post (2.0.0)
|
||||
nio4r (2.0.0)
|
||||
nokogiri (1.7.1)
|
||||
mini_portile2 (~> 2.1.0)
|
||||
nio4r (2.3.0)
|
||||
nokogiri (1.8.2)
|
||||
mini_portile2 (~> 2.3.0)
|
||||
oauth2 (1.3.1)
|
||||
faraday (>= 0.8, < 0.12)
|
||||
jwt (~> 1.0)
|
||||
multi_json (~> 1.3)
|
||||
multi_xml (~> 0.5)
|
||||
rack (>= 1.2, < 3)
|
||||
omniauth (1.6.1)
|
||||
omniauth (1.8.1)
|
||||
hashie (>= 3.4.6, < 3.6.0)
|
||||
rack (>= 1.6.2, < 3)
|
||||
omniauth-facebook (4.0.0)
|
||||
@@ -106,40 +114,41 @@ GEM
|
||||
omniauth (~> 1.0)
|
||||
rack-openid (~> 1.3.1)
|
||||
orm_adapter (0.5.0)
|
||||
rack (2.0.1)
|
||||
rack (2.0.4)
|
||||
rack-openid (1.3.1)
|
||||
rack (>= 1.1.0)
|
||||
ruby-openid (>= 2.1.8)
|
||||
rack-test (0.6.3)
|
||||
rack (>= 1.0)
|
||||
rails (5.1.0)
|
||||
actioncable (= 5.1.0)
|
||||
actionmailer (= 5.1.0)
|
||||
actionpack (= 5.1.0)
|
||||
actionview (= 5.1.0)
|
||||
activejob (= 5.1.0)
|
||||
activemodel (= 5.1.0)
|
||||
activerecord (= 5.1.0)
|
||||
activesupport (= 5.1.0)
|
||||
bundler (>= 1.3.0, < 2.0)
|
||||
railties (= 5.1.0)
|
||||
rack-test (1.0.0)
|
||||
rack (>= 1.0, < 3)
|
||||
rails (5.2.0)
|
||||
actioncable (= 5.2.0)
|
||||
actionmailer (= 5.2.0)
|
||||
actionpack (= 5.2.0)
|
||||
actionview (= 5.2.0)
|
||||
activejob (= 5.2.0)
|
||||
activemodel (= 5.2.0)
|
||||
activerecord (= 5.2.0)
|
||||
activestorage (= 5.2.0)
|
||||
activesupport (= 5.2.0)
|
||||
bundler (>= 1.3.0)
|
||||
railties (= 5.2.0)
|
||||
sprockets-rails (>= 2.0.0)
|
||||
rails-controller-testing (1.0.1)
|
||||
actionpack (~> 5.x)
|
||||
actionview (~> 5.x)
|
||||
activesupport (~> 5.x)
|
||||
rails-dom-testing (2.0.2)
|
||||
activesupport (>= 4.2.0, < 6.0)
|
||||
nokogiri (~> 1.6)
|
||||
rails-html-sanitizer (1.0.3)
|
||||
loofah (~> 2.0)
|
||||
railties (5.1.0)
|
||||
actionpack (= 5.1.0)
|
||||
activesupport (= 5.1.0)
|
||||
rails-dom-testing (2.0.3)
|
||||
activesupport (>= 4.2.0)
|
||||
nokogiri (>= 1.6)
|
||||
rails-html-sanitizer (1.0.4)
|
||||
loofah (~> 2.2, >= 2.2.2)
|
||||
railties (5.2.0)
|
||||
actionpack (= 5.2.0)
|
||||
activesupport (= 5.2.0)
|
||||
method_source
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.18.1, < 2.0)
|
||||
rake (12.0.0)
|
||||
rake (12.3.1)
|
||||
rdoc (5.1.0)
|
||||
responders (2.4.0)
|
||||
actionpack (>= 4.2.0, < 5.3)
|
||||
@@ -148,14 +157,15 @@ GEM
|
||||
sprockets (3.7.1)
|
||||
concurrent-ruby (~> 1.0)
|
||||
rack (> 1, < 3)
|
||||
sprockets-rails (3.2.0)
|
||||
sprockets-rails (3.2.1)
|
||||
actionpack (>= 4.0)
|
||||
activesupport (>= 4.0)
|
||||
sprockets (>= 3.0.0)
|
||||
sqlite3 (1.3.13)
|
||||
thor (0.19.4)
|
||||
thor (0.20.0)
|
||||
thread_safe (0.3.6)
|
||||
tzinfo (1.2.3)
|
||||
timecop (0.8.1)
|
||||
tzinfo (1.2.5)
|
||||
thread_safe (~> 0.1)
|
||||
warden (1.2.7)
|
||||
rack (>= 1.0)
|
||||
@@ -163,9 +173,9 @@ GEM
|
||||
nokogiri (>= 1.2.0)
|
||||
rack (>= 1.0)
|
||||
rack-test (>= 0.5.3)
|
||||
websocket-driver (0.6.5)
|
||||
websocket-driver (0.7.0)
|
||||
websocket-extensions (>= 0.1.0)
|
||||
websocket-extensions (0.1.2)
|
||||
websocket-extensions (0.1.3)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
@@ -182,12 +192,13 @@ DEPENDENCIES
|
||||
omniauth-facebook
|
||||
omniauth-oauth2
|
||||
omniauth-openid
|
||||
rails (~> 5.1)
|
||||
rails (~> 5.2)
|
||||
rails-controller-testing
|
||||
rdoc
|
||||
responders (~> 2.1)
|
||||
sqlite3
|
||||
responders (~> 2.4)
|
||||
sqlite3 (~> 1.3.6)
|
||||
timecop
|
||||
webrat (= 0.7.3)
|
||||
|
||||
BUNDLED WITH
|
||||
1.16.1
|
||||
1.17.3
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
## Precheck
|
||||
## Pre-check
|
||||
|
||||
- Do not use the issues tracker for help or support, try Stack Overflow.
|
||||
- For bugs, do a quick search and make sure the bug has not yet been reported
|
||||
- If you found a security bug, do not report it through GitHub. Please send an e-mail to opensource@plataformatec.com.br instead.
|
||||
- Finally, be nice and have fun!
|
||||
|
||||
## Environment
|
||||
@@ -12,7 +13,7 @@
|
||||
|
||||
## Current behavior
|
||||
|
||||
Include code samples, errors, steps to reproduce the error and stacktraces if appropriate.
|
||||
Include code samples, errors, steps to reproduce the error and stack traces if appropriate.
|
||||
|
||||
Will be even more helpful if you provide a sample application or a test case that reproduces the error.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Copyright 2009-2017 Plataformatec. http://plataformatec.com.br
|
||||
Copyright 2009-2019 Plataformatec. http://plataformatec.com.br
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
||||
85
README.md
85
README.md
@@ -16,16 +16,16 @@ Devise is a flexible authentication solution for Rails based on Warden. It:
|
||||
|
||||
It's composed of 10 modules:
|
||||
|
||||
* [Database Authenticatable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/DatabaseAuthenticatable): hashes and stores a password in the database to validate the authenticity of a user while signing in. The authentication can be done both through POST requests or HTTP Basic Authentication.
|
||||
* [Omniauthable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Omniauthable): adds OmniAuth (https://github.com/omniauth/omniauth) support.
|
||||
* [Confirmable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Confirmable): sends emails with confirmation instructions and verifies whether an account is already confirmed during sign in.
|
||||
* [Recoverable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Recoverable): resets the user password and sends reset instructions.
|
||||
* [Registerable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Registerable): handles signing up users through a registration process, also allowing them to edit and destroy their account.
|
||||
* [Rememberable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Rememberable): manages generating and clearing a token for remembering the user from a saved cookie.
|
||||
* [Trackable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Trackable): tracks sign in count, timestamps and IP address.
|
||||
* [Timeoutable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Timeoutable): expires sessions that have not been active in a specified period of time.
|
||||
* [Validatable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Validatable): provides validations of email and password. It's optional and can be customized, so you're able to define your own validations.
|
||||
* [Lockable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Lockable): locks an account after a specified number of failed sign-in attempts. Can unlock via email or after a specified time period.
|
||||
* [Database Authenticatable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/DatabaseAuthenticatable): hashes and stores a password in the database to validate the authenticity of a user while signing in. The authentication can be done both through POST requests or HTTP Basic Authentication.
|
||||
* [Omniauthable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Omniauthable): adds OmniAuth (https://github.com/omniauth/omniauth) support.
|
||||
* [Confirmable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Confirmable): sends emails with confirmation instructions and verifies whether an account is already confirmed during sign in.
|
||||
* [Recoverable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Recoverable): resets the user password and sends reset instructions.
|
||||
* [Registerable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Registerable): handles signing up users through a registration process, also allowing them to edit and destroy their account.
|
||||
* [Rememberable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Rememberable): manages generating and clearing a token for remembering the user from a saved cookie.
|
||||
* [Trackable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Trackable): tracks sign in count, timestamps and IP address.
|
||||
* [Timeoutable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Timeoutable): expires sessions that have not been active in a specified period of time.
|
||||
* [Validatable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Validatable): provides validations of email and password. It's optional and can be customized, so you're able to define your own validations.
|
||||
* [Lockable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Lockable): locks an account after a specified number of failed sign-in attempts. Can unlock via email or after a specified time period.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
@@ -53,14 +53,10 @@ It's composed of 10 modules:
|
||||
- [Integration tests](#integration-tests)
|
||||
- [OmniAuth](#omniauth)
|
||||
- [Configuring multiple models](#configuring-multiple-models)
|
||||
- [Create a migration with the required fields](#create-a-migration-with-the-required-fields)
|
||||
- [Inside your Admin model](#inside-your-admin-model)
|
||||
- [Inside your routes](#inside-your-routes)
|
||||
- [Inside your protected controller](#inside-your-protected-controller)
|
||||
- [Inside your controllers and views](#inside-your-controllers-and-views)
|
||||
- [ActiveJob Integration](#activejob-integration)
|
||||
- [Password reset tokens and Rails logs](#password-reset-tokens-and-rails-logs)
|
||||
- [Other ORMs](#other-orms)
|
||||
- [Rails API mode](#rails-api-mode)
|
||||
- [Additional information](#additional-information)
|
||||
- [Heroku](#heroku)
|
||||
- [Warden](#warden)
|
||||
@@ -140,18 +136,36 @@ Please note that the command output will show the variable value being used.
|
||||
|
||||
### BUNDLE_GEMFILE
|
||||
We can use this variable to tell bundler what Gemfile it should use (instead of the one in the current directory).
|
||||
Inside the [gemfiles](https://github.com/plataformatec/devise/tree/master/gemfiles) directory, we have one for each version of Rails we support. When you send us a pull request, it may happen that the test suite brakes on Travis using some of them. If that's the case, you can simulate the same environment using the `BUNDLE_GEMFILE` variable.
|
||||
For example, if the tests broke using Ruby 2.4.2 and Rails 4.1, you can do the following:
|
||||
Inside the [gemfiles](https://github.com/plataformatec/devise/tree/master/gemfiles) directory, we have one for each version of Rails we support. When you send us a pull request, it may happen that the test suite breaks on Travis using some of them. If that's the case, you can simulate the same environment using the `BUNDLE_GEMFILE` variable.
|
||||
For example, if the tests broke using Ruby 2.5.0 and Rails 5.0, you can do the following:
|
||||
```bash
|
||||
rbenv shell 2.4.2 # or rvm use 2.4.2
|
||||
BUNDLE_GEMFILE=gemfiles/Gemfile.rails-4.1-stable bundle install
|
||||
BUNDLE_GEMFILE=gemfiles/Gemfile.rails-4.1-stable bin/test
|
||||
rbenv shell 2.5.0 # or rvm use 2.5.0
|
||||
BUNDLE_GEMFILE=gemfiles/Gemfile.rails-5.0-stable bundle install
|
||||
BUNDLE_GEMFILE=gemfiles/Gemfile.rails-5.0-stable bin/test
|
||||
```
|
||||
|
||||
You can also combine both of them if the tests broke for Mongoid:
|
||||
```bash
|
||||
BUNDLE_GEMFILE=gemfiles/Gemfile.rails-4.1-stable bundle install
|
||||
BUNDLE_GEMFILE=gemfiles/Gemfile.rails-4.1-stable DEVISE_ORM=mongoid bin/test
|
||||
BUNDLE_GEMFILE=gemfiles/Gemfile.rails-5.0-stable bundle install
|
||||
BUNDLE_GEMFILE=gemfiles/Gemfile.rails-5.0-stable DEVISE_ORM=mongoid bin/test
|
||||
```
|
||||
|
||||
### Running tests
|
||||
Devise uses [Mini Test](https://github.com/seattlerb/minitest) as test framework.
|
||||
|
||||
* Running all tests:
|
||||
```bash
|
||||
bin/test
|
||||
```
|
||||
|
||||
* Running tests for an specific file:
|
||||
```bash
|
||||
bin/test test/models/trackable_test.rb
|
||||
```
|
||||
|
||||
* Running a specific test given a regex:
|
||||
```bash
|
||||
bin/test test/models/trackable_test.rb:16
|
||||
```
|
||||
|
||||
## Starting with Rails?
|
||||
@@ -160,13 +174,13 @@ If you are building your first Rails application, we recommend you *do not* use
|
||||
|
||||
* Michael Hartl's online book: https://www.railstutorial.org/book/modeling_users
|
||||
* Ryan Bates' Railscast: http://railscasts.com/episodes/250-authentication-from-scratch
|
||||
* Codecademy's Ruby on Rails: Authentication and Authorization: http://www.codecademy.com/en/learn/rails-auth
|
||||
* Codecademy's Ruby on Rails: Authentication and Authorization: https://www.codecademy.com/learn/rails-auth
|
||||
|
||||
Once you have solidified your understanding of Rails and authentication mechanisms, we assure you Devise will be very pleasant to work with. :smiley:
|
||||
|
||||
## Getting started
|
||||
|
||||
Devise 4.0 works with Rails 4.1 onwards. You can add it to your Gemfile with:
|
||||
Devise 5.0 works with Rails 5.0 onwards. Add the following line to your Gemfile:
|
||||
|
||||
```ruby
|
||||
gem 'devise'
|
||||
@@ -195,7 +209,7 @@ In the following command you will replace `MODEL` with the class name used for t
|
||||
$ rails generate devise MODEL
|
||||
```
|
||||
|
||||
Next, check the MODEL for any additional configuration options you might want to add, such as confirmable or lockable. If you add an option, be sure to inspect the migration file (created by the generator if your ORM supports them) and uncomment the appropriate section. For example, if you add the confirmable option in the model, you'll need to uncomment the Confirmable section in the migration.
|
||||
Next, check the MODEL for any additional configuration options you might want to add, such as confirmable or lockable. If you add an option, be sure to inspect the migration file (created by the generator if your ORM supports them) and uncomment the appropriate section. For example, if you add the confirmable option in the model, you'll need to uncomment the Confirmable section in the migration.
|
||||
|
||||
Then run `rails db:migrate`
|
||||
|
||||
@@ -256,7 +270,7 @@ member_session
|
||||
The Devise method in your models also accepts some options to configure its modules. For example, you can choose the cost of the hashing algorithm with:
|
||||
|
||||
```ruby
|
||||
devise :database_authenticatable, :registerable, :confirmable, :recoverable, stretches: 12
|
||||
devise :database_authenticatable, :registerable, :confirmable, :recoverable, stretches: 13
|
||||
```
|
||||
|
||||
Besides `:stretches`, you can define `:pepper`, `:encryptor`, `:confirm_within`, `:remember_for`, `:timeout_in`, `:unlock_in` among other options. For more details, see the initializer file that was created when you invoked the "devise:install" generator described above. This file is usually located at `/config/initializers/devise.rb`.
|
||||
@@ -404,6 +418,7 @@ If the customization at the views level is not enough, you can customize each co
|
||||
...
|
||||
end
|
||||
```
|
||||
(Use the -c flag to specify a controller, for example: `rails generate devise:controllers users -c=sessions`)
|
||||
|
||||
2. Tell the router to use this controller:
|
||||
|
||||
@@ -519,6 +534,9 @@ cases/specs.
|
||||
|
||||
Controller tests require that you include `Devise::Test::ControllerHelpers` on
|
||||
your test case or its parent `ActionController::TestCase` superclass.
|
||||
For Rails 5, include `Devise::Test::IntegrationHelpers` instead, since the superclass
|
||||
for controller tests has been changed to ActionDispatch::IntegrationTest
|
||||
(for more details, see the [Integration tests](#integration-tests) section).
|
||||
|
||||
```ruby
|
||||
class PostsControllerTest < ActionController::TestCase
|
||||
@@ -602,7 +620,7 @@ are executed in your tests.
|
||||
|
||||
You can read more about testing your Rails 3 - Rails 4 controllers with RSpec in the wiki:
|
||||
|
||||
* https://github.com/plataformatec/devise/wiki/How-To:-Test-controllers-with-Rails-3-and-4-%28and-RSpec%29
|
||||
* https://github.com/plataformatec/devise/wiki/How-To:-Test-controllers-with-Rails-(and-RSpec)
|
||||
|
||||
### OmniAuth
|
||||
|
||||
@@ -677,6 +695,17 @@ config.log_level = :warn
|
||||
|
||||
Devise supports ActiveRecord (default) and Mongoid. To select another ORM, simply require it in the initializer file.
|
||||
|
||||
### Rails API Mode
|
||||
|
||||
Rails 5+ has a built-in [API Mode](https://edgeguides.rubyonrails.org/api_app.html) which optimizes Rails for use as an API (only). One of the side effects is that it changes the order of the middleware stack, and this can cause problems for `Devise::Test::IntegrationHelpers`. This problem usually surfaces as an ```undefined method `[]=' for nil:NilClass``` error when using integration test helpers, such as `#sign_in`. The solution is simply to reorder the middlewares by adding the following to test.rb:
|
||||
|
||||
```ruby
|
||||
Rails.application.config.middleware.insert_before Warden::Manager, ActionDispatch::Cookies
|
||||
Rails.application.config.middleware.insert_before Warden::Manager, ActionDispatch::Session::CookieStore
|
||||
```
|
||||
|
||||
For a deeper understanding of this, review [this issue](https://github.com/plataformatec/devise/issues/4696).
|
||||
|
||||
## Additional information
|
||||
|
||||
### Heroku
|
||||
@@ -703,6 +732,6 @@ https://github.com/plataformatec/devise/graphs/contributors
|
||||
|
||||
## License
|
||||
|
||||
MIT License. Copyright 2009-2018 Plataformatec. http://plataformatec.com.br
|
||||
MIT License. Copyright 2009-2019 Plataformatec. http://plataformatec.com.br
|
||||
|
||||
You are not granted rights or licenses to the trademarks of Plataformatec, including without limitation the Devise name or logo.
|
||||
|
||||
@@ -39,6 +39,7 @@ class Devise::PasswordsController < DeviseController
|
||||
if Devise.sign_in_after_reset_password
|
||||
flash_message = resource.active_for_authentication? ? :updated : :updated_not_active
|
||||
set_flash_message!(:notice, flash_message)
|
||||
resource.after_database_authentication
|
||||
sign_in(resource_name, resource)
|
||||
else
|
||||
set_flash_message!(:notice, :updated_not_active)
|
||||
@@ -46,7 +47,12 @@ class Devise::PasswordsController < DeviseController
|
||||
respond_with resource, location: after_resetting_password_path_for(resource)
|
||||
else
|
||||
set_minimum_password_length
|
||||
respond_with resource
|
||||
|
||||
if expired_token_error?(resource)
|
||||
redirect_to new_password_path(resource_name), alert: t('devise.passwords.expired_token')
|
||||
else
|
||||
respond_with resource
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -79,4 +85,9 @@ class Devise::PasswordsController < DeviseController
|
||||
def translation_scope
|
||||
'devise.passwords'
|
||||
end
|
||||
|
||||
private
|
||||
def expired_token_error?(resource)
|
||||
resource.errors.details[:reset_password_token].any? { |error| error[:error] == :expired }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -50,12 +50,9 @@ class Devise::RegistrationsController < DeviseController
|
||||
resource_updated = update_resource(resource, account_update_params)
|
||||
yield resource if block_given?
|
||||
if resource_updated
|
||||
if is_flashing_format?
|
||||
flash_key = update_needs_confirmation?(resource, prev_unconfirmed_email) ?
|
||||
:update_needs_confirmation : :updated
|
||||
set_flash_message :notice, flash_key
|
||||
end
|
||||
bypass_sign_in resource, scope: resource_name
|
||||
set_flash_message_for_update(resource, prev_unconfirmed_email)
|
||||
bypass_sign_in resource, scope: resource_name if sign_in_after_change_password?
|
||||
|
||||
respond_with resource, location: after_update_path_for(resource)
|
||||
else
|
||||
clean_up_passwords resource
|
||||
@@ -112,7 +109,7 @@ class Devise::RegistrationsController < DeviseController
|
||||
# The path used after sign up. You need to overwrite this method
|
||||
# in your own RegistrationsController.
|
||||
def after_sign_up_path_for(resource)
|
||||
after_sign_in_path_for(resource)
|
||||
after_sign_in_path_for(resource) if is_navigational_format?
|
||||
end
|
||||
|
||||
# The path used after sign up for inactive accounts. You need to overwrite
|
||||
@@ -127,7 +124,7 @@ class Devise::RegistrationsController < DeviseController
|
||||
# The default url to be used after updating a resource. You need to overwrite
|
||||
# this method in your own RegistrationsController.
|
||||
def after_update_path_for(resource)
|
||||
signed_in_root_path(resource)
|
||||
sign_in_after_change_password? ? signed_in_root_path(resource) : new_session_path(resource_name)
|
||||
end
|
||||
|
||||
# Authenticates the current scope and gets the current resource from the session.
|
||||
@@ -147,4 +144,25 @@ class Devise::RegistrationsController < DeviseController
|
||||
def translation_scope
|
||||
'devise.registrations'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_flash_message_for_update(resource, prev_unconfirmed_email)
|
||||
return unless is_flashing_format?
|
||||
|
||||
flash_key = if update_needs_confirmation?(resource, prev_unconfirmed_email)
|
||||
:update_needs_confirmation
|
||||
elsif sign_in_after_change_password?
|
||||
:updated
|
||||
else
|
||||
:updated_but_not_signed_in
|
||||
end
|
||||
set_flash_message :notice, flash_key
|
||||
end
|
||||
|
||||
def sign_in_after_change_password?
|
||||
return true if account_update_params[:password].blank?
|
||||
|
||||
Devise.sign_in_after_change_password
|
||||
end
|
||||
end
|
||||
|
||||
@@ -28,7 +28,7 @@ class Devise::SessionsController < DeviseController
|
||||
signed_out = (Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name))
|
||||
set_flash_message! :notice, :signed_out if signed_out
|
||||
yield if block_given?
|
||||
respond_to_on_destroy
|
||||
respond_to_on_destroy(status: :no_content)
|
||||
end
|
||||
|
||||
protected
|
||||
@@ -62,7 +62,7 @@ class Devise::SessionsController < DeviseController
|
||||
if all_signed_out?
|
||||
set_flash_message! :notice, :already_signed_out
|
||||
|
||||
respond_to_on_destroy
|
||||
respond_to_on_destroy(status: :unauthorized)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -72,11 +72,11 @@ class Devise::SessionsController < DeviseController
|
||||
users.all?(&:blank?)
|
||||
end
|
||||
|
||||
def respond_to_on_destroy
|
||||
def respond_to_on_destroy(status:)
|
||||
# We actually need to hardcode this as Rails default responder doesn't
|
||||
# support returning empty response on GET request
|
||||
respond_to do |format|
|
||||
format.all { head :no_content }
|
||||
format.all { head status }
|
||||
format.any(*navigational_formats) { redirect_to after_sign_out_path_for(resource_name) }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -22,7 +22,7 @@ class DeviseController < Devise.parent_controller.constantize
|
||||
# Action Controller tests that forces _prefixes to be
|
||||
# loaded before even having a request object.
|
||||
#
|
||||
# This method should be public as it is is in ActionPack
|
||||
# This method should be public as it is in ActionPack
|
||||
# itself. Changing its visibility may break other gems.
|
||||
def _prefixes #:nodoc:
|
||||
@_prefixes ||= if self.class.scoped_views? && request && devise_mapping
|
||||
|
||||
@@ -1,27 +1,18 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module DeviseHelper
|
||||
# A simple way to show error messages for the current devise resource. If you need
|
||||
# to customize this method, you can either overwrite it in your application helpers or
|
||||
# copy the views to your application.
|
||||
#
|
||||
# This method is intended to stay simple and it is unlikely that we are going to change
|
||||
# it to add more behavior or options.
|
||||
# Retain this method for backwards compatibility, deprecated in favour of modifying the
|
||||
# devise/shared/error_messages partial
|
||||
def devise_error_messages!
|
||||
ActiveSupport::Deprecation.warn <<-DEPRECATION.strip_heredoc
|
||||
[Devise] `DeviseHelper.devise_error_messages!`
|
||||
is deprecated and it will be removed in the next major version.
|
||||
To customize the errors styles please run `rails g devise:views` and modify the
|
||||
`devise/shared/error_messages` partial.
|
||||
DEPRECATION
|
||||
|
||||
return "" if resource.errors.empty?
|
||||
|
||||
messages = resource.errors.full_messages.map { |msg| content_tag(:li, msg) }.join
|
||||
sentence = I18n.t("errors.messages.not_saved",
|
||||
count: resource.errors.count,
|
||||
resource: resource.class.model_name.human.downcase)
|
||||
|
||||
html = <<-HTML
|
||||
<div id="error_explanation">
|
||||
<h2>#{sentence}</h2>
|
||||
<ul>#{messages}</ul>
|
||||
</div>
|
||||
HTML
|
||||
|
||||
html.html_safe
|
||||
render "devise/shared/error_messages", resource: resource
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<h2>Resend confirmation instructions</h2>
|
||||
|
||||
<%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %>
|
||||
<%= devise_error_messages! %>
|
||||
<%= render "devise/shared/error_messages", resource: resource %>
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :email %><br />
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<h2>Change your password</h2>
|
||||
|
||||
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %>
|
||||
<%= devise_error_messages! %>
|
||||
<%= render "devise/shared/error_messages", resource: resource %>
|
||||
<%= f.hidden_field :reset_password_token %>
|
||||
|
||||
<div class="field">
|
||||
@@ -9,12 +9,12 @@
|
||||
<% if @minimum_password_length %>
|
||||
<em>(<%= @minimum_password_length %> characters minimum)</em><br />
|
||||
<% end %>
|
||||
<%= f.password_field :password, autofocus: true, autocomplete: "off" %>
|
||||
<%= f.password_field :password, autofocus: true, autocomplete: "new-password" %>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :password_confirmation, "Confirm new password" %><br />
|
||||
<%= f.password_field :password_confirmation, autocomplete: "off" %>
|
||||
<%= f.password_field :password_confirmation, autocomplete: "new-password" %>
|
||||
</div>
|
||||
|
||||
<div class="actions">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<h2>Forgot your password?</h2>
|
||||
|
||||
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %>
|
||||
<%= devise_error_messages! %>
|
||||
<%= render "devise/shared/error_messages", resource: resource %>
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :email %><br />
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<h2>Edit <%= resource_name.to_s.humanize %></h2>
|
||||
|
||||
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
|
||||
<%= devise_error_messages! %>
|
||||
<%= render "devise/shared/error_messages", resource: resource %>
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :email %><br />
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
|
||||
<%= f.password_field :password, autocomplete: "off" %>
|
||||
<%= f.password_field :password, autocomplete: "new-password" %>
|
||||
<% if @minimum_password_length %>
|
||||
<br />
|
||||
<em><%= @minimum_password_length %> characters minimum</em>
|
||||
@@ -23,12 +23,12 @@
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :password_confirmation %><br />
|
||||
<%= f.password_field :password_confirmation, autocomplete: "off" %>
|
||||
<%= f.password_field :password_confirmation, autocomplete: "new-password" %>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
|
||||
<%= f.password_field :current_password, autocomplete: "off" %>
|
||||
<%= f.password_field :current_password, autocomplete: "current-password" %>
|
||||
</div>
|
||||
|
||||
<div class="actions">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<h2>Sign up</h2>
|
||||
|
||||
<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
|
||||
<%= devise_error_messages! %>
|
||||
<%= render "devise/shared/error_messages", resource: resource %>
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :email %><br />
|
||||
@@ -13,12 +13,12 @@
|
||||
<% if @minimum_password_length %>
|
||||
<em>(<%= @minimum_password_length %> characters minimum)</em>
|
||||
<% end %><br />
|
||||
<%= f.password_field :password, autocomplete: "off" %>
|
||||
<%= f.password_field :password, autocomplete: "new-password" %>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :password_confirmation %><br />
|
||||
<%= f.password_field :password_confirmation, autocomplete: "off" %>
|
||||
<%= f.password_field :password_confirmation, autocomplete: "new-password" %>
|
||||
</div>
|
||||
|
||||
<div class="actions">
|
||||
|
||||
@@ -8,15 +8,15 @@
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :password %><br />
|
||||
<%= f.password_field :password, autocomplete: "off" %>
|
||||
<%= f.password_field :password, autocomplete: "current-password" %>
|
||||
</div>
|
||||
|
||||
<% if devise_mapping.rememberable? -%>
|
||||
<% if devise_mapping.rememberable? %>
|
||||
<div class="field">
|
||||
<%= f.check_box :remember_me %>
|
||||
<%= f.label :remember_me %>
|
||||
</div>
|
||||
<% end -%>
|
||||
<% end %>
|
||||
|
||||
<div class="actions">
|
||||
<%= f.submit "Log in" %>
|
||||
|
||||
15
app/views/devise/shared/_error_messages.html.erb
Normal file
15
app/views/devise/shared/_error_messages.html.erb
Normal file
@@ -0,0 +1,15 @@
|
||||
<% if resource.errors.any? %>
|
||||
<div id="error_explanation">
|
||||
<h2>
|
||||
<%= I18n.t("errors.messages.not_saved",
|
||||
count: resource.errors.count,
|
||||
resource: resource.class.model_name.human.downcase)
|
||||
%>
|
||||
</h2>
|
||||
<ul>
|
||||
<% resource.errors.full_messages.each do |message| %>
|
||||
<li><%= message %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -1,25 +1,25 @@
|
||||
<%- if controller_name != 'sessions' %>
|
||||
<%= link_to "Log in", new_session_path(resource_name) %><br />
|
||||
<% end -%>
|
||||
<% end %>
|
||||
|
||||
<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
|
||||
<%= link_to "Sign up", new_registration_path(resource_name) %><br />
|
||||
<% end -%>
|
||||
<% end %>
|
||||
|
||||
<%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %>
|
||||
<%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
|
||||
<% end -%>
|
||||
<% end %>
|
||||
|
||||
<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
|
||||
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
|
||||
<% end -%>
|
||||
<% end %>
|
||||
|
||||
<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
|
||||
<%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br />
|
||||
<% end -%>
|
||||
<% end %>
|
||||
|
||||
<%- if devise_mapping.omniauthable? %>
|
||||
<%- resource_class.omniauth_providers.each do |provider| %>
|
||||
<%= link_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider) %><br />
|
||||
<% end -%>
|
||||
<% end -%>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<h2>Resend unlock instructions</h2>
|
||||
|
||||
<%= form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| %>
|
||||
<%= devise_error_messages! %>
|
||||
<%= render "devise/shared/error_messages", resource: resource %>
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :email %><br />
|
||||
|
||||
16
bin/test
16
bin/test
@@ -1,13 +1,17 @@
|
||||
#!/usr/bin/env ruby
|
||||
$: << File.expand_path(File.expand_path('../../test', __FILE__))
|
||||
|
||||
require 'bundler/setup'
|
||||
# Remove this begin/rescue once Rails 4 support is removed.
|
||||
begin
|
||||
require 'rails/test_unit/minitest_plugin'
|
||||
require 'bundler/setup'
|
||||
require 'rails/test_unit/runner'
|
||||
require 'rails/test_unit/reporter'
|
||||
require 'rails/test_unit/line_filtering'
|
||||
|
||||
Rails::TestUnitReporter.executable = 'bin/test'
|
||||
|
||||
Rails::TestUnit::Runner.parse_options(ARGV)
|
||||
Rails::TestUnit::Runner.run(ARGV)
|
||||
rescue LoadError
|
||||
exec 'rake'
|
||||
end
|
||||
|
||||
Rails::TestUnitReporter.executable = 'bin/test'
|
||||
|
||||
exit Minitest.run(ARGV)
|
||||
|
||||
@@ -10,7 +10,11 @@ en:
|
||||
already_authenticated: "You are already signed in."
|
||||
inactive: "Your account is not activated yet."
|
||||
invalid: "Invalid %{authentication_keys} or password."
|
||||
locked: "Your account is locked."
|
||||
locked:
|
||||
none: "Your account is locked."
|
||||
email: "Your account is locked. An email has been sent with instructions on how to unlock your account."
|
||||
time: "Your account is locked. Your account will become available after a certain amount of time."
|
||||
both: "Your account is locked. An email has been sent with instructions on how to unlock your account, or wait a certain amount of time and try again."
|
||||
last_attempt: "You have one more attempt before your account is locked."
|
||||
not_found_in_database: "Invalid %{authentication_keys} or password."
|
||||
timeout: "Your session expired. Please sign in again to continue."
|
||||
@@ -36,14 +40,16 @@ en:
|
||||
send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."
|
||||
updated: "Your password has been changed successfully. You are now signed in."
|
||||
updated_not_active: "Your password has been changed successfully."
|
||||
expired_token: "The password recovery link expired. Please request a new one."
|
||||
registrations:
|
||||
destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon."
|
||||
signed_up: "Welcome! You have signed up successfully."
|
||||
signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated."
|
||||
signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked."
|
||||
signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account."
|
||||
update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirm link to confirm your new email address."
|
||||
update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirmation link to confirm your new email address."
|
||||
updated: "Your account has been updated successfully."
|
||||
updated_but_not_signed_in: "Your account has been updated successfully, but since your password was changed, you need to sign in again"
|
||||
sessions:
|
||||
signed_in: "Signed in successfully."
|
||||
signed_out: "Signed out successfully."
|
||||
|
||||
@@ -15,14 +15,13 @@ Gem::Specification.new do |s|
|
||||
s.description = "Flexible authentication solution for Rails with Warden"
|
||||
s.authors = ['José Valim', 'Carlos Antônio']
|
||||
|
||||
s.files = `git ls-files`.split("\n")
|
||||
s.test_files = `git ls-files -- test/*`.split("\n")
|
||||
s.files = Dir["{app,config,lib}/**/*", "CHANGELOG.md", "MIT-LICENSE", "README.md"]
|
||||
s.require_paths = ["lib"]
|
||||
s.required_ruby_version = '>= 2.1.0'
|
||||
s.required_ruby_version = '>= 2.3.0'
|
||||
|
||||
s.add_dependency("warden", "~> 1.2.3")
|
||||
s.add_dependency("orm_adapter", "~> 0.1")
|
||||
s.add_dependency("bcrypt", "~> 3.0")
|
||||
s.add_dependency("railties", ">= 4.1.0", "< 6.0")
|
||||
s.add_dependency("railties", ">= 5.0")
|
||||
s.add_dependency("responders")
|
||||
end
|
||||
|
||||
@@ -8,10 +8,13 @@ gem "rails", github: "rails/rails", branch: "4-1-stable"
|
||||
gem "omniauth"
|
||||
gem "omniauth-oauth2"
|
||||
gem "rdoc", "~> 5.1"
|
||||
# Force this version because it's breaking on CI since a higher nokogiri version requires Ruby 2.3+.
|
||||
gem "nokogiri", "1.9.1"
|
||||
|
||||
group :test do
|
||||
gem "omniauth-facebook"
|
||||
gem "omniauth-openid"
|
||||
gem "timecop"
|
||||
gem "webrat", "0.7.3", require: false
|
||||
gem "mocha", "~> 1.1", require: false
|
||||
gem 'test_after_commit', require: false
|
||||
@@ -24,7 +27,7 @@ platforms :jruby do
|
||||
end
|
||||
|
||||
platforms :ruby do
|
||||
gem "sqlite3"
|
||||
gem "sqlite3", "~> 1.3.6"
|
||||
end
|
||||
|
||||
group :mongoid do
|
||||
|
||||
@@ -21,10 +21,10 @@ GIT
|
||||
PATH
|
||||
remote: ..
|
||||
specs:
|
||||
devise (4.4.3)
|
||||
devise (4.7.1)
|
||||
bcrypt (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
railties (>= 4.1.0, < 6.0)
|
||||
railties (>= 4.1.0)
|
||||
responders
|
||||
warden (~> 1.2.3)
|
||||
|
||||
@@ -54,7 +54,7 @@ GEM
|
||||
thread_safe (~> 0.1)
|
||||
tzinfo (~> 1.1)
|
||||
arel (5.0.1.20140414130214)
|
||||
bcrypt (3.1.11)
|
||||
bcrypt (3.1.13)
|
||||
bson (3.2.6)
|
||||
builder (3.2.3)
|
||||
concurrent-ruby (1.0.5)
|
||||
@@ -72,7 +72,7 @@ GEM
|
||||
mime-types (3.1)
|
||||
mime-types-data (~> 3.2015)
|
||||
mime-types-data (3.2016.0521)
|
||||
mini_portile2 (2.1.0)
|
||||
mini_portile2 (2.4.0)
|
||||
minitest (5.10.1)
|
||||
mocha (1.2.1)
|
||||
metaclass (~> 0.0.1)
|
||||
@@ -88,8 +88,8 @@ GEM
|
||||
multi_json (1.12.1)
|
||||
multi_xml (0.6.0)
|
||||
multipart-post (2.0.0)
|
||||
nokogiri (1.7.0.1)
|
||||
mini_portile2 (~> 2.1.0)
|
||||
nokogiri (1.9.1)
|
||||
mini_portile2 (~> 2.4.0)
|
||||
oauth2 (1.3.1)
|
||||
faraday (>= 0.8, < 0.12)
|
||||
jwt (~> 1.0)
|
||||
@@ -138,6 +138,7 @@ GEM
|
||||
activerecord (>= 3.2)
|
||||
thor (0.19.4)
|
||||
thread_safe (0.3.6)
|
||||
timecop (0.8.1)
|
||||
tzinfo (1.2.2)
|
||||
thread_safe (~> 0.1)
|
||||
warden (1.2.7)
|
||||
@@ -157,15 +158,17 @@ DEPENDENCIES
|
||||
jruby-openssl
|
||||
mocha (~> 1.1)
|
||||
mongoid (~> 4.0)
|
||||
nokogiri (= 1.9.1)
|
||||
omniauth
|
||||
omniauth-facebook
|
||||
omniauth-oauth2
|
||||
omniauth-openid
|
||||
rails!
|
||||
rdoc (~> 5.1)
|
||||
sqlite3
|
||||
sqlite3 (~> 1.3.6)
|
||||
test_after_commit
|
||||
timecop
|
||||
webrat (= 0.7.3)
|
||||
|
||||
BUNDLED WITH
|
||||
1.16.1
|
||||
1.17.3
|
||||
|
||||
@@ -8,10 +8,12 @@ gem "rails", github: "rails/rails", branch: "4-2-stable"
|
||||
gem "omniauth"
|
||||
gem "omniauth-oauth2"
|
||||
gem "rdoc", "~> 5.1"
|
||||
gem "nokogiri", "1.9.1"
|
||||
|
||||
group :test do
|
||||
gem "omniauth-facebook"
|
||||
gem "omniauth-openid"
|
||||
gem "timecop"
|
||||
gem "webrat", "0.7.3", require: false
|
||||
gem "mocha", "~> 1.1", require: false
|
||||
gem 'test_after_commit', require: false
|
||||
@@ -24,7 +26,7 @@ platforms :jruby do
|
||||
end
|
||||
|
||||
platforms :ruby do
|
||||
gem "sqlite3"
|
||||
gem "sqlite3", "~> 1.3.6"
|
||||
end
|
||||
|
||||
group :mongoid do
|
||||
|
||||
@@ -57,10 +57,10 @@ GIT
|
||||
PATH
|
||||
remote: ..
|
||||
specs:
|
||||
devise (4.4.3)
|
||||
devise (4.7.1)
|
||||
bcrypt (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
railties (>= 4.1.0, < 6.0)
|
||||
railties (>= 4.1.0)
|
||||
responders
|
||||
warden (~> 1.2.3)
|
||||
|
||||
@@ -68,7 +68,7 @@ GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
arel (6.0.4)
|
||||
bcrypt (3.1.11)
|
||||
bcrypt (3.1.13)
|
||||
bson (3.2.6)
|
||||
builder (3.2.3)
|
||||
concurrent-ruby (1.0.5)
|
||||
@@ -89,7 +89,7 @@ GEM
|
||||
mime-types (3.1)
|
||||
mime-types-data (~> 3.2015)
|
||||
mime-types-data (3.2016.0521)
|
||||
mini_portile2 (2.1.0)
|
||||
mini_portile2 (2.4.0)
|
||||
minitest (5.10.1)
|
||||
mocha (1.2.1)
|
||||
metaclass (~> 0.0.1)
|
||||
@@ -105,8 +105,8 @@ GEM
|
||||
multi_json (1.12.1)
|
||||
multi_xml (0.6.0)
|
||||
multipart-post (2.0.0)
|
||||
nokogiri (1.7.0.1)
|
||||
mini_portile2 (~> 2.1.0)
|
||||
nokogiri (1.9.1)
|
||||
mini_portile2 (~> 2.4.0)
|
||||
oauth2 (1.3.1)
|
||||
faraday (>= 0.8, < 0.12)
|
||||
jwt (~> 1.0)
|
||||
@@ -143,9 +143,9 @@ GEM
|
||||
loofah (~> 2.0)
|
||||
rake (12.0.0)
|
||||
rdoc (5.1.0)
|
||||
responders (2.4.0)
|
||||
actionpack (>= 4.2.0, < 5.3)
|
||||
railties (>= 4.2.0, < 5.3)
|
||||
responders (2.4.1)
|
||||
actionpack (>= 4.2.0, < 6.0)
|
||||
railties (>= 4.2.0, < 6.0)
|
||||
ruby-openid (2.7.0)
|
||||
sprockets (3.7.1)
|
||||
concurrent-ruby (~> 1.0)
|
||||
@@ -159,6 +159,7 @@ GEM
|
||||
activerecord (>= 3.2)
|
||||
thor (0.19.4)
|
||||
thread_safe (0.3.6)
|
||||
timecop (0.8.1)
|
||||
tzinfo (1.2.2)
|
||||
thread_safe (~> 0.1)
|
||||
warden (1.2.7)
|
||||
@@ -178,15 +179,17 @@ DEPENDENCIES
|
||||
jruby-openssl
|
||||
mocha (~> 1.1)
|
||||
mongoid (~> 4.0)
|
||||
nokogiri (= 1.9.1)
|
||||
omniauth
|
||||
omniauth-facebook
|
||||
omniauth-oauth2
|
||||
omniauth-openid
|
||||
rails!
|
||||
rdoc (~> 5.1)
|
||||
sqlite3
|
||||
sqlite3 (~> 1.3.6)
|
||||
test_after_commit
|
||||
timecop
|
||||
webrat (= 0.7.3)
|
||||
|
||||
BUNDLED WITH
|
||||
1.16.1
|
||||
1.17.3
|
||||
|
||||
@@ -18,13 +18,13 @@ gem "responders", "~> 2.1"
|
||||
group :test do
|
||||
gem "omniauth-facebook"
|
||||
gem "omniauth-openid"
|
||||
gem "timecop"
|
||||
gem "webrat", "0.7.3", require: false
|
||||
gem "mocha", "~> 1.1", require: false
|
||||
gem 'test_after_commit', require: false
|
||||
end
|
||||
|
||||
platforms :ruby do
|
||||
gem "sqlite3"
|
||||
gem "sqlite3", "~> 1.3.6"
|
||||
end
|
||||
|
||||
# TODO:
|
||||
|
||||
@@ -10,10 +10,10 @@ GIT
|
||||
PATH
|
||||
remote: ..
|
||||
specs:
|
||||
devise (4.4.3)
|
||||
devise (4.7.1)
|
||||
bcrypt (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
railties (>= 4.1.0, < 6.0)
|
||||
railties (>= 5.0)
|
||||
responders
|
||||
warden (~> 1.2.3)
|
||||
|
||||
@@ -58,7 +58,7 @@ GEM
|
||||
minitest (~> 5.1)
|
||||
tzinfo (~> 1.1)
|
||||
arel (7.1.4)
|
||||
bcrypt (3.1.11)
|
||||
bcrypt (3.1.13)
|
||||
builder (3.2.3)
|
||||
concurrent-ruby (1.0.5)
|
||||
erubis (2.7.0)
|
||||
@@ -153,10 +153,9 @@ GEM
|
||||
activesupport (>= 4.0)
|
||||
sprockets (>= 3.0.0)
|
||||
sqlite3 (1.3.13)
|
||||
test_after_commit (1.1.0)
|
||||
activerecord (>= 3.2)
|
||||
thor (0.19.4)
|
||||
thread_safe (0.3.6)
|
||||
timecop (0.8.1)
|
||||
tzinfo (1.2.3)
|
||||
thread_safe (~> 0.1)
|
||||
warden (1.2.7)
|
||||
@@ -184,9 +183,10 @@ DEPENDENCIES
|
||||
rails-controller-testing
|
||||
rdoc
|
||||
responders (~> 2.1)
|
||||
sqlite3
|
||||
sqlite3 (~> 1.3.6)
|
||||
test_after_commit
|
||||
timecop
|
||||
webrat (= 0.7.3)
|
||||
|
||||
BUNDLED WITH
|
||||
1.16.1
|
||||
1.17.3
|
||||
|
||||
@@ -2,7 +2,7 @@ source "https://rubygems.org"
|
||||
|
||||
gemspec path: ".."
|
||||
|
||||
gem "rails", '~> 5.2.0.rc1'
|
||||
gem "rails", '~> 5.2'
|
||||
gem "omniauth"
|
||||
gem "omniauth-oauth2"
|
||||
gem "rdoc"
|
||||
@@ -16,11 +16,11 @@ gem "responders", "~> 2.1"
|
||||
group :test do
|
||||
gem "omniauth-facebook"
|
||||
gem "omniauth-openid"
|
||||
gem "timecop"
|
||||
gem "webrat", "0.7.3", require: false
|
||||
gem "mocha", "~> 1.1", require: false
|
||||
gem 'test_after_commit', require: false
|
||||
end
|
||||
|
||||
platforms :ruby do
|
||||
gem "sqlite3"
|
||||
gem "sqlite3", "~> 1.3.6"
|
||||
end
|
||||
@@ -1,6 +1,6 @@
|
||||
GIT
|
||||
remote: git://github.com/rails/activemodel-serializers-xml.git
|
||||
revision: 356edf4dfc38fb1fbfee90c87856e4fe5b73c5e1
|
||||
revision: f744aeca2747ed3134e492249c4ee39b548efdf6
|
||||
specs:
|
||||
activemodel-serializers-xml (1.0.2)
|
||||
activemodel (> 5.x)
|
||||
@@ -10,91 +10,91 @@ GIT
|
||||
PATH
|
||||
remote: ..
|
||||
specs:
|
||||
devise (4.4.3)
|
||||
devise (4.7.1)
|
||||
bcrypt (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
railties (>= 4.1.0, < 6.0)
|
||||
railties (>= 5.0)
|
||||
responders
|
||||
warden (~> 1.2.3)
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
actioncable (5.2.0.rc1)
|
||||
actionpack (= 5.2.0.rc1)
|
||||
actioncable (5.2.1)
|
||||
actionpack (= 5.2.1)
|
||||
nio4r (~> 2.0)
|
||||
websocket-driver (>= 0.6.1)
|
||||
actionmailer (5.2.0.rc1)
|
||||
actionpack (= 5.2.0.rc1)
|
||||
actionview (= 5.2.0.rc1)
|
||||
activejob (= 5.2.0.rc1)
|
||||
actionmailer (5.2.1)
|
||||
actionpack (= 5.2.1)
|
||||
actionview (= 5.2.1)
|
||||
activejob (= 5.2.1)
|
||||
mail (~> 2.5, >= 2.5.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
actionpack (5.2.0.rc1)
|
||||
actionview (= 5.2.0.rc1)
|
||||
activesupport (= 5.2.0.rc1)
|
||||
actionpack (5.2.1)
|
||||
actionview (= 5.2.1)
|
||||
activesupport (= 5.2.1)
|
||||
rack (~> 2.0)
|
||||
rack-test (>= 0.6.3)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||
actionview (5.2.0.rc1)
|
||||
activesupport (= 5.2.0.rc1)
|
||||
actionview (5.2.1)
|
||||
activesupport (= 5.2.1)
|
||||
builder (~> 3.1)
|
||||
erubi (~> 1.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
||||
activejob (5.2.0.rc1)
|
||||
activesupport (= 5.2.0.rc1)
|
||||
activejob (5.2.1)
|
||||
activesupport (= 5.2.1)
|
||||
globalid (>= 0.3.6)
|
||||
activemodel (5.2.0.rc1)
|
||||
activesupport (= 5.2.0.rc1)
|
||||
activerecord (5.2.0.rc1)
|
||||
activemodel (= 5.2.0.rc1)
|
||||
activesupport (= 5.2.0.rc1)
|
||||
activemodel (5.2.1)
|
||||
activesupport (= 5.2.1)
|
||||
activerecord (5.2.1)
|
||||
activemodel (= 5.2.1)
|
||||
activesupport (= 5.2.1)
|
||||
arel (>= 9.0)
|
||||
activestorage (5.2.0.rc1)
|
||||
actionpack (= 5.2.0.rc1)
|
||||
activerecord (= 5.2.0.rc1)
|
||||
activestorage (5.2.1)
|
||||
actionpack (= 5.2.1)
|
||||
activerecord (= 5.2.1)
|
||||
marcel (~> 0.3.1)
|
||||
activesupport (5.2.0.rc1)
|
||||
activesupport (5.2.1)
|
||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||
i18n (~> 0.7)
|
||||
i18n (>= 0.7, < 2)
|
||||
minitest (~> 5.1)
|
||||
tzinfo (~> 1.1)
|
||||
arel (9.0.0)
|
||||
bcrypt (3.1.11)
|
||||
bcrypt (3.1.13)
|
||||
builder (3.2.3)
|
||||
concurrent-ruby (1.0.5)
|
||||
crass (1.0.3)
|
||||
erubi (1.7.0)
|
||||
crass (1.0.4)
|
||||
erubi (1.7.1)
|
||||
faraday (0.12.2)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
globalid (0.4.1)
|
||||
activesupport (>= 4.2.0)
|
||||
hashie (3.5.7)
|
||||
i18n (0.9.3)
|
||||
i18n (1.1.0)
|
||||
concurrent-ruby (~> 1.0)
|
||||
jwt (1.5.6)
|
||||
loofah (2.1.1)
|
||||
loofah (2.2.2)
|
||||
crass (~> 1.0.2)
|
||||
nokogiri (>= 1.5.9)
|
||||
mail (2.7.0)
|
||||
mini_mime (>= 0.1.1)
|
||||
marcel (0.3.1)
|
||||
marcel (0.3.3)
|
||||
mimemagic (~> 0.3.2)
|
||||
metaclass (0.0.4)
|
||||
method_source (0.9.0)
|
||||
mimemagic (0.3.2)
|
||||
mini_mime (1.0.0)
|
||||
mini_mime (1.0.1)
|
||||
mini_portile2 (2.3.0)
|
||||
minitest (5.11.3)
|
||||
mocha (1.3.0)
|
||||
mocha (1.7.0)
|
||||
metaclass (~> 0.0.1)
|
||||
multi_json (1.13.1)
|
||||
multi_xml (0.6.0)
|
||||
multipart-post (2.0.0)
|
||||
nio4r (2.2.0)
|
||||
nokogiri (1.8.2)
|
||||
nio4r (2.3.1)
|
||||
nokogiri (1.8.5)
|
||||
mini_portile2 (~> 2.3.0)
|
||||
oauth2 (1.4.0)
|
||||
faraday (>= 0.8, < 0.13)
|
||||
@@ -105,7 +105,7 @@ GEM
|
||||
omniauth (1.8.1)
|
||||
hashie (>= 3.4.6, < 3.6.0)
|
||||
rack (>= 1.6.2, < 3)
|
||||
omniauth-facebook (4.0.0)
|
||||
omniauth-facebook (5.0.0)
|
||||
omniauth-oauth2 (~> 1.2)
|
||||
omniauth-oauth2 (1.5.0)
|
||||
oauth2 (~> 1.1)
|
||||
@@ -114,24 +114,24 @@ GEM
|
||||
omniauth (~> 1.0)
|
||||
rack-openid (~> 1.3.1)
|
||||
orm_adapter (0.5.0)
|
||||
rack (2.0.4)
|
||||
rack (2.0.5)
|
||||
rack-openid (1.3.1)
|
||||
rack (>= 1.1.0)
|
||||
ruby-openid (>= 2.1.8)
|
||||
rack-test (0.8.2)
|
||||
rack-test (1.1.0)
|
||||
rack (>= 1.0, < 3)
|
||||
rails (5.2.0.rc1)
|
||||
actioncable (= 5.2.0.rc1)
|
||||
actionmailer (= 5.2.0.rc1)
|
||||
actionpack (= 5.2.0.rc1)
|
||||
actionview (= 5.2.0.rc1)
|
||||
activejob (= 5.2.0.rc1)
|
||||
activemodel (= 5.2.0.rc1)
|
||||
activerecord (= 5.2.0.rc1)
|
||||
activestorage (= 5.2.0.rc1)
|
||||
activesupport (= 5.2.0.rc1)
|
||||
rails (5.2.1)
|
||||
actioncable (= 5.2.1)
|
||||
actionmailer (= 5.2.1)
|
||||
actionpack (= 5.2.1)
|
||||
actionview (= 5.2.1)
|
||||
activejob (= 5.2.1)
|
||||
activemodel (= 5.2.1)
|
||||
activerecord (= 5.2.1)
|
||||
activestorage (= 5.2.1)
|
||||
activesupport (= 5.2.1)
|
||||
bundler (>= 1.3.0)
|
||||
railties (= 5.2.0.rc1)
|
||||
railties (= 5.2.1)
|
||||
sprockets-rails (>= 2.0.0)
|
||||
rails-controller-testing (1.0.2)
|
||||
actionpack (~> 5.x, >= 5.0.1)
|
||||
@@ -140,21 +140,21 @@ GEM
|
||||
rails-dom-testing (2.0.3)
|
||||
activesupport (>= 4.2.0)
|
||||
nokogiri (>= 1.6)
|
||||
rails-html-sanitizer (1.0.3)
|
||||
loofah (~> 2.0)
|
||||
railties (5.2.0.rc1)
|
||||
actionpack (= 5.2.0.rc1)
|
||||
activesupport (= 5.2.0.rc1)
|
||||
rails-html-sanitizer (1.0.4)
|
||||
loofah (~> 2.2, >= 2.2.2)
|
||||
railties (5.2.1)
|
||||
actionpack (= 5.2.1)
|
||||
activesupport (= 5.2.1)
|
||||
method_source
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.18.1, < 2.0)
|
||||
rake (12.3.0)
|
||||
rdoc (6.0.1)
|
||||
thor (>= 0.19.0, < 2.0)
|
||||
rake (12.3.1)
|
||||
rdoc (6.0.4)
|
||||
responders (2.4.0)
|
||||
actionpack (>= 4.2.0, < 5.3)
|
||||
railties (>= 4.2.0, < 5.3)
|
||||
ruby-openid (2.7.0)
|
||||
sprockets (3.7.1)
|
||||
sprockets (3.7.2)
|
||||
concurrent-ruby (~> 1.0)
|
||||
rack (> 1, < 3)
|
||||
sprockets-rails (3.2.1)
|
||||
@@ -162,10 +162,9 @@ GEM
|
||||
activesupport (>= 4.0)
|
||||
sprockets (>= 3.0.0)
|
||||
sqlite3 (1.3.13)
|
||||
test_after_commit (1.1.0)
|
||||
activerecord (>= 3.2)
|
||||
thor (0.20.0)
|
||||
thread_safe (0.3.6)
|
||||
timecop (0.9.1)
|
||||
tzinfo (1.2.5)
|
||||
thread_safe (~> 0.1)
|
||||
warden (1.2.7)
|
||||
@@ -189,13 +188,14 @@ DEPENDENCIES
|
||||
omniauth-facebook
|
||||
omniauth-oauth2
|
||||
omniauth-openid
|
||||
rails (~> 5.2.0.rc1)
|
||||
rails (~> 5.2)
|
||||
rails-controller-testing
|
||||
rdoc
|
||||
responders (~> 2.1)
|
||||
sqlite3
|
||||
sqlite3 (~> 1.3.6)
|
||||
test_after_commit
|
||||
timecop
|
||||
webrat (= 0.7.3)
|
||||
|
||||
BUNDLED WITH
|
||||
1.16.1
|
||||
1.17.3
|
||||
27
gemfiles/Gemfile.rails-6.0-stable
Normal file
27
gemfiles/Gemfile.rails-6.0-stable
Normal file
@@ -0,0 +1,27 @@
|
||||
source "https://rubygems.org"
|
||||
|
||||
gemspec path: ".."
|
||||
|
||||
gem "rails", '~> 6.0.0'
|
||||
gem "omniauth"
|
||||
gem "omniauth-oauth2"
|
||||
gem "rdoc"
|
||||
|
||||
gem "activemodel-serializers-xml", github: "rails/activemodel-serializers-xml"
|
||||
|
||||
gem "rails-controller-testing"
|
||||
|
||||
gem "responders", "~> 3.0"
|
||||
|
||||
group :test do
|
||||
gem "omniauth-facebook"
|
||||
gem "omniauth-openid"
|
||||
gem "timecop"
|
||||
gem "webrat", "0.7.3", require: false
|
||||
gem "mocha", "~> 1.1", require: false
|
||||
gem 'test_after_commit', require: false
|
||||
end
|
||||
|
||||
platforms :ruby do
|
||||
gem "sqlite3", "~> 1.4"
|
||||
end
|
||||
219
gemfiles/Gemfile.rails-6.0-stable.lock
Normal file
219
gemfiles/Gemfile.rails-6.0-stable.lock
Normal file
@@ -0,0 +1,219 @@
|
||||
GIT
|
||||
remote: git://github.com/rails/activemodel-serializers-xml.git
|
||||
revision: 93689638c28525acc65afb638fce866826532641
|
||||
specs:
|
||||
activemodel-serializers-xml (1.0.2)
|
||||
activemodel (>= 5.0.0.a)
|
||||
activesupport (>= 5.0.0.a)
|
||||
builder (~> 3.1)
|
||||
|
||||
PATH
|
||||
remote: ..
|
||||
specs:
|
||||
devise (4.7.1)
|
||||
bcrypt (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
railties (>= 5.0)
|
||||
responders
|
||||
warden (~> 1.2.3)
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
actioncable (6.0.0)
|
||||
actionpack (= 6.0.0)
|
||||
nio4r (~> 2.0)
|
||||
websocket-driver (>= 0.6.1)
|
||||
actionmailbox (6.0.0)
|
||||
actionpack (= 6.0.0)
|
||||
activejob (= 6.0.0)
|
||||
activerecord (= 6.0.0)
|
||||
activestorage (= 6.0.0)
|
||||
activesupport (= 6.0.0)
|
||||
mail (>= 2.7.1)
|
||||
actionmailer (6.0.0)
|
||||
actionpack (= 6.0.0)
|
||||
actionview (= 6.0.0)
|
||||
activejob (= 6.0.0)
|
||||
mail (~> 2.5, >= 2.5.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
actionpack (6.0.0)
|
||||
actionview (= 6.0.0)
|
||||
activesupport (= 6.0.0)
|
||||
rack (~> 2.0)
|
||||
rack-test (>= 0.6.3)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
||||
actiontext (6.0.0)
|
||||
actionpack (= 6.0.0)
|
||||
activerecord (= 6.0.0)
|
||||
activestorage (= 6.0.0)
|
||||
activesupport (= 6.0.0)
|
||||
nokogiri (>= 1.8.5)
|
||||
actionview (6.0.0)
|
||||
activesupport (= 6.0.0)
|
||||
builder (~> 3.1)
|
||||
erubi (~> 1.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
||||
activejob (6.0.0)
|
||||
activesupport (= 6.0.0)
|
||||
globalid (>= 0.3.6)
|
||||
activemodel (6.0.0)
|
||||
activesupport (= 6.0.0)
|
||||
activerecord (6.0.0)
|
||||
activemodel (= 6.0.0)
|
||||
activesupport (= 6.0.0)
|
||||
activestorage (6.0.0)
|
||||
actionpack (= 6.0.0)
|
||||
activejob (= 6.0.0)
|
||||
activerecord (= 6.0.0)
|
||||
marcel (~> 0.3.1)
|
||||
activesupport (6.0.0)
|
||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||
i18n (>= 0.7, < 2)
|
||||
minitest (~> 5.1)
|
||||
tzinfo (~> 1.1)
|
||||
zeitwerk (~> 2.1, >= 2.1.8)
|
||||
bcrypt (3.1.13)
|
||||
builder (3.2.3)
|
||||
concurrent-ruby (1.1.5)
|
||||
crass (1.0.4)
|
||||
erubi (1.8.0)
|
||||
faraday (0.15.4)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
globalid (0.4.2)
|
||||
activesupport (>= 4.2.0)
|
||||
hashie (3.6.0)
|
||||
i18n (1.6.0)
|
||||
concurrent-ruby (~> 1.0)
|
||||
jwt (2.2.1)
|
||||
loofah (2.2.3)
|
||||
crass (~> 1.0.2)
|
||||
nokogiri (>= 1.5.9)
|
||||
mail (2.7.1)
|
||||
mini_mime (>= 0.1.1)
|
||||
marcel (0.3.3)
|
||||
mimemagic (~> 0.3.2)
|
||||
metaclass (0.0.4)
|
||||
method_source (0.9.2)
|
||||
mimemagic (0.3.3)
|
||||
mini_mime (1.0.2)
|
||||
mini_portile2 (2.4.0)
|
||||
minitest (5.11.3)
|
||||
mocha (1.9.0)
|
||||
metaclass (~> 0.0.1)
|
||||
multi_json (1.13.1)
|
||||
multi_xml (0.6.0)
|
||||
multipart-post (2.1.1)
|
||||
nio4r (2.4.0)
|
||||
nokogiri (1.10.4)
|
||||
mini_portile2 (~> 2.4.0)
|
||||
oauth2 (1.4.1)
|
||||
faraday (>= 0.8, < 0.16.0)
|
||||
jwt (>= 1.0, < 3.0)
|
||||
multi_json (~> 1.3)
|
||||
multi_xml (~> 0.5)
|
||||
rack (>= 1.2, < 3)
|
||||
omniauth (1.9.0)
|
||||
hashie (>= 3.4.6, < 3.7.0)
|
||||
rack (>= 1.6.2, < 3)
|
||||
omniauth-facebook (5.0.0)
|
||||
omniauth-oauth2 (~> 1.2)
|
||||
omniauth-oauth2 (1.6.0)
|
||||
oauth2 (~> 1.1)
|
||||
omniauth (~> 1.9)
|
||||
omniauth-openid (1.0.1)
|
||||
omniauth (~> 1.0)
|
||||
rack-openid (~> 1.3.1)
|
||||
orm_adapter (0.5.0)
|
||||
rack (2.0.7)
|
||||
rack-openid (1.3.1)
|
||||
rack (>= 1.1.0)
|
||||
ruby-openid (>= 2.1.8)
|
||||
rack-test (1.1.0)
|
||||
rack (>= 1.0, < 3)
|
||||
rails (6.0.0)
|
||||
actioncable (= 6.0.0)
|
||||
actionmailbox (= 6.0.0)
|
||||
actionmailer (= 6.0.0)
|
||||
actionpack (= 6.0.0)
|
||||
actiontext (= 6.0.0)
|
||||
actionview (= 6.0.0)
|
||||
activejob (= 6.0.0)
|
||||
activemodel (= 6.0.0)
|
||||
activerecord (= 6.0.0)
|
||||
activestorage (= 6.0.0)
|
||||
activesupport (= 6.0.0)
|
||||
bundler (>= 1.3.0)
|
||||
railties (= 6.0.0)
|
||||
sprockets-rails (>= 2.0.0)
|
||||
rails-controller-testing (1.0.4)
|
||||
actionpack (>= 5.0.1.x)
|
||||
actionview (>= 5.0.1.x)
|
||||
activesupport (>= 5.0.1.x)
|
||||
rails-dom-testing (2.0.3)
|
||||
activesupport (>= 4.2.0)
|
||||
nokogiri (>= 1.6)
|
||||
rails-html-sanitizer (1.2.0)
|
||||
loofah (~> 2.2, >= 2.2.2)
|
||||
railties (6.0.0)
|
||||
actionpack (= 6.0.0)
|
||||
activesupport (= 6.0.0)
|
||||
method_source
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.20.3, < 2.0)
|
||||
rake (12.3.3)
|
||||
rdoc (6.1.1)
|
||||
responders (3.0.0)
|
||||
actionpack (>= 5.0)
|
||||
railties (>= 5.0)
|
||||
ruby-openid (2.7.0)
|
||||
sprockets (3.7.2)
|
||||
concurrent-ruby (~> 1.0)
|
||||
rack (> 1, < 3)
|
||||
sprockets-rails (3.2.1)
|
||||
actionpack (>= 4.0)
|
||||
activesupport (>= 4.0)
|
||||
sprockets (>= 3.0.0)
|
||||
sqlite3 (1.4.1)
|
||||
test_after_commit (1.1.0)
|
||||
activerecord (>= 3.2)
|
||||
thor (0.20.3)
|
||||
thread_safe (0.3.6)
|
||||
timecop (0.9.1)
|
||||
tzinfo (1.2.5)
|
||||
thread_safe (~> 0.1)
|
||||
warden (1.2.8)
|
||||
rack (>= 2.0.6)
|
||||
webrat (0.7.3)
|
||||
nokogiri (>= 1.2.0)
|
||||
rack (>= 1.0)
|
||||
rack-test (>= 0.5.3)
|
||||
websocket-driver (0.7.1)
|
||||
websocket-extensions (>= 0.1.0)
|
||||
websocket-extensions (0.1.4)
|
||||
zeitwerk (2.1.9)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
activemodel-serializers-xml!
|
||||
devise!
|
||||
mocha (~> 1.1)
|
||||
omniauth
|
||||
omniauth-facebook
|
||||
omniauth-oauth2
|
||||
omniauth-openid
|
||||
rails (~> 6.0.0)
|
||||
rails-controller-testing
|
||||
rdoc
|
||||
responders (~> 3.0)
|
||||
sqlite3 (~> 1.4)
|
||||
test_after_commit
|
||||
timecop
|
||||
webrat (= 0.7.3)
|
||||
|
||||
BUNDLED WITH
|
||||
1.17.3
|
||||
@@ -76,7 +76,7 @@ end
|
||||
class TestController < ApplicationController
|
||||
include Rails.application.routes.url_helpers
|
||||
|
||||
before_filter :authenticate_user!
|
||||
before_action :authenticate_user!
|
||||
|
||||
def index
|
||||
render plain: 'Home'
|
||||
|
||||
14
lib/devise.rb
Executable file → Normal file
14
lib/devise.rb
Executable file → Normal file
@@ -71,7 +71,7 @@ module Devise
|
||||
|
||||
# The number of times to hash the password.
|
||||
mattr_accessor :stretches
|
||||
@@stretches = 11
|
||||
@@stretches = 12
|
||||
|
||||
# The default key used when authenticating over http auth.
|
||||
mattr_accessor :http_authentication_key
|
||||
@@ -293,6 +293,10 @@ module Devise
|
||||
mattr_accessor :token_generator
|
||||
@@token_generator = nil
|
||||
|
||||
# When set to false, changing a password does not automatically sign in a user
|
||||
mattr_accessor :sign_in_after_change_password
|
||||
@@sign_in_after_change_password = true
|
||||
|
||||
def self.rails51? # :nodoc:
|
||||
Rails.gem_version >= Gem::Version.new("5.1.x")
|
||||
end
|
||||
@@ -498,12 +502,8 @@ module Devise
|
||||
|
||||
# constant-time comparison algorithm to prevent timing attacks
|
||||
def self.secure_compare(a, b)
|
||||
return false if a.blank? || b.blank? || a.bytesize != b.bytesize
|
||||
l = a.unpack "C#{a.bytesize}"
|
||||
|
||||
res = 0
|
||||
b.each_byte { |byte| res |= byte ^ l.shift }
|
||||
res == 0
|
||||
return false if a.nil? || b.nil?
|
||||
ActiveSupport::SecurityUtils.secure_compare(a, b)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ module Devise
|
||||
|
||||
def #{group_name}_signed_in?
|
||||
#{mappings}.any? do |mapping|
|
||||
warden.authenticate?(scope: mapping)
|
||||
warden.authenticated?(scope: mapping)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -119,7 +119,7 @@ module Devise
|
||||
end
|
||||
|
||||
def #{mapping}_signed_in?
|
||||
!!current_#{mapping}
|
||||
!!(@current_#{mapping} || warden.authenticated?(scope: :#{mapping}))
|
||||
end
|
||||
|
||||
def current_#{mapping}
|
||||
@@ -268,7 +268,7 @@ module Devise
|
||||
# Check if flash messages should be emitted. Default is to do it on
|
||||
# navigational formats
|
||||
def is_flashing_format?
|
||||
is_navigational_format?
|
||||
request.respond_to?(:flash) && is_navigational_format?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -12,13 +12,16 @@ module Devise
|
||||
# authentication hooks, you can directly call `warden.authenticated?(scope: scope)`
|
||||
def signed_in?(scope=nil)
|
||||
[scope || Devise.mappings.keys].flatten.any? do |_scope|
|
||||
warden.authenticate?(scope: _scope)
|
||||
warden.authenticated?(scope: _scope)
|
||||
end
|
||||
end
|
||||
|
||||
# Sign in a user that already was authenticated. This helper is useful for logging
|
||||
# users in after sign up. All options given to sign_in is passed forward
|
||||
# to the set_user method in warden.
|
||||
# If you are using a custom warden strategy and the timeoutable module, you have to
|
||||
# set `env["devise.skip_timeout"] = true` in the request to use this method, like we do
|
||||
# in the sessions controller: https://github.com/plataformatec/devise/blob/master/app/controllers/devise/sessions_controller.rb#L7
|
||||
#
|
||||
# Examples:
|
||||
#
|
||||
@@ -48,6 +51,7 @@ module Devise
|
||||
true
|
||||
else
|
||||
warden.set_user(resource, options.merge!(scope: scope))
|
||||
resource.update_tracked_fields!(warden.request) if resource.respond_to?(:update_tracked_fields!)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -103,11 +103,14 @@ module Devise
|
||||
options[:scope] = "devise.failure"
|
||||
options[:default] = [message]
|
||||
auth_keys = scope_class.authentication_keys
|
||||
keys = (auth_keys.respond_to?(:keys) ? auth_keys.keys : auth_keys).map { |key| scope_class.human_attribute_name(key) }
|
||||
keys = (auth_keys.respond_to?(:keys) ? auth_keys.keys : auth_keys).map { |key| scope_class.human_attribute_name(key).downcase }
|
||||
options[:authentication_keys] = keys.join(I18n.translate(:"support.array.words_connector"))
|
||||
options = i18n_options(options)
|
||||
translated_message = I18n.t(:"#{scope}.#{message}", options)
|
||||
|
||||
I18n.t(:"#{scope}.#{message}", options)
|
||||
# only call `#humanize` when the message is `:invalid` to ensure the original format
|
||||
# of other messages - like `:does_not_exist` - is kept.
|
||||
message == :invalid ? translated_message.humanize : translated_message
|
||||
else
|
||||
message.to_s
|
||||
end
|
||||
@@ -144,11 +147,20 @@ module Devise
|
||||
|
||||
opts[:format] = request_format unless skip_format?
|
||||
|
||||
opts[:script_name] = relative_url_root if relative_url_root?
|
||||
|
||||
router_name = Devise.mappings[scope].router_name || Devise.available_router_name
|
||||
context = send(router_name)
|
||||
|
||||
if relative_url_root?
|
||||
opts[:script_name] = relative_url_root
|
||||
|
||||
# We need to add the rootpath to `script_name` manually for applications that use a Rails
|
||||
# version lower than 5.1. Otherwise, it is going to generate a wrong path for Engines
|
||||
# that use Devise. Remove it when the support of Rails 5.0 is droped.
|
||||
elsif root_path_defined?(context) && !rails_51_and_up?
|
||||
rootpath = context.routes.url_helpers.root_path
|
||||
opts[:script_name] = rootpath.chomp('/') if rootpath.length > 1
|
||||
end
|
||||
|
||||
if context.respond_to?(route)
|
||||
context.send(route, opts)
|
||||
elsif respond_to?(:root_url)
|
||||
@@ -242,7 +254,7 @@ module Devise
|
||||
# Check if flash messages should be emitted. Default is to do it on
|
||||
# navigational formats
|
||||
def is_flashing_format?
|
||||
is_navigational_format?
|
||||
request.respond_to?(:flash) && is_navigational_format?
|
||||
end
|
||||
|
||||
def request_format
|
||||
@@ -260,5 +272,17 @@ module Devise
|
||||
def relative_url_root?
|
||||
relative_url_root.present?
|
||||
end
|
||||
|
||||
ActiveSupport.run_load_hooks(:devise_failure_app, self)
|
||||
|
||||
private
|
||||
|
||||
def root_path_defined?(context)
|
||||
defined?(context.routes) && context.routes.url_helpers.respond_to?(:root_path)
|
||||
end
|
||||
|
||||
def rails_51_and_up?
|
||||
Rails.gem_version >= Gem::Version.new("5.1")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# After each sign in, update sign in time, sign in count and sign in IP.
|
||||
# This is only triggered when the user is explicitly set (with set_user)
|
||||
# and on authentication. Retrieving the user from session (:fetch) does
|
||||
# not trigger it.
|
||||
Warden::Manager.after_set_user except: :fetch do |record, warden, options|
|
||||
if record.respond_to?(:update_tracked_fields!) && warden.authenticated?(options[:scope]) && !warden.request.env['devise.skip_trackable']
|
||||
record.update_tracked_fields!(warden.request)
|
||||
end
|
||||
end
|
||||
@@ -1,6 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'active_model/version'
|
||||
require 'devise/hooks/activatable'
|
||||
require 'devise/hooks/csrf_cleaner'
|
||||
|
||||
@@ -134,16 +133,18 @@ module Devise
|
||||
# This is an internal method called every time Devise needs
|
||||
# to send a notification/mail. This can be overridden if you
|
||||
# need to customize the e-mail delivery logic. For instance,
|
||||
# if you are using a queue to deliver e-mails (delayed job,
|
||||
# sidekiq, resque, etc), you must add the delivery to the queue
|
||||
# if you are using a queue to deliver e-mails (active job, delayed
|
||||
# job, sidekiq, resque, etc), you must add the delivery to the queue
|
||||
# just after the transaction was committed. To achieve this,
|
||||
# you can override send_devise_notification to store the
|
||||
# deliveries until the after_commit callback is triggered:
|
||||
# deliveries until the after_commit callback is triggered.
|
||||
#
|
||||
# The following example uses Active Job's `deliver_later` :
|
||||
#
|
||||
# class User
|
||||
# devise :database_authenticatable, :confirmable
|
||||
#
|
||||
# after_commit :send_pending_notifications
|
||||
# after_commit :send_pending_devise_notifications
|
||||
#
|
||||
# protected
|
||||
#
|
||||
@@ -152,48 +153,45 @@ module Devise
|
||||
# # delivery until the after_commit callback otherwise
|
||||
# # send now because after_commit will not be called.
|
||||
# if new_record? || changed?
|
||||
# pending_notifications << [notification, args]
|
||||
# pending_devise_notifications << [notification, args]
|
||||
# else
|
||||
# message = devise_mailer.send(notification, self, *args)
|
||||
# Remove once we move to Rails 4.2+ only.
|
||||
# if message.respond_to?(:deliver_now)
|
||||
# message.deliver_now
|
||||
# else
|
||||
# message.deliver
|
||||
# end
|
||||
# render_and_send_devise_message(notification, *args)
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# def send_pending_notifications
|
||||
# pending_notifications.each do |notification, args|
|
||||
# message = devise_mailer.send(notification, self, *args)
|
||||
# Remove once we move to Rails 4.2+ only.
|
||||
# if message.respond_to?(:deliver_now)
|
||||
# message.deliver_now
|
||||
# else
|
||||
# message.deliver
|
||||
# end
|
||||
# private
|
||||
#
|
||||
# def send_pending_devise_notifications
|
||||
# pending_devise_notifications.each do |notification, args|
|
||||
# render_and_send_devise_message(notification, *args)
|
||||
# end
|
||||
#
|
||||
# # Empty the pending notifications array because the
|
||||
# # after_commit hook can be called multiple times which
|
||||
# # could cause multiple emails to be sent.
|
||||
# pending_notifications.clear
|
||||
# pending_devise_notifications.clear
|
||||
# end
|
||||
#
|
||||
# def pending_notifications
|
||||
# @pending_notifications ||= []
|
||||
# def pending_devise_notifications
|
||||
# @pending_devise_notifications ||= []
|
||||
# end
|
||||
#
|
||||
# def render_and_send_devise_message(notification, *args)
|
||||
# message = devise_mailer.send(notification, self, *args)
|
||||
#
|
||||
# # Deliver later with Active Job's `deliver_later`
|
||||
# if message.respond_to?(:deliver_later)
|
||||
# message.deliver_later
|
||||
# else
|
||||
# message.deliver_now
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# end
|
||||
#
|
||||
def send_devise_notification(notification, *args)
|
||||
message = devise_mailer.send(notification, self, *args)
|
||||
# Remove once we move to Rails 4.2+ only.
|
||||
if message.respond_to?(:deliver_now)
|
||||
message.deliver_now
|
||||
else
|
||||
message.deliver
|
||||
end
|
||||
message.deliver_now
|
||||
end
|
||||
|
||||
def downcase_keys
|
||||
@@ -276,28 +274,20 @@ module Devise
|
||||
|
||||
# Find or initialize a record with group of attributes based on a list of required attributes.
|
||||
def find_or_initialize_with_errors(required_attributes, attributes, error=:invalid) #:nodoc:
|
||||
attributes = if attributes.respond_to? :permit!
|
||||
attributes.slice(*required_attributes).permit!.to_h.with_indifferent_access
|
||||
else
|
||||
attributes.with_indifferent_access.slice(*required_attributes)
|
||||
end
|
||||
attributes.delete_if { |key, value| value.blank? }
|
||||
attributes.try(:permit!)
|
||||
attributes = attributes.to_h.with_indifferent_access
|
||||
.slice(*required_attributes)
|
||||
.delete_if { |key, value| value.blank? }
|
||||
|
||||
if attributes.size == required_attributes.size
|
||||
record = find_first_by_auth_conditions(attributes)
|
||||
record = find_first_by_auth_conditions(attributes) and return record
|
||||
end
|
||||
|
||||
unless record
|
||||
record = new
|
||||
|
||||
new(devise_parameter_filter.filter(attributes)).tap do |record|
|
||||
required_attributes.each do |key|
|
||||
value = attributes[key]
|
||||
record.send("#{key}=", value)
|
||||
record.errors.add(key, value.present? ? error : :blank)
|
||||
record.errors.add(key, attributes[key].blank? ? :blank : error)
|
||||
end
|
||||
end
|
||||
|
||||
record
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
@@ -211,7 +211,10 @@ module Devise
|
||||
# confirmation_period_valid? # will always return true
|
||||
#
|
||||
def confirmation_period_valid?
|
||||
self.class.allow_unconfirmed_access_for.nil? || (confirmation_sent_at && confirmation_sent_at.utc >= self.class.allow_unconfirmed_access_for.ago)
|
||||
return true if self.class.allow_unconfirmed_access_for.nil?
|
||||
return false if self.class.allow_unconfirmed_access_for == 0.days
|
||||
|
||||
confirmation_sent_at && confirmation_sent_at.utc >= self.class.allow_unconfirmed_access_for.ago
|
||||
end
|
||||
|
||||
# Checks if the user confirmation happens before the token becomes invalid
|
||||
@@ -345,7 +348,19 @@ module Devise
|
||||
# If the user is already confirmed, create an error for the user
|
||||
# Options must have the confirmation_token
|
||||
def confirm_by_token(confirmation_token)
|
||||
# When the `confirmation_token` parameter is blank, if there are any users with a blank
|
||||
# `confirmation_token` in the database, the first one would be confirmed here.
|
||||
# The error is being manually added here to ensure no users are confirmed by mistake.
|
||||
# This was done in the model for convenience, since validation errors are automatically
|
||||
# displayed in the view.
|
||||
if confirmation_token.blank?
|
||||
confirmable = new
|
||||
confirmable.errors.add(:confirmation_token, :blank)
|
||||
return confirmable
|
||||
end
|
||||
|
||||
confirmable = find_first_by_auth_conditions(confirmation_token: confirmation_token)
|
||||
|
||||
unless confirmable
|
||||
confirmation_digest = Devise.token_generator.digest(self, :confirmation_token, confirmation_token)
|
||||
confirmable = find_or_initialize_with_error_by(:confirmation_token, confirmation_digest)
|
||||
|
||||
@@ -35,6 +35,22 @@ module Devise
|
||||
attr_accessor :password_confirmation
|
||||
end
|
||||
|
||||
def initialize(*args, &block)
|
||||
@skip_email_changed_notification = false
|
||||
@skip_password_change_notification = false
|
||||
super
|
||||
end
|
||||
|
||||
# Skips sending the email changed notification after_update
|
||||
def skip_email_changed_notification!
|
||||
@skip_email_changed_notification = true
|
||||
end
|
||||
|
||||
# Skips sending the password change notification after_update
|
||||
def skip_password_change_notification!
|
||||
@skip_password_change_notification = true
|
||||
end
|
||||
|
||||
def self.required_fields(klass)
|
||||
[:encrypted_password] + klass.authentication_keys
|
||||
end
|
||||
@@ -64,7 +80,7 @@ module Devise
|
||||
# users to change relevant information like the e-mail without changing
|
||||
# their password). In case the password field is rejected, the confirmation
|
||||
# is also rejected as long as it is also blank.
|
||||
def update_with_password(params, *options)
|
||||
def update_with_password(params)
|
||||
current_password = params.delete(:current_password)
|
||||
|
||||
if params[:password].blank?
|
||||
@@ -73,11 +89,11 @@ module Devise
|
||||
end
|
||||
|
||||
result = if valid_password?(current_password)
|
||||
update_attributes(params, *options)
|
||||
update(params)
|
||||
else
|
||||
self.assign_attributes(params, *options)
|
||||
self.valid?
|
||||
self.errors.add(:current_password, current_password.blank? ? :blank : :invalid)
|
||||
assign_attributes(params)
|
||||
valid?
|
||||
errors.add(:current_password, current_password.blank? ? :blank : :invalid)
|
||||
false
|
||||
end
|
||||
|
||||
@@ -97,11 +113,11 @@ module Devise
|
||||
# super(params)
|
||||
# end
|
||||
#
|
||||
def update_without_password(params, *options)
|
||||
def update_without_password(params)
|
||||
params.delete(:password)
|
||||
params.delete(:password_confirmation)
|
||||
|
||||
result = update_attributes(params, *options)
|
||||
result = update(params)
|
||||
clean_up_passwords
|
||||
result
|
||||
end
|
||||
@@ -113,8 +129,8 @@ module Devise
|
||||
result = if valid_password?(current_password)
|
||||
destroy
|
||||
else
|
||||
self.valid?
|
||||
self.errors.add(:current_password, current_password.blank? ? :blank : :invalid)
|
||||
valid?
|
||||
errors.add(:current_password, current_password.blank? ? :blank : :invalid)
|
||||
false
|
||||
end
|
||||
|
||||
@@ -169,21 +185,21 @@ module Devise
|
||||
|
||||
if Devise.activerecord51?
|
||||
def send_email_changed_notification?
|
||||
self.class.send_email_changed_notification && saved_change_to_email?
|
||||
self.class.send_email_changed_notification && saved_change_to_email? && !@skip_email_changed_notification
|
||||
end
|
||||
else
|
||||
def send_email_changed_notification?
|
||||
self.class.send_email_changed_notification && email_changed?
|
||||
self.class.send_email_changed_notification && email_changed? && !@skip_email_changed_notification
|
||||
end
|
||||
end
|
||||
|
||||
if Devise.activerecord51?
|
||||
def send_password_change_notification?
|
||||
self.class.send_password_change_notification && saved_change_to_encrypted_password?
|
||||
self.class.send_password_change_notification && saved_change_to_encrypted_password? && !@skip_password_change_notification
|
||||
end
|
||||
else
|
||||
def send_password_change_notification?
|
||||
self.class.send_password_change_notification && encrypted_password_changed?
|
||||
self.class.send_password_change_notification && encrypted_password_changed? && !@skip_password_change_notification
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -112,8 +112,8 @@ module Devise
|
||||
end
|
||||
|
||||
def increment_failed_attempts
|
||||
self.failed_attempts ||= 0
|
||||
self.failed_attempts += 1
|
||||
self.class.increment_counter(:failed_attempts, id)
|
||||
reload
|
||||
end
|
||||
|
||||
def unauthenticated_message
|
||||
@@ -122,7 +122,15 @@ module Devise
|
||||
if Devise.paranoid
|
||||
super
|
||||
elsif access_locked? || (lock_strategy_enabled?(:failed_attempts) && attempts_exceeded?)
|
||||
:locked
|
||||
if unlock_strategy_enabled?(:both)
|
||||
'locked.both'.to_sym
|
||||
elsif unlock_strategy_enabled?(:email)
|
||||
'locked.email'.to_sym
|
||||
elsif unlock_strategy_enabled?(:time)
|
||||
'locked.time'.to_sym
|
||||
else
|
||||
'locked.none'.to_sym
|
||||
end
|
||||
elsif lock_strategy_enabled?(:failed_attempts) && last_attempt? && self.class.last_attempt_warning
|
||||
:last_attempt
|
||||
else
|
||||
|
||||
@@ -21,6 +21,8 @@ module Devise
|
||||
def new_with_session(params, session)
|
||||
new(params)
|
||||
end
|
||||
|
||||
Devise::Models.config(self, :sign_in_after_change_password)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'devise/hooks/trackable'
|
||||
|
||||
module Devise
|
||||
module Models
|
||||
# Track information about your user sign in. It tracks the following columns:
|
||||
@@ -22,7 +20,7 @@ module Devise
|
||||
self.last_sign_in_at = old_current || new_current
|
||||
self.current_sign_in_at = new_current
|
||||
|
||||
old_current, new_current = self.current_sign_in_ip, request.remote_ip
|
||||
old_current, new_current = self.current_sign_in_ip, extract_ip_from(request)
|
||||
self.last_sign_in_ip = old_current || new_current
|
||||
self.current_sign_in_ip = new_current
|
||||
|
||||
@@ -36,9 +34,23 @@ module Devise
|
||||
# See https://github.com/plataformatec/devise/issues/4673 for more details.
|
||||
return if new_record?
|
||||
|
||||
return if skip_trackable_and_not_active_for_authentication?(request)
|
||||
|
||||
update_tracked_fields(request)
|
||||
save(validate: false)
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def extract_ip_from(request)
|
||||
request.remote_ip
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def skip_trackable_and_not_active_for_authentication?(request)
|
||||
request.env['devise.skip_trackable'] || !active_for_authentication?
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -30,7 +30,7 @@ module Devise
|
||||
base.class_eval do
|
||||
validates_presence_of :email, if: :email_required?
|
||||
if Devise.activerecord51?
|
||||
validates_uniqueness_of :email, allow_blank: true, if: :will_save_change_to_email?
|
||||
validates_uniqueness_of :email, allow_blank: true, case_sensitive: true, if: :will_save_change_to_email?
|
||||
validates_format_of :email, with: email_regexp, allow_blank: true, if: :will_save_change_to_email?
|
||||
else
|
||||
validates_uniqueness_of :email, allow_blank: true, if: :email_changed?
|
||||
|
||||
@@ -18,6 +18,8 @@ module Devise
|
||||
|
||||
def filtered_hash_by_method_for_given_keys(conditions, method, condition_keys)
|
||||
condition_keys.each do |k|
|
||||
next unless conditions.key?(k)
|
||||
|
||||
value = conditions[k]
|
||||
conditions[k] = value.send(method) if value.respond_to?(method)
|
||||
end
|
||||
|
||||
@@ -130,12 +130,23 @@ module Devise
|
||||
#
|
||||
# Returns an +ActiveSupport::HashWithIndifferentAccess+.
|
||||
def cast_to_hash(params)
|
||||
# TODO: Remove the `with_indifferent_access` method call when we only support Rails 5+.
|
||||
params && params.to_h.with_indifferent_access
|
||||
params && params.to_h
|
||||
end
|
||||
|
||||
def default_params
|
||||
@params.fetch(@resource_name, {})
|
||||
if hashable_resource_params?
|
||||
@params.fetch(@resource_name)
|
||||
else
|
||||
empty_params
|
||||
end
|
||||
end
|
||||
|
||||
def hashable_resource_params?
|
||||
@params[@resource_name].respond_to?(:permit)
|
||||
end
|
||||
|
||||
def empty_params
|
||||
ActionController::Parameters.new({})
|
||||
end
|
||||
|
||||
def permit_keys(parameters, keys)
|
||||
|
||||
@@ -135,10 +135,10 @@ module ActionDispatch::Routing
|
||||
# * failure_app: a rack app which is invoked whenever there is a failure. Strings representing a given
|
||||
# are also allowed as parameter.
|
||||
#
|
||||
# * sign_out_via: the HTTP method(s) accepted for the :sign_out action (default: :get),
|
||||
# * sign_out_via: the HTTP method(s) accepted for the :sign_out action (default: :delete),
|
||||
# if you wish to restrict this to accept only :post or :delete requests you should do:
|
||||
#
|
||||
# devise_for :users, sign_out_via: [:post, :delete]
|
||||
# devise_for :users, sign_out_via: [:get, :post]
|
||||
#
|
||||
# You need to make sure that your sign_out controls trigger a request with a matching HTTP method.
|
||||
#
|
||||
|
||||
@@ -13,6 +13,8 @@ module Devise
|
||||
@application.secrets.secret_key_base
|
||||
elsif @application.config.respond_to?(:secret_key_base) && key_exists?(@application.config)
|
||||
@application.config.secret_key_base
|
||||
elsif @application.respond_to?(:secret_key_base) && key_exists?(@application)
|
||||
@application.secret_key_base
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ module Devise
|
||||
private
|
||||
|
||||
# Receives a resource and check if it is valid by calling valid_for_authentication?
|
||||
# An optional block that will be triggered while validating can be optionally
|
||||
# A block that will be triggered while validating can be optionally
|
||||
# given as parameter. Check Devise::Models::Authenticatable.valid_for_authentication?
|
||||
# for more information.
|
||||
#
|
||||
|
||||
@@ -12,12 +12,18 @@ module Devise
|
||||
|
||||
if validate(resource){ hashed = true; resource.valid_password?(password) }
|
||||
remember_me(resource)
|
||||
resource.update_tracked_fields!(request) if resource.respond_to?(:update_tracked_fields!)
|
||||
resource.after_database_authentication
|
||||
success!(resource)
|
||||
end
|
||||
|
||||
# In paranoid mode, hash the password even when a resource doesn't exist for the given authentication key.
|
||||
# This is necessary to prevent enumeration attacks - e.g. the request is faster when a resource doesn't
|
||||
# exist in the database if the password hashing algorithm is not called.
|
||||
mapping.to.new.password = password if !hashed && Devise.paranoid
|
||||
fail(:not_found_in_database) unless resource
|
||||
unless resource
|
||||
Devise.paranoid ? fail(:invalid) : fail(:not_found_in_database)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -139,7 +139,6 @@ module Devise
|
||||
|
||||
status, headers, response = Devise.warden_config[:failure_app].call(env).to_a
|
||||
@controller.response.headers.merge!(headers)
|
||||
@controller.response.content_type = headers["Content-Type"] unless Rails.version.start_with?('5')
|
||||
@controller.status = status
|
||||
@controller.response.body = response.body
|
||||
nil # causes process return @response
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Devise
|
||||
VERSION = "4.4.3".freeze
|
||||
VERSION = "4.7.1".freeze
|
||||
end
|
||||
|
||||
@@ -54,11 +54,11 @@ module ActiveRecord
|
||||
t.datetime :remember_created_at
|
||||
|
||||
## Trackable
|
||||
t.integer :sign_in_count, default: 0, null: false
|
||||
t.datetime :current_sign_in_at
|
||||
t.datetime :last_sign_in_at
|
||||
t.#{ip_column} :current_sign_in_ip
|
||||
t.#{ip_column} :last_sign_in_ip
|
||||
# t.integer :sign_in_count, default: 0, null: false
|
||||
# t.datetime :current_sign_in_at
|
||||
# t.datetime :last_sign_in_at
|
||||
# t.#{ip_column} :current_sign_in_ip
|
||||
# t.#{ip_column} :last_sign_in_ip
|
||||
|
||||
## Confirmable
|
||||
# t.string :confirmation_token
|
||||
@@ -82,23 +82,17 @@ RUBY
|
||||
postgresql?
|
||||
end
|
||||
|
||||
def rails5?
|
||||
Rails.version.start_with? '5'
|
||||
end
|
||||
|
||||
def postgresql?
|
||||
config = ActiveRecord::Base.configurations[Rails.env]
|
||||
config && config['adapter'] == 'postgresql'
|
||||
end
|
||||
|
||||
def migration_version
|
||||
if rails5?
|
||||
"[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
|
||||
end
|
||||
"[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
|
||||
end
|
||||
|
||||
def primary_key_type
|
||||
primary_key_string if rails5?
|
||||
primary_key_string
|
||||
end
|
||||
|
||||
def primary_key_string
|
||||
|
||||
@@ -18,7 +18,7 @@ module Devise
|
||||
|
||||
This will create a controller class at app/controllers/users/sessions_controller.rb like this:
|
||||
|
||||
class Users::ConfirmationsController < Devise::ConfirmationsController
|
||||
class Users::SessionsController < Devise::SessionsController
|
||||
content...
|
||||
end
|
||||
DESC
|
||||
|
||||
@@ -37,10 +37,6 @@ module Devise
|
||||
def show_readme
|
||||
readme "README" if behavior == :invoke
|
||||
end
|
||||
|
||||
def rails_4?
|
||||
Rails::VERSION::MAJOR == 4
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -6,9 +6,9 @@ module Devise
|
||||
def model_contents
|
||||
buffer = <<-CONTENT
|
||||
# Include default devise modules. Others available are:
|
||||
# :confirmable, :lockable, :timeoutable and :omniauthable
|
||||
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
|
||||
devise :database_authenticatable, :registerable,
|
||||
:recoverable, :rememberable, :trackable, :validatable
|
||||
:recoverable, :rememberable, :validatable
|
||||
|
||||
CONTENT
|
||||
buffer
|
||||
|
||||
@@ -42,7 +42,7 @@ module Devise
|
||||
def view_directory(name, _target_path = nil)
|
||||
directory name.to_s, _target_path || "#{target_path}/#{name}" do |content|
|
||||
if scope
|
||||
content.gsub "devise/shared/links", "#{plural_scope}/shared/links"
|
||||
content.gsub("devise/shared/links", "#{plural_scope}/shared/links").gsub("devise/shared/error_messages", "#{plural_scope}/shared/error_messages")
|
||||
else
|
||||
content
|
||||
end
|
||||
|
||||
@@ -34,11 +34,11 @@ module Mongoid
|
||||
field :remember_created_at, type: Time
|
||||
|
||||
## Trackable
|
||||
field :sign_in_count, type: Integer, default: 0
|
||||
field :current_sign_in_at, type: Time
|
||||
field :last_sign_in_at, type: Time
|
||||
field :current_sign_in_ip, type: String
|
||||
field :last_sign_in_ip, type: String
|
||||
# field :sign_in_count, type: Integer, default: 0
|
||||
# field :current_sign_in_at, type: Time
|
||||
# field :last_sign_in_at, type: Time
|
||||
# field :current_sign_in_ip, type: String
|
||||
# field :last_sign_in_ip, type: String
|
||||
|
||||
## Confirmable
|
||||
# field :confirmation_token, type: String
|
||||
|
||||
26
lib/generators/templates/devise.rb
Executable file → Normal file
26
lib/generators/templates/devise.rb
Executable file → Normal file
@@ -9,7 +9,7 @@ Devise.setup do |config|
|
||||
# Devise will use the `secret_key_base` as its `secret_key`
|
||||
# by default. You can change it below and use your own secret key.
|
||||
# config.secret_key = '<%= SecureRandom.hex(64) %>'
|
||||
|
||||
|
||||
# ==> Controller configuration
|
||||
# Configure the parent class to the devise controllers.
|
||||
# config.parent_controller = 'DeviseController'
|
||||
@@ -103,7 +103,7 @@ Devise.setup do |config|
|
||||
# config.reload_routes = true
|
||||
|
||||
# ==> Configuration for :database_authenticatable
|
||||
# For bcrypt, this is the cost for hashing the password and defaults to 11. If
|
||||
# For bcrypt, this is the cost for hashing the password and defaults to 12. If
|
||||
# using other algorithms, it sets how many times you want the password to be hashed.
|
||||
#
|
||||
# Limiting the stretches to just one in testing will increase the performance of
|
||||
@@ -111,7 +111,7 @@ Devise.setup do |config|
|
||||
# a value less than 10 in other environments. Note that, for bcrypt (the default
|
||||
# algorithm), the cost increases exponentially with the number of stretches (e.g.
|
||||
# a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
|
||||
config.stretches = Rails.env.test? ? 1 : 11
|
||||
config.stretches = Rails.env.test? ? 1 : 12
|
||||
|
||||
# Set up a pepper to generate the hashed password.
|
||||
# config.pepper = '<%= SecureRandom.hex(64) %>'
|
||||
@@ -126,8 +126,11 @@ Devise.setup do |config|
|
||||
# A period that the user is allowed to access the website even without
|
||||
# confirming their account. For instance, if set to 2.days, the user will be
|
||||
# able to access the website for two days without confirming their account,
|
||||
# access will be blocked just in the third day. Default is 0.days, meaning
|
||||
# the user cannot access the website without confirming their account.
|
||||
# access will be blocked just in the third day.
|
||||
# You can also set it to nil, which will allow the user to access the website
|
||||
# without confirming their account.
|
||||
# Default is 0.days, meaning the user cannot access the website without
|
||||
# confirming their account.
|
||||
# config.allow_unconfirmed_access_for = 2.days
|
||||
|
||||
# A period that the user is allowed to confirm their account before their
|
||||
@@ -280,4 +283,17 @@ Devise.setup do |config|
|
||||
# When using OmniAuth, Devise cannot automatically set OmniAuth path,
|
||||
# so you need to do it manually. For the users scope, it would be:
|
||||
# config.omniauth_path_prefix = '/my_engine/users/auth'
|
||||
|
||||
# ==> Turbolinks configuration
|
||||
# If your app is using Turbolinks, Turbolinks::Controller needs to be included to make redirection work correctly:
|
||||
#
|
||||
# ActiveSupport.on_load(:devise_failure_app) do
|
||||
# include Turbolinks::Controller
|
||||
# end
|
||||
|
||||
# ==> Configuration for :registerable
|
||||
|
||||
# When set to false, does not sign a user in automatically after their password is
|
||||
# changed. Defaults to true, so a user is signed in automatically after changing a password.
|
||||
# config.sign_in_after_change_password = true
|
||||
end
|
||||
|
||||
@@ -5,7 +5,11 @@
|
||||
<%= f.full_error :confirmation_token %>
|
||||
|
||||
<div class="form-inputs">
|
||||
<%= f.input :email, required: true, autofocus: true %>
|
||||
<%= f.input :email,
|
||||
required: true,
|
||||
autofocus: true,
|
||||
value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email),
|
||||
input_html: { autocomplete: "email" } %>
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
|
||||
@@ -7,8 +7,16 @@
|
||||
<%= f.full_error :reset_password_token %>
|
||||
|
||||
<div class="form-inputs">
|
||||
<%= f.input :password, label: "New password", required: true, autofocus: true, hint: ("#{@minimum_password_length} characters minimum" if @minimum_password_length) %>
|
||||
<%= f.input :password_confirmation, label: "Confirm your new password", required: true %>
|
||||
<%= f.input :password,
|
||||
label: "New password",
|
||||
required: true,
|
||||
autofocus: true,
|
||||
hint: ("#{@minimum_password_length} characters minimum" if @minimum_password_length),
|
||||
input_html: { autocomplete: "new-password" } %>
|
||||
<%= f.input :password_confirmation,
|
||||
label: "Confirm your new password",
|
||||
required: true,
|
||||
input_html: { autocomplete: "new-password" } %>
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
|
||||
@@ -4,7 +4,10 @@
|
||||
<%= f.error_notification %>
|
||||
|
||||
<div class="form-inputs">
|
||||
<%= f.input :email, required: true, autofocus: true %>
|
||||
<%= f.input :email,
|
||||
required: true,
|
||||
autofocus: true,
|
||||
input_html: { autocomplete: "email" } %>
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
|
||||
@@ -10,9 +10,17 @@
|
||||
<p>Currently waiting confirmation for: <%= resource.unconfirmed_email %></p>
|
||||
<% end %>
|
||||
|
||||
<%= f.input :password, autocomplete: "off", hint: "leave it blank if you don't want to change it", required: false %>
|
||||
<%= f.input :password_confirmation, required: false %>
|
||||
<%= f.input :current_password, hint: "we need your current password to confirm your changes", required: true %>
|
||||
<%= f.input :password,
|
||||
hint: "leave it blank if you don't want to change it",
|
||||
required: false,
|
||||
input_html: { autocomplete: "new-password" } %>
|
||||
<%= f.input :password_confirmation,
|
||||
required: false,
|
||||
input_html: { autocomplete: "new-password" } %>
|
||||
<%= f.input :current_password,
|
||||
hint: "we need your current password to confirm your changes",
|
||||
required: true,
|
||||
input_html: { autocomplete: "current-password" } %>
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
|
||||
@@ -4,9 +4,17 @@
|
||||
<%= f.error_notification %>
|
||||
|
||||
<div class="form-inputs">
|
||||
<%= f.input :email, required: true, autofocus: true %>
|
||||
<%= f.input :password, required: true, hint: ("#{@minimum_password_length} characters minimum" if @minimum_password_length) %>
|
||||
<%= f.input :password_confirmation, required: true %>
|
||||
<%= f.input :email,
|
||||
required: true,
|
||||
autofocus: true,
|
||||
input_html: { autocomplete: "email" }%>
|
||||
<%= f.input :password,
|
||||
required: true,
|
||||
hint: ("#{@minimum_password_length} characters minimum" if @minimum_password_length),
|
||||
input_html: { autocomplete: "new-password" } %>
|
||||
<%= f.input :password_confirmation,
|
||||
required: true,
|
||||
input_html: { autocomplete: "new-password" } %>
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
|
||||
@@ -2,8 +2,13 @@
|
||||
|
||||
<%= simple_form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
|
||||
<div class="form-inputs">
|
||||
<%= f.input :email, required: false, autofocus: true %>
|
||||
<%= f.input :password, required: false %>
|
||||
<%= f.input :email,
|
||||
required: false,
|
||||
autofocus: true,
|
||||
input_html: { autocomplete: "email" } %>
|
||||
<%= f.input :password,
|
||||
required: false,
|
||||
input_html: { autocomplete: "current-password" } %>
|
||||
<%= f.input :remember_me, as: :boolean if devise_mapping.rememberable? %>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -5,7 +5,10 @@
|
||||
<%= f.full_error :unlock_token %>
|
||||
|
||||
<div class="form-inputs">
|
||||
<%= f.input :email, required: true, autofocus: true %>
|
||||
<%= f.input :email,
|
||||
required: true,
|
||||
autofocus: true,
|
||||
input_html: { autocomplete: "email" } %>
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
|
||||
@@ -15,21 +15,21 @@ class ControllerAuthenticatableTest < Devise::ControllerTestCase
|
||||
assert_equal @mock_warden, @controller.warden
|
||||
end
|
||||
|
||||
test 'proxy signed_in?(scope) to authenticate?' do
|
||||
@mock_warden.expects(:authenticate?).with(scope: :my_scope)
|
||||
test 'proxy signed_in?(scope) to authenticated?' do
|
||||
@mock_warden.expects(:authenticated?).with(scope: :my_scope)
|
||||
@controller.signed_in?(:my_scope)
|
||||
end
|
||||
|
||||
test 'proxy signed_in?(nil) to authenticate?' do
|
||||
test 'proxy signed_in?(nil) to authenticated?' do
|
||||
Devise.mappings.keys.each do |scope| # :user, :admin, :manager
|
||||
@mock_warden.expects(:authenticate?).with(scope: scope)
|
||||
@mock_warden.expects(:authenticated?).with(scope: scope)
|
||||
end
|
||||
@controller.signed_in?
|
||||
end
|
||||
|
||||
test 'proxy [group]_signed_in? to authenticate? with each scope' do
|
||||
test 'proxy [group]_signed_in? to authenticated? with each scope' do
|
||||
[:user, :admin].each do |scope|
|
||||
@mock_warden.expects(:authenticate?).with(scope: scope).returns(false)
|
||||
@mock_warden.expects(:authenticated?).with(scope: scope).returns(false)
|
||||
end
|
||||
@controller.commenter_signed_in?
|
||||
end
|
||||
@@ -81,7 +81,7 @@ class ControllerAuthenticatableTest < Devise::ControllerTestCase
|
||||
test 'proxy authenticate_[group]! to authenticate!? with each scope' do
|
||||
[:user, :admin].each do |scope|
|
||||
@mock_warden.expects(:authenticate!).with(scope: scope)
|
||||
@mock_warden.expects(:authenticate?).with(scope: scope).returns(false)
|
||||
@mock_warden.expects(:authenticated?).with(scope: scope).returns(false)
|
||||
end
|
||||
@controller.authenticate_commenter!
|
||||
end
|
||||
@@ -91,18 +91,18 @@ class ControllerAuthenticatableTest < Devise::ControllerTestCase
|
||||
@controller.authenticate_publisher_account!
|
||||
end
|
||||
|
||||
test 'proxy user_signed_in? to authenticate with user scope' do
|
||||
@mock_warden.expects(:authenticate).with(scope: :user).returns("user")
|
||||
test 'proxy user_signed_in? to authenticated? with user scope' do
|
||||
@mock_warden.expects(:authenticated?).with(scope: :user).returns("user")
|
||||
assert @controller.user_signed_in?
|
||||
end
|
||||
|
||||
test 'proxy admin_signed_in? to authenticatewith admin scope' do
|
||||
@mock_warden.expects(:authenticate).with(scope: :admin)
|
||||
test 'proxy admin_signed_in? to authenticated? with admin scope' do
|
||||
@mock_warden.expects(:authenticated?).with(scope: :admin)
|
||||
refute @controller.admin_signed_in?
|
||||
end
|
||||
|
||||
test 'proxy publisher_account_signed_in? to authenticate with namespaced publisher account scope' do
|
||||
@mock_warden.expects(:authenticate).with(scope: :publisher_account)
|
||||
test 'proxy publisher_account_signed_in? to authenticated? with namespaced publisher account scope' do
|
||||
@mock_warden.expects(:authenticated?).with(scope: :publisher_account)
|
||||
@controller.publisher_account_signed_in?
|
||||
end
|
||||
|
||||
@@ -312,6 +312,16 @@ class ControllerAuthenticatableTest < Devise::ControllerTestCase
|
||||
end
|
||||
end
|
||||
|
||||
test 'is_flashing_format? depends on is_navigation_format?' do
|
||||
@controller.expects(:is_navigational_format?).returns(true)
|
||||
assert @controller.is_flashing_format?
|
||||
end
|
||||
|
||||
test 'is_flashing_format? is guarded against flash (middleware) not being loaded' do
|
||||
@controller.request.expects(:respond_to?).with(:flash).returns(false)
|
||||
refute @controller.is_flashing_format?
|
||||
end
|
||||
|
||||
test 'is not a devise controller' do
|
||||
refute @controller.devise_controller?
|
||||
end
|
||||
|
||||
@@ -31,4 +31,15 @@ class PasswordsControllerTest < Devise::ControllerTestCase
|
||||
put_update_with_params
|
||||
assert_redirected_to custom_path
|
||||
end
|
||||
|
||||
test 'calls after_database_authentication callback after sign_in immediately after password update' do
|
||||
User.any_instance.expects :after_database_authentication
|
||||
put_update_with_params
|
||||
end
|
||||
|
||||
test 'redirects to new_password_path when token has expired' do
|
||||
@user.update(reset_password_sent_at: Time.now - 1.year)
|
||||
put_update_with_params
|
||||
assert_redirected_to new_user_password_path
|
||||
end
|
||||
end
|
||||
|
||||
@@ -74,7 +74,7 @@ class SessionsControllerTest < Devise::ControllerTestCase
|
||||
assert_template "devise/sessions/new"
|
||||
end
|
||||
|
||||
test "#destroy doesn't set the flash if the requested format is not navigational" do
|
||||
test "#destroy doesn't set the flash and returns 204 status if the requested format is not navigational" do
|
||||
request.env["devise.mapping"] = Devise.mappings[:user]
|
||||
user = create_user
|
||||
user.confirm
|
||||
@@ -88,6 +88,17 @@ class SessionsControllerTest < Devise::ControllerTestCase
|
||||
assert_equal 204, @response.status
|
||||
end
|
||||
|
||||
test "#destroy returns 401 status if user is not signed in and the requested format is not navigational" do
|
||||
delete :destroy, format: 'json'
|
||||
assert_equal 401, @response.status
|
||||
end
|
||||
|
||||
test "#destroy returns 302 status if user is not signed in and the requested format is navigational" do
|
||||
request.env["devise.mapping"] = Devise.mappings[:user]
|
||||
delete :destroy
|
||||
assert_equal 302, @response.status
|
||||
end
|
||||
|
||||
if defined?(ActiveRecord) && ActiveRecord::Base.respond_to?(:mass_assignment_sanitizer)
|
||||
test "#new doesn't raise mass-assignment exception even if sign-in key is attr_protected" do
|
||||
request.env["devise.mapping"] = Devise.mappings[:user]
|
||||
|
||||
5
test/devise_test.rb
Executable file → Normal file
5
test/devise_test.rb
Executable file → Normal file
@@ -90,11 +90,14 @@ class DeviseTest < ActiveSupport::TestCase
|
||||
[nil, ""].each do |empty|
|
||||
refute Devise.secure_compare(empty, "something")
|
||||
refute Devise.secure_compare("something", empty)
|
||||
refute Devise.secure_compare(empty, empty)
|
||||
end
|
||||
refute Devise.secure_compare("size_1", "size_four")
|
||||
end
|
||||
|
||||
test 'Devise.secure_compare should return true if strings are same' do
|
||||
assert Devise.secure_compare('', '')
|
||||
end
|
||||
|
||||
test 'Devise.email_regexp should match valid email addresses' do
|
||||
valid_emails = ["test@example.com", "jo@jo.co", "f4$_m@you.com", "testing.example@example.com.ua", "test@tt", "test@valid---domain.com"]
|
||||
non_valid_emails = ["rex", "test user@example.com", "test_user@example server.com"]
|
||||
|
||||
@@ -28,6 +28,27 @@ class FailureTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
class FailureWithoutRootPath < Devise::FailureApp
|
||||
class FakeURLHelpers
|
||||
end
|
||||
|
||||
class FakeRoutesWithoutRoot
|
||||
def url_helpers
|
||||
FakeURLHelpers.new
|
||||
end
|
||||
end
|
||||
|
||||
class FakeAppWithoutRootPath
|
||||
def routes
|
||||
FakeRoutesWithoutRoot.new
|
||||
end
|
||||
end
|
||||
|
||||
def main_app
|
||||
FakeAppWithoutRootPath.new
|
||||
end
|
||||
end
|
||||
|
||||
class FakeEngineApp < Devise::FailureApp
|
||||
class FakeEngine
|
||||
def new_user_on_engine_session_url _
|
||||
@@ -44,6 +65,10 @@ class FailureTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
class RequestWithoutFlashSupport < ActionDispatch::Request
|
||||
undef_method :flash
|
||||
end
|
||||
|
||||
def self.context(name, &block)
|
||||
instance_eval(&block)
|
||||
end
|
||||
@@ -66,7 +91,7 @@ class FailureTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
@response = (env.delete(:app) || Devise::FailureApp).call(env).to_a
|
||||
@request = ActionDispatch::Request.new(env)
|
||||
@request = (env.delete(:request_klass) || ActionDispatch::Request).new(env)
|
||||
end
|
||||
|
||||
context 'When redirecting' do
|
||||
@@ -99,6 +124,13 @@ class FailureTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
test 'returns to the root path even when it\'s not defined' do
|
||||
call_failure app: FailureWithoutRootPath
|
||||
assert_equal 302, @response.first
|
||||
assert_equal 'You need to sign in or sign up before continuing.', @request.flash[:alert]
|
||||
assert_equal 'http://test.host/', @response.second['Location']
|
||||
end
|
||||
|
||||
test 'returns to the root path considering subdomain if no session path is available' do
|
||||
swap Devise, router_name: :fake_app do
|
||||
call_failure app: FailureWithSubdomain
|
||||
@@ -153,17 +185,27 @@ class FailureTest < ActiveSupport::TestCase
|
||||
|
||||
test 'uses the proxy failure message as symbol' do
|
||||
call_failure('warden' => OpenStruct.new(message: :invalid))
|
||||
assert_equal 'Invalid Email or password.', @request.flash[:alert]
|
||||
assert_equal 'Invalid email or password.', @request.flash[:alert]
|
||||
assert_equal 'http://test.host/users/sign_in', @response.second["Location"]
|
||||
end
|
||||
|
||||
test 'supports authentication_keys as a Hash for the flash message' do
|
||||
swap Devise, authentication_keys: { email: true, login: true } do
|
||||
call_failure('warden' => OpenStruct.new(message: :invalid))
|
||||
assert_equal 'Invalid Email, Login or password.', @request.flash[:alert]
|
||||
assert_equal 'Invalid email, login or password.', @request.flash[:alert]
|
||||
end
|
||||
end
|
||||
|
||||
test 'downcases authentication_keys for the flash message' do
|
||||
call_failure('warden' => OpenStruct.new(message: :invalid))
|
||||
assert_equal 'Invalid email or password.', @request.flash[:alert]
|
||||
end
|
||||
|
||||
test 'humanizes the flash message' do
|
||||
call_failure('warden' => OpenStruct.new(message: :invalid))
|
||||
assert_equal @request.flash[:alert], @request.flash[:alert].humanize
|
||||
end
|
||||
|
||||
test 'uses custom i18n options' do
|
||||
call_failure('warden' => OpenStruct.new(message: :does_not_exist), app: FailureWithI18nOptions)
|
||||
assert_equal 'User Steve does not exist', @request.flash[:alert]
|
||||
@@ -246,7 +288,7 @@ class FailureTest < ActiveSupport::TestCase
|
||||
|
||||
test 'uses the failure message as response body' do
|
||||
call_failure('formats' => Mime[:xml], 'warden' => OpenStruct.new(message: :invalid))
|
||||
assert_match '<error>Invalid Email or password.</error>', @response.third.body
|
||||
assert_match '<error>Invalid email or password.</error>', @response.third.body
|
||||
end
|
||||
|
||||
context 'on ajax call' do
|
||||
@@ -295,7 +337,7 @@ class FailureTest < ActiveSupport::TestCase
|
||||
}
|
||||
call_failure(env)
|
||||
assert @response.third.body.include?('<h2>Log in</h2>')
|
||||
assert @response.third.body.include?('Invalid Email or password.')
|
||||
assert @response.third.body.include?('Invalid email or password.')
|
||||
end
|
||||
|
||||
test 'calls the original controller if not confirmed email' do
|
||||
@@ -330,11 +372,24 @@ class FailureTest < ActiveSupport::TestCase
|
||||
}
|
||||
call_failure(env)
|
||||
assert @response.third.body.include?('<h2>Log in</h2>')
|
||||
assert @response.third.body.include?('Invalid Email or password.')
|
||||
assert @response.third.body.include?('Invalid email or password.')
|
||||
assert_equal @request.env["SCRIPT_NAME"], '/sample'
|
||||
assert_equal @request.env["PATH_INFO"], '/users/sign_in'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "Lazy loading" do
|
||||
test "loads" do
|
||||
assert_equal Devise::FailureApp.new.lazy_loading_works?, "yes it does"
|
||||
end
|
||||
end
|
||||
context "Without Flash Support" do
|
||||
test "returns to the default redirect location without a flash message" do
|
||||
call_failure request_klass: RequestWithoutFlashSupport
|
||||
assert_equal 302, @response.first
|
||||
assert_equal 'http://test.host/users/sign_in', @response.second['Location']
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -48,7 +48,6 @@ if DEVISE_ORM == :active_record
|
||||
run_generator %w(monster)
|
||||
assert_file "app/models/monster.rb"
|
||||
run_generator %w(monster)
|
||||
|
||||
if Rails.version >= '5.0.3'
|
||||
assert_migration "db2/migrate/add_devise_to_monsters.rb"
|
||||
else
|
||||
@@ -84,11 +83,7 @@ if DEVISE_ORM == :active_record
|
||||
|
||||
test "add primary key type with rails 5 when specified in rails generator" do
|
||||
run_generator ["monster", "--primary_key_type=uuid"]
|
||||
if Rails.version.start_with? '5'
|
||||
assert_migration "db/migrate/devise_create_monsters.rb", /create_table :monsters, id: :uuid do/
|
||||
else
|
||||
assert_migration "db/migrate/devise_create_monsters.rb", /create_table :monsters do/
|
||||
end
|
||||
assert_migration "db/migrate/devise_create_monsters.rb", /create_table :monsters, id: :uuid do/
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -11,16 +11,19 @@ class ViewsGeneratorTest < Rails::Generators::TestCase
|
||||
run_generator
|
||||
assert_files
|
||||
assert_shared_links
|
||||
assert_error_messages
|
||||
end
|
||||
|
||||
test "Assert all views are properly created with scope param" do
|
||||
run_generator %w(users)
|
||||
assert_files "users"
|
||||
assert_shared_links "users"
|
||||
assert_error_messages "users"
|
||||
|
||||
run_generator %w(admins)
|
||||
assert_files "admins"
|
||||
assert_shared_links "admins"
|
||||
assert_error_messages "admins"
|
||||
end
|
||||
|
||||
test "Assert views with simple form" do
|
||||
@@ -88,6 +91,7 @@ class ViewsGeneratorTest < Rails::Generators::TestCase
|
||||
assert_file "app/views/#{scope}/registrations/edit.html.erb"
|
||||
assert_file "app/views/#{scope}/sessions/new.html.erb"
|
||||
assert_file "app/views/#{scope}/shared/_links.html.erb"
|
||||
assert_file "app/views/#{scope}/shared/_error_messages.html.erb"
|
||||
assert_file "app/views/#{scope}/unlocks/new.html.erb"
|
||||
end
|
||||
|
||||
@@ -102,4 +106,16 @@ class ViewsGeneratorTest < Rails::Generators::TestCase
|
||||
assert_file "app/views/#{scope}/sessions/new.html.erb", link
|
||||
assert_file "app/views/#{scope}/unlocks/new.html.erb", link
|
||||
end
|
||||
|
||||
def assert_error_messages(scope = nil)
|
||||
scope = "devise" if scope.nil?
|
||||
link = /<%= render \"#{scope}\/shared\/error_messages\", resource: resource %>/
|
||||
|
||||
assert_file "app/views/#{scope}/passwords/edit.html.erb", link
|
||||
assert_file "app/views/#{scope}/passwords/new.html.erb", link
|
||||
assert_file "app/views/#{scope}/confirmations/new.html.erb", link
|
||||
assert_file "app/views/#{scope}/registrations/new.html.erb", link
|
||||
assert_file "app/views/#{scope}/registrations/edit.html.erb", link
|
||||
assert_file "app/views/#{scope}/unlocks/new.html.erb", link
|
||||
end
|
||||
end
|
||||
|
||||
@@ -557,7 +557,7 @@ class AuthenticationKeysTest < Devise::IntegrationTest
|
||||
test 'missing authentication keys cause authentication to abort' do
|
||||
swap Devise, authentication_keys: [:subdomain] do
|
||||
sign_in_as_user
|
||||
assert_contain "Invalid Subdomain or password."
|
||||
assert_contain "Invalid subdomain or password."
|
||||
refute warden.authenticated?(:user)
|
||||
end
|
||||
end
|
||||
@@ -596,7 +596,7 @@ class AuthenticationRequestKeysTest < Devise::IntegrationTest
|
||||
|
||||
swap Devise, request_keys: [:subdomain] do
|
||||
sign_in_as_user
|
||||
assert_contain "Invalid Email or password."
|
||||
assert_contain "Invalid email or password."
|
||||
refute warden.authenticated?(:user)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -142,7 +142,7 @@ class ConfirmationTest < Devise::IntegrationTest
|
||||
fill_in 'password', with: 'invalid'
|
||||
end
|
||||
|
||||
assert_contain 'Invalid Email or password'
|
||||
assert_contain 'Invalid email or password'
|
||||
refute warden.authenticated?(:user)
|
||||
end
|
||||
end
|
||||
@@ -175,6 +175,36 @@ class ConfirmationTest < Devise::IntegrationTest
|
||||
assert_current_url '/users/sign_in'
|
||||
end
|
||||
|
||||
test "should not be able to confirm an email with a blank confirmation token" do
|
||||
visit_user_confirmation_with_token("")
|
||||
|
||||
assert_contain "Confirmation token can't be blank"
|
||||
end
|
||||
|
||||
test "should not be able to confirm an email with a nil confirmation token" do
|
||||
visit_user_confirmation_with_token(nil)
|
||||
|
||||
assert_contain "Confirmation token can't be blank"
|
||||
end
|
||||
|
||||
test "should not be able to confirm user with blank confirmation token" do
|
||||
user = create_user(confirm: false)
|
||||
user.update_attribute(:confirmation_token, "")
|
||||
|
||||
visit_user_confirmation_with_token("")
|
||||
|
||||
assert_contain "Confirmation token can't be blank"
|
||||
end
|
||||
|
||||
test "should not be able to confirm user with nil confirmation token" do
|
||||
user = create_user(confirm: false)
|
||||
user.update_attribute(:confirmation_token, nil)
|
||||
|
||||
visit_user_confirmation_with_token(nil)
|
||||
|
||||
assert_contain "Confirmation token can't be blank"
|
||||
end
|
||||
|
||||
test 'error message is configurable by resource name' do
|
||||
store_translations :en, devise: {
|
||||
failure: { user: { unconfirmed: "Not confirmed user" } }
|
||||
@@ -263,7 +293,7 @@ class ConfirmationOnChangeTest < Devise::IntegrationTest
|
||||
|
||||
test 'admin should be able to request a new confirmation after email changed' do
|
||||
admin = create_admin
|
||||
admin.update_attributes(email: 'new_test@example.com')
|
||||
admin.update(email: 'new_test@example.com')
|
||||
|
||||
visit new_admin_session_path
|
||||
click_link "Didn't receive confirmation instructions?"
|
||||
@@ -279,7 +309,7 @@ class ConfirmationOnChangeTest < Devise::IntegrationTest
|
||||
|
||||
test 'admin with valid confirmation token should be able to confirm email after email changed' do
|
||||
admin = create_admin
|
||||
admin.update_attributes(email: 'new_test@example.com')
|
||||
admin.update(email: 'new_test@example.com')
|
||||
assert_equal 'new_test@example.com', admin.unconfirmed_email
|
||||
visit_admin_confirmation_with_token(admin.raw_confirmation_token)
|
||||
|
||||
@@ -291,13 +321,13 @@ class ConfirmationOnChangeTest < Devise::IntegrationTest
|
||||
|
||||
test 'admin with previously valid confirmation token should not be able to confirm email after email changed again' do
|
||||
admin = create_admin
|
||||
admin.update_attributes(email: 'first_test@example.com')
|
||||
admin.update(email: 'first_test@example.com')
|
||||
assert_equal 'first_test@example.com', admin.unconfirmed_email
|
||||
|
||||
raw_confirmation_token = admin.raw_confirmation_token
|
||||
admin = Admin.find(admin.id)
|
||||
|
||||
admin.update_attributes(email: 'second_test@example.com')
|
||||
admin.update(email: 'second_test@example.com')
|
||||
assert_equal 'second_test@example.com', admin.unconfirmed_email
|
||||
|
||||
visit_admin_confirmation_with_token(raw_confirmation_token)
|
||||
@@ -313,7 +343,7 @@ class ConfirmationOnChangeTest < Devise::IntegrationTest
|
||||
|
||||
test 'admin email should be unique also within unconfirmed_email' do
|
||||
admin = create_admin
|
||||
admin.update_attributes(email: 'new_admin_test@example.com')
|
||||
admin.update(email: 'new_admin_test@example.com')
|
||||
assert_equal 'new_admin_test@example.com', admin.unconfirmed_email
|
||||
|
||||
create_second_admin(email: "new_admin_test@example.com")
|
||||
|
||||
@@ -70,10 +70,23 @@ class DatabaseAuthenticationTest < Devise::IntegrationTest
|
||||
fill_in 'password', with: 'abcdef'
|
||||
end
|
||||
|
||||
assert_contain 'Invalid Email or password'
|
||||
assert_contain 'Invalid email or password'
|
||||
refute warden.authenticated?(:admin)
|
||||
end
|
||||
|
||||
test 'when in paranoid mode and without a valid e-mail' do
|
||||
swap Devise, paranoid: true do
|
||||
store_translations :en, devise: { failure: { not_found_in_database: 'Not found in database' } } do
|
||||
sign_in_as_user do
|
||||
fill_in 'email', with: 'wrongemail@test.com'
|
||||
end
|
||||
|
||||
assert_not_contain 'Not found in database'
|
||||
assert_contain 'Invalid email or password.'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
test 'error message is configurable by resource name' do
|
||||
store_translations :en, devise: { failure: { admin: { invalid: "Invalid credentials" } } } do
|
||||
sign_in_as_admin do
|
||||
|
||||
@@ -52,7 +52,7 @@ class HttpAuthenticationTest < Devise::IntegrationTest
|
||||
sign_in_as_new_user_with_http("unknown")
|
||||
assert_equal 401, status
|
||||
assert_equal "application/xml; charset=utf-8", headers["Content-Type"]
|
||||
assert_match "<error>Invalid Email or password.</error>", response.body
|
||||
assert_match "<error>Invalid email or password.</error>", response.body
|
||||
end
|
||||
|
||||
test 'returns a custom response with www-authenticate and chosen realm' do
|
||||
|
||||
@@ -104,7 +104,7 @@ class LockTest < Devise::IntegrationTest
|
||||
|
||||
test 'error message is configurable by resource name' do
|
||||
store_translations :en, devise: {
|
||||
failure: {user: {locked: "You are locked!"}}
|
||||
failure: {user: {locked: { both: "You are locked!" }}}
|
||||
} do
|
||||
|
||||
user = create_user(locked: true)
|
||||
@@ -118,7 +118,7 @@ class LockTest < Devise::IntegrationTest
|
||||
|
||||
test "user should not be able to sign in when locked" do
|
||||
store_translations :en, devise: {
|
||||
failure: {user: {locked: "You are locked!"}}
|
||||
failure: {user: {locked: {both: "You are locked!"}}}
|
||||
} do
|
||||
|
||||
user = create_user(locked: true)
|
||||
|
||||
@@ -2,10 +2,23 @@
|
||||
|
||||
require 'test_helper'
|
||||
|
||||
class MyMountableEngine
|
||||
def self.call(env)
|
||||
['200', { 'Content-Type' => 'text/html' }, ['Rendered content of MyMountableEngine']]
|
||||
module MyMountableEngine
|
||||
class Engine < ::Rails::Engine
|
||||
isolate_namespace MyMountableEngine
|
||||
end
|
||||
class TestsController < ActionController::Base
|
||||
def index
|
||||
render plain: 'Root test successful'
|
||||
end
|
||||
def inner_route
|
||||
render plain: 'Inner route test successful'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
MyMountableEngine::Engine.routes.draw do
|
||||
get 'test', to: 'tests#inner_route'
|
||||
root to: 'tests#index'
|
||||
end
|
||||
|
||||
# If disable_clear_and_finalize is set to true, Rails will not clear other routes when calling
|
||||
@@ -15,7 +28,7 @@ Rails.application.routes.disable_clear_and_finalize = true
|
||||
|
||||
Rails.application.routes.draw do
|
||||
authenticate(:user) do
|
||||
mount MyMountableEngine, at: '/mountable_engine'
|
||||
mount MyMountableEngine::Engine, at: '/mountable_engine'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -33,6 +46,23 @@ class AuthenticatedMountedEngineTest < Devise::IntegrationTest
|
||||
get '/mountable_engine'
|
||||
|
||||
assert_response :success
|
||||
assert_contain 'Rendered content of MyMountableEngine'
|
||||
assert_contain 'Root test successful'
|
||||
end
|
||||
|
||||
|
||||
test 'renders a inner route of the mounted engine when authenticated' do
|
||||
sign_in_as_user
|
||||
get '/mountable_engine/test'
|
||||
|
||||
assert_response :success
|
||||
assert_contain 'Inner route test successful'
|
||||
end
|
||||
|
||||
test 'respond properly to a non existing route of the mounted engine' do
|
||||
sign_in_as_user
|
||||
|
||||
assert_raise ActionController::RoutingError do
|
||||
get '/mountable_engine/non-existing-route'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -152,6 +152,19 @@ class PasswordTest < Devise::IntegrationTest
|
||||
refute user.reload.valid_password?('987654321')
|
||||
end
|
||||
|
||||
test 'not authenticated user with expired reset password token should be redirected to new password path' do
|
||||
user = create_user
|
||||
request_forgot_password
|
||||
user.update(reset_password_sent_at: Time.now - 1.year)
|
||||
|
||||
visit edit_user_password_path(reset_password_token: 'abcdef')
|
||||
fill_in 'New password', with: '987654321'
|
||||
fill_in 'Confirm new password', with: '987654321'
|
||||
click_button 'Change my password'
|
||||
|
||||
assert_contain 'The password recovery link expired. Please request a new one.'
|
||||
end
|
||||
|
||||
test 'not authenticated user with valid reset password token but invalid password should not be able to change their password' do
|
||||
user = create_user
|
||||
request_forgot_password
|
||||
|
||||
@@ -179,6 +179,39 @@ class RegistrationTest < Devise::IntegrationTest
|
||||
assert warden.authenticated?(:user)
|
||||
end
|
||||
|
||||
test 'a signed in user should not be able to use the website after changing their password if config.sign_in_after_change_password is false' do
|
||||
swap Devise, sign_in_after_change_password: false do
|
||||
sign_in_as_user
|
||||
get edit_user_registration_path
|
||||
|
||||
fill_in 'password', with: '1234567890'
|
||||
fill_in 'password confirmation', with: '1234567890'
|
||||
fill_in 'current password', with: '12345678'
|
||||
click_button 'Update'
|
||||
|
||||
assert_contain 'Your account has been updated successfully, but since your password was changed, you need to sign in again'
|
||||
assert_equal new_user_session_path, @request.path
|
||||
refute warden.authenticated?(:user)
|
||||
end
|
||||
end
|
||||
|
||||
test 'a signed in user should be able to use the website after changing its email with config.sign_in_after_change_password is false' do
|
||||
swap Devise, sign_in_after_change_password: false do
|
||||
sign_in_as_user
|
||||
get edit_user_registration_path
|
||||
|
||||
fill_in 'email', with: 'user.new@example.com'
|
||||
fill_in 'current password', with: '12345678'
|
||||
click_button 'Update'
|
||||
|
||||
assert_current_url '/'
|
||||
assert_contain 'Your account has been updated successfully.'
|
||||
|
||||
assert warden.authenticated?(:user)
|
||||
assert_equal "user.new@example.com", User.to_adapter.find_first.email
|
||||
end
|
||||
end
|
||||
|
||||
test 'a signed in user should not change their current user with invalid password' do
|
||||
sign_in_as_user
|
||||
get edit_user_registration_path
|
||||
|
||||
@@ -12,12 +12,10 @@ class RememberMeTest < Devise::IntegrationTest
|
||||
end
|
||||
|
||||
def generate_signed_cookie(raw_cookie)
|
||||
request = if Devise::Test.rails51? || Devise::Test.rails52?
|
||||
request = if Devise::Test.rails51? || Devise::Test.rails52_and_up?
|
||||
ActionController::TestRequest.create(Class.new) # needs a "controller class"
|
||||
elsif Devise::Test.rails5?
|
||||
ActionController::TestRequest.create
|
||||
else
|
||||
ActionController::TestRequest.new
|
||||
ActionController::TestRequest.create
|
||||
end
|
||||
request.cookie_jar.signed['raw_cookie'] = raw_cookie
|
||||
request.cookie_jar['raw_cookie']
|
||||
|
||||
@@ -95,5 +95,4 @@ class TrackableHooksTest < Devise::IntegrationTest
|
||||
user.reload
|
||||
assert_equal 1, user.sign_in_count
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -19,7 +19,7 @@ class EmailChangedTest < ActionMailer::TestCase
|
||||
def user
|
||||
@user ||= create_user.tap { |u|
|
||||
@original_user_email = u.email
|
||||
u.update_attributes!(email: 'new-email@example.com')
|
||||
u.update!(email: 'new-email@example.com')
|
||||
}
|
||||
end
|
||||
|
||||
@@ -108,7 +108,7 @@ class EmailChangedReconfirmationTest < ActionMailer::TestCase
|
||||
def admin
|
||||
@admin ||= create_admin.tap { |u|
|
||||
@original_admin_email = u.email
|
||||
u.update_attributes!(email: 'new-email@example.com')
|
||||
u.update!(email: 'new-email@example.com')
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
@@ -13,6 +13,31 @@ class AuthenticatableTest < ActiveSupport::TestCase
|
||||
assert_nil User.find_first_by_auth_conditions({ email: "example@example.com" }, id: user.id.to_s.next)
|
||||
end
|
||||
|
||||
# assumes default configuration of
|
||||
# config.case_insensitive_keys = [:email]
|
||||
# config.strip_whitespace_keys = [:email]
|
||||
test 'find_or_initialize_with_errors uses parameter filter on find' do
|
||||
user = User.create!(email: "example@example.com", password: "1234567")
|
||||
assert_equal User.find_or_initialize_with_errors([:email], { email: " EXAMPLE@example.com " }), user
|
||||
end
|
||||
|
||||
# assumes default configuration of
|
||||
# config.case_insensitive_keys = [:email]
|
||||
# config.strip_whitespace_keys = [:email]
|
||||
test 'find_or_initialize_with_errors uses parameter filter on initialize' do
|
||||
assert_equal User.find_or_initialize_with_errors([:email], { email: " EXAMPLE@example.com " }).email, "example@example.com"
|
||||
end
|
||||
|
||||
test 'find_or_initialize_with_errors adds blank error' do
|
||||
user_with_error = User.find_or_initialize_with_errors([:email], { email: "" })
|
||||
assert_equal [:email, "can't be blank"], user_with_error.errors.first
|
||||
end
|
||||
|
||||
test 'find_or_initialize_with_errors adds invalid error' do
|
||||
user_with_error = User.find_or_initialize_with_errors([:email], { email: "example@example.com" })
|
||||
assert_equal [:email, "is invalid"], user_with_error.errors.first
|
||||
end
|
||||
|
||||
if defined?(ActionController::Parameters)
|
||||
test 'does not passes an ActionController::Parameters to find_first_by_auth_conditions through find_or_initialize_with_errors' do
|
||||
user = create_user(email: 'example@example.com')
|
||||
|
||||
@@ -77,6 +77,24 @@ class ConfirmableTest < ActiveSupport::TestCase
|
||||
assert_equal "can't be blank", confirmed_user.errors[:confirmation_token].join
|
||||
end
|
||||
|
||||
test 'should return a new record with errors when a blank token is given and a record exists on the database' do
|
||||
user = create_user(confirmation_token: '')
|
||||
|
||||
confirmed_user = User.confirm_by_token('')
|
||||
|
||||
refute user.reload.confirmed?
|
||||
assert_equal "can't be blank", confirmed_user.errors[:confirmation_token].join
|
||||
end
|
||||
|
||||
test 'should return a new record with errors when a nil token is given and a record exists on the database' do
|
||||
user = create_user(confirmation_token: nil)
|
||||
|
||||
confirmed_user = User.confirm_by_token(nil)
|
||||
|
||||
refute user.reload.confirmed?
|
||||
assert_equal "can't be blank", confirmed_user.errors[:confirmation_token].join
|
||||
end
|
||||
|
||||
test 'should generate errors for a user email if user is already confirmed' do
|
||||
user = create_user
|
||||
user.confirmed_at = Time.now
|
||||
@@ -240,6 +258,16 @@ class ConfirmableTest < ActiveSupport::TestCase
|
||||
refute user.active_for_authentication?
|
||||
end
|
||||
|
||||
test 'should not be active when confirm period is set to 0 days' do
|
||||
Devise.allow_unconfirmed_access_for = 0.days
|
||||
user = create_user
|
||||
|
||||
Timecop.freeze(Time.zone.today) do
|
||||
user.confirmation_sent_at = Time.zone.today
|
||||
refute user.active_for_authentication?
|
||||
end
|
||||
end
|
||||
|
||||
test 'should be active when we set allow_unconfirmed_access_for to nil' do
|
||||
swap Devise, allow_unconfirmed_access_for: nil do
|
||||
user = create_user
|
||||
@@ -372,7 +400,7 @@ class ReconfirmableTest < ActiveSupport::TestCase
|
||||
admin = create_admin
|
||||
assert admin.confirm
|
||||
residual_token = admin.confirmation_token
|
||||
assert admin.update_attributes(email: 'new_test@example.com')
|
||||
assert admin.update(email: 'new_test@example.com')
|
||||
assert_not_equal residual_token, admin.confirmation_token
|
||||
end
|
||||
|
||||
@@ -381,7 +409,7 @@ class ReconfirmableTest < ActiveSupport::TestCase
|
||||
original_token = admin.confirmation_token
|
||||
assert admin.confirm
|
||||
admin.skip_reconfirmation!
|
||||
assert admin.update_attributes(email: 'new_test@example.com')
|
||||
assert admin.update(email: 'new_test@example.com')
|
||||
assert admin.confirmed?
|
||||
refute admin.pending_reconfirmation?
|
||||
assert_equal original_token, admin.confirmation_token
|
||||
@@ -392,16 +420,16 @@ class ReconfirmableTest < ActiveSupport::TestCase
|
||||
admin.skip_confirmation_notification!
|
||||
|
||||
assert_email_not_sent do
|
||||
admin.update_attributes(email: 'new_test@example.com')
|
||||
admin.update(email: 'new_test@example.com')
|
||||
end
|
||||
end
|
||||
|
||||
test 'should regenerate confirmation token after changing email' do
|
||||
admin = create_admin
|
||||
assert admin.confirm
|
||||
assert admin.update_attributes(email: 'old_test@example.com')
|
||||
assert admin.update(email: 'old_test@example.com')
|
||||
token = admin.confirmation_token
|
||||
assert admin.update_attributes(email: 'new_test@example.com')
|
||||
assert admin.update(email: 'new_test@example.com')
|
||||
assert_not_equal token, admin.confirmation_token
|
||||
end
|
||||
|
||||
@@ -409,7 +437,7 @@ class ReconfirmableTest < ActiveSupport::TestCase
|
||||
admin = create_admin
|
||||
assert admin.confirm
|
||||
assert_email_sent "new_test@example.com" do
|
||||
assert admin.update_attributes(email: 'new_test@example.com')
|
||||
assert admin.update(email: 'new_test@example.com')
|
||||
end
|
||||
assert_match "new_test@example.com", ActionMailer::Base.deliveries.last.body.encoded
|
||||
end
|
||||
@@ -417,7 +445,7 @@ class ReconfirmableTest < ActiveSupport::TestCase
|
||||
test 'should send confirmation instructions by email after changing email from nil' do
|
||||
admin = create_admin(email: nil)
|
||||
assert_email_sent "new_test@example.com" do
|
||||
assert admin.update_attributes(email: 'new_test@example.com')
|
||||
assert admin.update(email: 'new_test@example.com')
|
||||
end
|
||||
assert_match "new_test@example.com", ActionMailer::Base.deliveries.last.body.encoded
|
||||
end
|
||||
@@ -426,7 +454,7 @@ class ReconfirmableTest < ActiveSupport::TestCase
|
||||
admin = create_admin
|
||||
assert admin.confirm
|
||||
assert_email_not_sent do
|
||||
assert admin.update_attributes(password: 'newpass', password_confirmation: 'newpass')
|
||||
assert admin.update(password: 'newpass', password_confirmation: 'newpass')
|
||||
end
|
||||
end
|
||||
|
||||
@@ -442,14 +470,14 @@ class ReconfirmableTest < ActiveSupport::TestCase
|
||||
test 'should stay confirmed when email is changed' do
|
||||
admin = create_admin
|
||||
assert admin.confirm
|
||||
assert admin.update_attributes(email: 'new_test@example.com')
|
||||
assert admin.update(email: 'new_test@example.com')
|
||||
assert admin.confirmed?
|
||||
end
|
||||
|
||||
test 'should update email only when it is confirmed' do
|
||||
admin = create_admin
|
||||
assert admin.confirm
|
||||
assert admin.update_attributes(email: 'new_test@example.com')
|
||||
assert admin.update(email: 'new_test@example.com')
|
||||
assert_not_equal 'new_test@example.com', admin.email
|
||||
assert admin.confirm
|
||||
assert_equal 'new_test@example.com', admin.email
|
||||
@@ -458,16 +486,16 @@ class ReconfirmableTest < ActiveSupport::TestCase
|
||||
test 'should not allow admin to get past confirmation email by resubmitting their new address' do
|
||||
admin = create_admin
|
||||
assert admin.confirm
|
||||
assert admin.update_attributes(email: 'new_test@example.com')
|
||||
assert admin.update(email: 'new_test@example.com')
|
||||
assert_not_equal 'new_test@example.com', admin.email
|
||||
assert admin.update_attributes(email: 'new_test@example.com')
|
||||
assert admin.update(email: 'new_test@example.com')
|
||||
assert_not_equal 'new_test@example.com', admin.email
|
||||
end
|
||||
|
||||
test 'should find a admin by send confirmation instructions with unconfirmed_email' do
|
||||
admin = create_admin
|
||||
assert admin.confirm
|
||||
assert admin.update_attributes(email: 'new_test@example.com')
|
||||
assert admin.update(email: 'new_test@example.com')
|
||||
confirmation_admin = Admin.send_confirmation_instructions(email: admin.unconfirmed_email)
|
||||
assert_equal confirmation_admin, admin
|
||||
end
|
||||
@@ -536,7 +564,7 @@ class ReconfirmableTest < ActiveSupport::TestCase
|
||||
original_email = admin.email
|
||||
|
||||
assert_difference 'ActionMailer::Base.deliveries.size', 2 do
|
||||
assert admin.update_attributes(email: 'new-email@example.com')
|
||||
assert admin.update(email: 'new-email@example.com')
|
||||
end
|
||||
assert_equal original_email, ActionMailer::Base.deliveries[-2]['to'].to_s
|
||||
assert_equal 'new-email@example.com', ActionMailer::Base.deliveries[-1]['to'].to_s
|
||||
|
||||
@@ -88,6 +88,13 @@ class DatabaseAuthenticatableTest < ActiveSupport::TestCase
|
||||
assert_equal( {'strip_whitespace' => 'strip_whitespace_val', 'do_not_strip_whitespace' => ' do_not_strip_whitespace_val '}, conditions )
|
||||
end
|
||||
|
||||
test 'param filter should not add keys to filtered hash' do
|
||||
conditions = { 'present' => 'present_val' }
|
||||
conditions.default = ''
|
||||
conditions = Devise::ParameterFilter.new(['not_present'], []).filter(conditions)
|
||||
assert_equal({ 'present' => 'present_val' }, conditions)
|
||||
end
|
||||
|
||||
test 'should respond to password and password confirmation' do
|
||||
user = new_user
|
||||
assert user.respond_to?(:password)
|
||||
@@ -234,7 +241,7 @@ class DatabaseAuthenticatableTest < ActiveSupport::TestCase
|
||||
test 'should not email on password change' do
|
||||
user = create_user
|
||||
assert_email_not_sent do
|
||||
assert user.update_attributes(password: 'newpass', password_confirmation: 'newpass')
|
||||
assert user.update(password: 'newpass', password_confirmation: 'newpass')
|
||||
end
|
||||
end
|
||||
|
||||
@@ -243,7 +250,7 @@ class DatabaseAuthenticatableTest < ActiveSupport::TestCase
|
||||
user = create_user
|
||||
original_email = user.email
|
||||
assert_email_sent original_email do
|
||||
assert user.update_attributes(email: 'new-email@example.com')
|
||||
assert user.update(email: 'new-email@example.com')
|
||||
end
|
||||
assert_match original_email, ActionMailer::Base.deliveries.last.body.encoded
|
||||
end
|
||||
@@ -253,12 +260,32 @@ class DatabaseAuthenticatableTest < ActiveSupport::TestCase
|
||||
swap Devise, send_password_change_notification: true do
|
||||
user = create_user
|
||||
assert_email_sent user.email do
|
||||
assert user.update_attributes(password: 'newpass', password_confirmation: 'newpass')
|
||||
assert user.update(password: 'newpass', password_confirmation: 'newpass')
|
||||
end
|
||||
assert_match user.email, ActionMailer::Base.deliveries.last.body.encoded
|
||||
end
|
||||
end
|
||||
|
||||
test 'should not notify email on password change even when configured if skip_password_change_notification! is invoked' do
|
||||
swap Devise, send_password_change_notification: true do
|
||||
user = create_user
|
||||
user.skip_password_change_notification!
|
||||
assert_email_not_sent do
|
||||
assert user.update(password: 'newpass', password_confirmation: 'newpass')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
test 'should not notify email on email change even when configured if skip_email_changed_notification! is invoked' do
|
||||
swap Devise, send_email_changed_notification: true do
|
||||
user = create_user
|
||||
user.skip_email_changed_notification!
|
||||
assert_email_not_sent do
|
||||
assert user.update(email: 'new-email@example.com')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
test 'downcase_keys with validation' do
|
||||
User.create(email: "HEllO@example.com", password: "123456")
|
||||
user = User.create(email: "HEllO@example.com", password: "123456")
|
||||
|
||||
@@ -39,6 +39,17 @@ class LockableTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
test "should read failed_attempts from database when incrementing" do
|
||||
user = create_user
|
||||
initial_failed_attempts = user.failed_attempts
|
||||
same_user = User.find(user.id)
|
||||
|
||||
user.increment_failed_attempts
|
||||
same_user.increment_failed_attempts
|
||||
|
||||
assert_equal initial_failed_attempts + 2, user.reload.failed_attempts
|
||||
end
|
||||
|
||||
test 'should be valid for authentication with a unlocked user' do
|
||||
user = create_user
|
||||
user.lock_access!
|
||||
@@ -301,7 +312,7 @@ class LockableTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
test 'should return last attempt message if user made next-to-last attempt of password entering' do
|
||||
swap Devise, last_attempt_warning: true, lock_strategy: :failed_attempts do
|
||||
swap Devise, last_attempt_warning: true, lock_strategy: :failed_attempts, unlock_strategy: :none do
|
||||
user = create_user
|
||||
user.failed_attempts = Devise.maximum_attempts - 2
|
||||
assert_equal :invalid, user.unauthenticated_message
|
||||
@@ -310,7 +321,7 @@ class LockableTest < ActiveSupport::TestCase
|
||||
assert_equal :last_attempt, user.unauthenticated_message
|
||||
|
||||
user.failed_attempts = Devise.maximum_attempts
|
||||
assert_equal :locked, user.unauthenticated_message
|
||||
assert_equal :'locked.none', user.unauthenticated_message
|
||||
end
|
||||
end
|
||||
|
||||
@@ -325,7 +336,22 @@ class LockableTest < ActiveSupport::TestCase
|
||||
test 'should return locked message if user was programatically locked' do
|
||||
user = create_user
|
||||
user.lock_access!
|
||||
assert_equal :locked, user.unauthenticated_message
|
||||
|
||||
swap Devise, unlock_strategy: :none do
|
||||
assert_equal :'locked.none', user.unauthenticated_message
|
||||
end
|
||||
|
||||
swap Devise, unlock_strategy: :both do
|
||||
assert_equal :'locked.both', user.unauthenticated_message
|
||||
end
|
||||
|
||||
swap Devise, unlock_strategy: :email do
|
||||
assert_equal :'locked.email', user.unauthenticated_message
|
||||
end
|
||||
|
||||
swap Devise, unlock_strategy: :time do
|
||||
assert_equal :'locked.time', user.unauthenticated_message
|
||||
end
|
||||
end
|
||||
|
||||
test 'unlock_strategy_enabled? should return true for both, email, and time strategies if :both is used' do
|
||||
|
||||
@@ -59,4 +59,55 @@ class TrackableTest < ActiveSupport::TestCase
|
||||
|
||||
assert_not user.update_tracked_fields!(request)
|
||||
end
|
||||
|
||||
test "update_tracked_fields! runs when isn't a new record and the validations are ok" do
|
||||
user = create_user
|
||||
user.stubs(:active_for_authentication?).returns(true)
|
||||
|
||||
request = mock
|
||||
request.stubs(:remote_ip).returns("127.0.0.1")
|
||||
request.stubs(:env).returns('devise.skip_trackable' => nil)
|
||||
|
||||
assert user.update_tracked_fields!(request)
|
||||
end
|
||||
|
||||
test "update_tracked_fields! should not run when skip trackable is turned on" do
|
||||
user = create_user
|
||||
user.stubs(:active_for_authentication?).returns(true)
|
||||
|
||||
request = mock
|
||||
request.stubs(:remote_ip).returns("127.0.0.1")
|
||||
request.stubs(:env).returns('devise.skip_trackable' => 1)
|
||||
|
||||
assert_not user.update_tracked_fields!(request)
|
||||
end
|
||||
|
||||
test "update_tracked_fields! should not run when the user is not active for authentication" do
|
||||
user = create_user
|
||||
user.stubs(:active_for_authentication?).returns(false)
|
||||
|
||||
request = mock
|
||||
request.stubs(:remote_ip).returns("127.0.0.1")
|
||||
request.stubs(:env).returns('devise.skip_trackable' => nil)
|
||||
|
||||
assert_not user.update_tracked_fields!(request)
|
||||
end
|
||||
|
||||
test 'extract_ip_from should be overridable' do
|
||||
class UserWithOverride < User
|
||||
protected
|
||||
def extract_ip_from(request)
|
||||
"127.0.0.2"
|
||||
end
|
||||
end
|
||||
|
||||
request = mock
|
||||
request.stubs(:remote_ip).returns("127.0.0.1")
|
||||
user = UserWithOverride.new
|
||||
|
||||
user.update_tracked_fields(request)
|
||||
|
||||
assert_equal "127.0.0.2", user.current_sign_in_ip
|
||||
assert_equal "127.0.0.2", user.last_sign_in_ip
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,20 +5,16 @@ ActiveRecord::Base.logger = Logger.new(nil)
|
||||
ActiveRecord::Base.include_root_in_json = true
|
||||
|
||||
migrate_path = File.expand_path("../../rails_app/db/migrate/", __FILE__)
|
||||
if Devise::Test.rails52?
|
||||
if Devise::Test.rails6?
|
||||
ActiveRecord::MigrationContext.new(migrate_path, ActiveRecord::SchemaMigration).migrate
|
||||
elsif Devise::Test.rails52_and_up?
|
||||
ActiveRecord::MigrationContext.new(migrate_path).migrate
|
||||
else
|
||||
ActiveRecord::Migrator.migrate(migrate_path)
|
||||
end
|
||||
|
||||
class ActiveSupport::TestCase
|
||||
if Devise::Test.rails5?
|
||||
self.use_transactional_tests = true
|
||||
else
|
||||
# Let `after_commit` work with transactional fixtures, however this is not needed for Rails 5.
|
||||
require 'test_after_commit'
|
||||
self.use_transactional_fixtures = true
|
||||
end
|
||||
self.use_transactional_tests = true
|
||||
|
||||
self.use_instantiated_fixtures = false
|
||||
end
|
||||
|
||||
@@ -16,6 +16,34 @@ class ParameterSanitizerTest < ActiveSupport::TestCase
|
||||
assert_equal({ 'email' => 'jose' }, sanitized)
|
||||
end
|
||||
|
||||
test 'permits empty params when received not a hash' do
|
||||
sanitizer = sanitizer({ 'user' => 'string' })
|
||||
sanitized = sanitizer.sanitize(:sign_in)
|
||||
|
||||
assert_equal({}, sanitized)
|
||||
end
|
||||
|
||||
test 'does not rise error when received string instead of hash' do
|
||||
sanitizer = sanitizer('user' => 'string')
|
||||
assert_nothing_raised do
|
||||
sanitizer.sanitize(:sign_in)
|
||||
end
|
||||
end
|
||||
|
||||
test 'does not rise error when received nil instead of hash' do
|
||||
sanitizer = sanitizer('user' => nil)
|
||||
assert_nothing_raised do
|
||||
sanitizer.sanitize(:sign_in)
|
||||
end
|
||||
end
|
||||
|
||||
test 'permits empty params when received nil instead of hash' do
|
||||
sanitizer = sanitizer({ 'user' => nil })
|
||||
sanitized = sanitizer.sanitize(:sign_in)
|
||||
|
||||
assert_equal({}, sanitized)
|
||||
end
|
||||
|
||||
test 'permits the default parameters for sign up' do
|
||||
sanitizer = sanitizer('user' => { 'email' => 'jose', 'role' => 'invalid' })
|
||||
sanitized = sanitizer.sanitize(:sign_up)
|
||||
|
||||
@@ -5,7 +5,7 @@ require 'shared_user'
|
||||
class User < ActiveRecord::Base
|
||||
include Shim
|
||||
include SharedUser
|
||||
include ActiveModel::Serializers::Xml if Devise::Test.rails5?
|
||||
include ActiveModel::Serializers::Xml
|
||||
|
||||
validates :sign_in_count, presence: true
|
||||
|
||||
|
||||
@@ -22,10 +22,6 @@ class HomeController < ApplicationController
|
||||
end
|
||||
|
||||
def unauthenticated
|
||||
if Devise::Test.rails5?
|
||||
render body: "unauthenticated", status: :unauthorized
|
||||
else
|
||||
render text: "unauthenticated", status: :unauthorized
|
||||
end
|
||||
render body: "unauthenticated", status: :unauthorized
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,6 +11,6 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
||||
user = User.to_adapter.find_first(email: 'user@test.com')
|
||||
user.remember_me = true
|
||||
sign_in user
|
||||
render (Devise::Test.rails5? ? :body : :text) => ""
|
||||
render body: ""
|
||||
end
|
||||
end
|
||||
|
||||
@@ -15,7 +15,7 @@ class UsersController < ApplicationController
|
||||
end
|
||||
|
||||
def update_form
|
||||
render (Devise::Test.rails5? ? :body : :text) => 'Update'
|
||||
render body: 'Update'
|
||||
end
|
||||
|
||||
def accept
|
||||
@@ -23,11 +23,11 @@ class UsersController < ApplicationController
|
||||
end
|
||||
|
||||
def exhibit
|
||||
render (Devise::Test.rails5? ? :body : :text) => current_user ? "User is authenticated" : "User is not authenticated"
|
||||
render body: current_user ? "User is authenticated" : "User is not authenticated"
|
||||
end
|
||||
|
||||
def expire
|
||||
user_session['last_request_at'] = 31.minutes.ago.utc
|
||||
render (Devise::Test.rails5? ? :body : :text) => 'User will be expired on next request'
|
||||
render body: 'User will be expired on next request'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
Welcome to "sessions/new" view!
|
||||
<%= render file: "devise/sessions/new" %>
|
||||
<%= render template: "devise/sessions/new" %>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user