mirror of
https://github.com/heartcombo/devise.git
synced 2026-01-10 16:18:04 -05:00
Compare commits
141 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3926e6d9eb | ||
|
|
506eaf495d | ||
|
|
8dbe5b2fe8 | ||
|
|
207ddc5127 | ||
|
|
367ea42762 | ||
|
|
89a08357d6 | ||
|
|
eed51179c7 | ||
|
|
232c855c54 | ||
|
|
afec6655c7 | ||
|
|
7d1dc56fdb | ||
|
|
890bd9e3b5 | ||
|
|
1e63c640c0 | ||
|
|
8acbdd6d93 | ||
|
|
400eaf7fbe | ||
|
|
df8b79a53f | ||
|
|
ef6c73b221 | ||
|
|
c7a719a979 | ||
|
|
60c5774ff4 | ||
|
|
90f46bac37 | ||
|
|
ee8f0f8e83 | ||
|
|
41e2db2120 | ||
|
|
7f419bf99a | ||
|
|
44f0fd741f | ||
|
|
2d655ea46e | ||
|
|
49ed129c40 | ||
|
|
8e2e3f6fda | ||
|
|
31c4f31ef4 | ||
|
|
8606e1e671 | ||
|
|
2df5efcece | ||
|
|
43c349a2fc | ||
|
|
0d392fa49f | ||
|
|
d0f0853c75 | ||
|
|
88625d488f | ||
|
|
f08e0ad24a | ||
|
|
3632ddf674 | ||
|
|
cddba28945 | ||
|
|
032c4476ae | ||
|
|
319d9fa648 | ||
|
|
59bedaa1e7 | ||
|
|
fc1ac76ddf | ||
|
|
6d32d2447c | ||
|
|
d4bf52bdfd | ||
|
|
f8d1ea90bc | ||
|
|
2fa9303ab3 | ||
|
|
b5172a0cdb | ||
|
|
e1c53d6580 | ||
|
|
875217d8c1 | ||
|
|
55eabee800 | ||
|
|
8d4c3647a7 | ||
|
|
700284fc67 | ||
|
|
1542b7da29 | ||
|
|
451ff6d49c | ||
|
|
542df3634b | ||
|
|
3c5acaf531 | ||
|
|
025b1c8734 | ||
|
|
43800b4b85 | ||
|
|
baf5e00544 | ||
|
|
289dd5f221 | ||
|
|
9f5b83750e | ||
|
|
8593801130 | ||
|
|
bb879f7154 | ||
|
|
772b74a657 | ||
|
|
51bf327017 | ||
|
|
14eb1362e3 | ||
|
|
f3e8fd3baa | ||
|
|
a0ccc1cf96 | ||
|
|
b39faffde4 | ||
|
|
366a428b2c | ||
|
|
7d103bc627 | ||
|
|
bdd2e7e24f | ||
|
|
c82e4cf47b | ||
|
|
63ccdfb34a | ||
|
|
2ee0068d77 | ||
|
|
57d1a1d381 | ||
|
|
5d5636f03a | ||
|
|
a3ae35e9c9 | ||
|
|
e8e0c27599 | ||
|
|
429afcbe8a | ||
|
|
ef9a2f4104 | ||
|
|
0cd72a56f9 | ||
|
|
1ba53dc369 | ||
|
|
faef12cf2b | ||
|
|
c82a381f29 | ||
|
|
a793472a3e | ||
|
|
ad91686b62 | ||
|
|
1bb5fcbbec | ||
|
|
80423c8f01 | ||
|
|
743b6937e2 | ||
|
|
e16d60d0fe | ||
|
|
9d16f33c7b | ||
|
|
c9a0f896cc | ||
|
|
aa8d89579a | ||
|
|
210c62af38 | ||
|
|
3048fe0960 | ||
|
|
628f2fb2be | ||
|
|
13ba27497b | ||
|
|
7386f419e3 | ||
|
|
e07932c181 | ||
|
|
d0eafe70dc | ||
|
|
7e6da424e2 | ||
|
|
81bf3ad8c1 | ||
|
|
51c05a5b21 | ||
|
|
1d138dd40c | ||
|
|
c43ae8cb47 | ||
|
|
cd60c747cc | ||
|
|
837baaf2e1 | ||
|
|
e0395367e4 | ||
|
|
fb17e2755f | ||
|
|
f4462cd85e | ||
|
|
8bb358cf80 | ||
|
|
98fc5e8e39 | ||
|
|
dfbed22cee | ||
|
|
fd03f9e353 | ||
|
|
a19e78cdb4 | ||
|
|
b88af5d65e | ||
|
|
45b831c4ea | ||
|
|
f12be553cc | ||
|
|
4896a9b41a | ||
|
|
eed641d2be | ||
|
|
97aa37bb50 | ||
|
|
15135f7dc6 | ||
|
|
e39b9b9134 | ||
|
|
4a5e7a9143 | ||
|
|
8664bac682 | ||
|
|
3e588d2d25 | ||
|
|
23fbc35b2d | ||
|
|
2c844b0649 | ||
|
|
0c2cab7c94 | ||
|
|
2da46d8dd6 | ||
|
|
507573994a | ||
|
|
f26e05c200 | ||
|
|
f5cc775a5f | ||
|
|
b94b957490 | ||
|
|
057afdc1e6 | ||
|
|
c249ba991b | ||
|
|
ffa8a80f42 | ||
|
|
4f60544396 | ||
|
|
79d7eddfc3 | ||
|
|
b25492ea01 | ||
|
|
0e33f55b7d | ||
|
|
6991ff4eb4 |
169
.github/workflows/test.yml
vendored
Normal file
169
.github/workflows/test.yml
vendored
Normal file
@@ -0,0 +1,169 @@
|
||||
name: Test
|
||||
on: [push, pull_request]
|
||||
jobs:
|
||||
test:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
gemfile:
|
||||
- Gemfile
|
||||
- gemfiles/Gemfile-rails-main
|
||||
- gemfiles/Gemfile-rails-6-1
|
||||
- gemfiles/Gemfile-rails-6-0
|
||||
- gemfiles/Gemfile-rails-5-2
|
||||
- gemfiles/Gemfile-rails-5-1
|
||||
- gemfiles/Gemfile-rails-5-0
|
||||
- gemfiles/Gemfile-rails-4-2
|
||||
- gemfiles/Gemfile-rails-4-1
|
||||
ruby:
|
||||
- '3.2'
|
||||
- '3.1'
|
||||
- '3.0'
|
||||
- '2.7'
|
||||
- '2.6'
|
||||
- '2.5'
|
||||
- '2.4'
|
||||
- '2.3'
|
||||
- '2.2'
|
||||
- '2.1'
|
||||
env:
|
||||
- DEVISE_ORM=active_record
|
||||
- DEVISE_ORM=mongoid
|
||||
exclude:
|
||||
- gemfile: Gemfile
|
||||
ruby: '2.6'
|
||||
- gemfile: Gemfile
|
||||
ruby: '2.5'
|
||||
- gemfile: Gemfile
|
||||
ruby: '2.4'
|
||||
- gemfile: Gemfile
|
||||
ruby: '2.3'
|
||||
- gemfile: Gemfile
|
||||
ruby: '2.2'
|
||||
- gemfile: Gemfile
|
||||
ruby: '2.1'
|
||||
- gemfile: Gemfile
|
||||
env: DEVISE_ORM=mongoid
|
||||
- gemfile: gemfiles/Gemfile-rails-main
|
||||
ruby: '2.6'
|
||||
- gemfile: gemfiles/Gemfile-rails-main
|
||||
ruby: '2.5'
|
||||
- gemfile: gemfiles/Gemfile-rails-main
|
||||
ruby: '2.4'
|
||||
- gemfile: gemfiles/Gemfile-rails-main
|
||||
ruby: '2.3'
|
||||
- gemfile: gemfiles/Gemfile-rails-main
|
||||
ruby: '2.2'
|
||||
- gemfile: gemfiles/Gemfile-rails-main
|
||||
ruby: '2.1'
|
||||
- gemfile: gemfiles/Gemfile-rails-main
|
||||
env: DEVISE_ORM=mongoid
|
||||
- gemfile: gemfiles/Gemfile-rails-6-1
|
||||
ruby: '2.4'
|
||||
- gemfile: gemfiles/Gemfile-rails-6-1
|
||||
ruby: '2.3'
|
||||
- gemfile: gemfiles/Gemfile-rails-6-1
|
||||
ruby: '2.2'
|
||||
- gemfile: gemfiles/Gemfile-rails-6-1
|
||||
ruby: '2.1'
|
||||
- gemfile: gemfiles/Gemfile-rails-6-1
|
||||
env: DEVISE_ORM=mongoid
|
||||
- gemfile: gemfiles/Gemfile-rails-6-0
|
||||
ruby: '3.2'
|
||||
- gemfile: gemfiles/Gemfile-rails-6-0
|
||||
ruby: '3.1'
|
||||
- gemfile: gemfiles/Gemfile-rails-6-0
|
||||
ruby: '2.4'
|
||||
- gemfile: gemfiles/Gemfile-rails-6-0
|
||||
ruby: '2.3'
|
||||
- gemfile: gemfiles/Gemfile-rails-6-0
|
||||
ruby: '2.2'
|
||||
- gemfile: gemfiles/Gemfile-rails-6-0
|
||||
ruby: '2.1'
|
||||
- gemfile: gemfiles/Gemfile-rails-6-0
|
||||
env: DEVISE_ORM=mongoid
|
||||
- gemfile: gemfiles/Gemfile-rails-5-2
|
||||
ruby: '3.2'
|
||||
- gemfile: gemfiles/Gemfile-rails-5-2
|
||||
ruby: '3.1'
|
||||
- gemfile: gemfiles/Gemfile-rails-5-2
|
||||
ruby: '3.0'
|
||||
- gemfile: gemfiles/Gemfile-rails-5-2
|
||||
ruby: '2.7'
|
||||
- gemfile: gemfiles/Gemfile-rails-5-2
|
||||
ruby: '2.2'
|
||||
- gemfile: gemfiles/Gemfile-rails-5-2
|
||||
ruby: '2.1'
|
||||
- gemfile: gemfiles/Gemfile-rails-5-2
|
||||
env: DEVISE_ORM=mongoid
|
||||
- gemfile: gemfiles/Gemfile-rails-5-1
|
||||
ruby: '3.2'
|
||||
- gemfile: gemfiles/Gemfile-rails-5-1
|
||||
ruby: '3.1'
|
||||
- gemfile: gemfiles/Gemfile-rails-5-1
|
||||
ruby: '3.0'
|
||||
- gemfile: gemfiles/Gemfile-rails-5-1
|
||||
ruby: '2.7'
|
||||
- gemfile: gemfiles/Gemfile-rails-5-1
|
||||
ruby: '2.1'
|
||||
- gemfile: gemfiles/Gemfile-rails-5-1
|
||||
env: DEVISE_ORM=mongoid
|
||||
- gemfile: gemfiles/Gemfile-rails-5-0
|
||||
ruby: '3.2'
|
||||
- gemfile: gemfiles/Gemfile-rails-5-0
|
||||
ruby: '3.1'
|
||||
- gemfile: gemfiles/Gemfile-rails-5-0
|
||||
ruby: '3.0'
|
||||
- gemfile: gemfiles/Gemfile-rails-5-0
|
||||
ruby: '2.7'
|
||||
- gemfile: gemfiles/Gemfile-rails-5-0
|
||||
ruby: '2.1'
|
||||
- gemfile: gemfiles/Gemfile-rails-5-0
|
||||
env: DEVISE_ORM=mongoid
|
||||
- gemfile: gemfiles/Gemfile-rails-4-2
|
||||
ruby: '3.2'
|
||||
- gemfile: gemfiles/Gemfile-rails-4-2
|
||||
ruby: '3.1'
|
||||
- gemfile: gemfiles/Gemfile-rails-4-2
|
||||
ruby: '3.0'
|
||||
- gemfile: gemfiles/Gemfile-rails-4-2
|
||||
ruby: '2.7'
|
||||
- gemfile: gemfiles/Gemfile-rails-4-2
|
||||
ruby: '2.6'
|
||||
- gemfile: gemfiles/Gemfile-rails-4-1
|
||||
ruby: '3.2'
|
||||
- gemfile: gemfiles/Gemfile-rails-4-1
|
||||
ruby: '3.1'
|
||||
- gemfile: gemfiles/Gemfile-rails-4-1
|
||||
ruby: '3.0'
|
||||
- gemfile: gemfiles/Gemfile-rails-4-1
|
||||
ruby: '2.7'
|
||||
- gemfile: gemfiles/Gemfile-rails-4-1
|
||||
ruby: '2.6'
|
||||
- gemfile: gemfiles/Gemfile-rails-4-1
|
||||
ruby: '2.5'
|
||||
- gemfile: gemfiles/Gemfile-rails-4-1
|
||||
ruby: '2.4'
|
||||
runs-on: ubuntu-latest
|
||||
env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
|
||||
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup Bundler 1.x for Rails 4.x
|
||||
if: ${{ matrix.gemfile == 'gemfiles/Gemfile-rails-4-1' || matrix.gemfile == 'gemfiles/Gemfile-rails-4-2' }}
|
||||
run: echo "BUNDLER_VERSION=1.17.3" >> $GITHUB_ENV
|
||||
- name: Setup Rubygems version as default for Ruby < 2.5
|
||||
if: ${{ matrix.ruby < '2.5' }}
|
||||
run: echo "RUBYGEMS_VERSION=default" >> $GITHUB_ENV
|
||||
- name: Setup Rubygems version as 3.2.3 for Ruby 2.5
|
||||
if: ${{ matrix.ruby == '2.5' }}
|
||||
run: echo "RUBYGEMS_VERSION=3.2.3" >> $GITHUB_ENV
|
||||
- uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: ${{ matrix.ruby }}
|
||||
bundler-cache: true # runs bundle install and caches installed gems automatically
|
||||
bundler: ${{ env.BUNDLER_VERSION || 'default' }}
|
||||
rubygems: ${{ env.RUBYGEMS_VERSION || 'latest' }}
|
||||
- uses: supercharge/mongodb-github-action@1.3.0
|
||||
if: ${{ matrix.env == 'DEVISE_ORM=mongoid' }}
|
||||
- run: bundle exec rake
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -8,3 +8,4 @@ rdoc/*
|
||||
pkg
|
||||
log
|
||||
test/tmp/*
|
||||
gemfiles/*.lock
|
||||
|
||||
110
.travis.yml
110
.travis.yml
@@ -1,110 +0,0 @@
|
||||
language: ruby
|
||||
|
||||
rvm:
|
||||
- 2.1.10
|
||||
- 2.2.10
|
||||
- 2.3.8
|
||||
- 2.4.10
|
||||
- 2.5.8
|
||||
- 2.6.6
|
||||
- 2.7.1
|
||||
- ruby-head
|
||||
|
||||
gemfile:
|
||||
- Gemfile
|
||||
- gemfiles/Gemfile.rails-6.0-stable
|
||||
- gemfiles/Gemfile.rails-5.2-stable
|
||||
- gemfiles/Gemfile.rails-5.1-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-6.0-stable
|
||||
- rvm: 2.1.10
|
||||
gemfile: gemfiles/Gemfile.rails-5.2-stable
|
||||
- rvm: 2.1.10
|
||||
gemfile: gemfiles/Gemfile.rails-5.1-stable
|
||||
- rvm: 2.1.10
|
||||
gemfile: gemfiles/Gemfile.rails-5.0-stable
|
||||
- rvm: 2.2.10
|
||||
gemfile: Gemfile
|
||||
- rvm: 2.2.10
|
||||
gemfile: gemfiles/Gemfile.rails-6.0-stable
|
||||
- rvm: 2.2.10
|
||||
gemfile: gemfiles/Gemfile.rails-5.2-stable
|
||||
- rvm: 2.3.8
|
||||
gemfile: Gemfile
|
||||
- rvm: 2.3.8
|
||||
gemfile: gemfiles/Gemfile.rails-6.0-stable
|
||||
- rvm: 2.4.10
|
||||
gemfile: Gemfile
|
||||
- rvm: 2.4.10
|
||||
gemfile: gemfiles/Gemfile.rails-6.0-stable
|
||||
- rvm: 2.4.10
|
||||
gemfile: gemfiles/Gemfile.rails-4.1-stable
|
||||
- rvm: 2.5.8
|
||||
gemfile: gemfiles/Gemfile.rails-4.1-stable
|
||||
- rvm: 2.6.6
|
||||
gemfile: gemfiles/Gemfile.rails-4.1-stable
|
||||
- rvm: 2.6.6
|
||||
gemfile: gemfiles/Gemfile.rails-4.2-stable
|
||||
- rvm: 2.7.1
|
||||
gemfile: gemfiles/Gemfile.rails-4.1-stable
|
||||
- rvm: 2.7.1
|
||||
gemfile: gemfiles/Gemfile.rails-4.1-stable
|
||||
- rvm: 2.7.1
|
||||
gemfile: gemfiles/Gemfile.rails-4.2-stable
|
||||
- rvm: 2.7.1
|
||||
gemfile: gemfiles/Gemfile.rails-5.0-stable
|
||||
- rvm: 2.7.1
|
||||
gemfile: gemfiles/Gemfile.rails-5.1-stable
|
||||
- rvm: 2.7.1
|
||||
gemfile: gemfiles/Gemfile.rails-5.2-stable
|
||||
- rvm: ruby-head
|
||||
gemfile: gemfiles/Gemfile.rails-4.1-stable
|
||||
- rvm: ruby-head
|
||||
gemfile: gemfiles/Gemfile.rails-4.2-stable
|
||||
- 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.1-stable
|
||||
- env: DEVISE_ORM=mongoid
|
||||
gemfile: gemfiles/Gemfile.rails-5.2-stable
|
||||
- env: DEVISE_ORM=mongoid
|
||||
gemfile: gemfiles/Gemfile.rails-6.0-stable
|
||||
allow_failures:
|
||||
- rvm: ruby-head
|
||||
|
||||
services:
|
||||
- mongodb
|
||||
|
||||
cache: bundler
|
||||
|
||||
env:
|
||||
matrix:
|
||||
- DEVISE_ORM=active_record
|
||||
- DEVISE_ORM=mongoid
|
||||
|
||||
before_install:
|
||||
- gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
|
||||
- gem install bundler -v '< 2'
|
||||
- "rm ${BUNDLE_GEMFILE}.lock"
|
||||
|
||||
before_script: "bundle update"
|
||||
|
||||
script: "bin/test"
|
||||
|
||||
notifications:
|
||||
email: false
|
||||
slack:
|
||||
on_pull_requests: false
|
||||
on_success: change
|
||||
on_failure: always
|
||||
secure: Q3M+kmude3FjisibEeeGe0wSMXgvwLH+vL7Zrx9//q4QtkfnrQ/BBMvY9KXxPEsNF+eys4YopYjTkJ8uRmeboUATW/oQ4Jrv3+u3zkIHK2sFn/Q2cQWpK5w+CbgEnHPjKYnUu34b09njXTgDlr/mqtbPqrKeZ1dLlpKXCB/q4GY=
|
||||
70
CHANGELOG.md
70
CHANGELOG.md
@@ -1,4 +1,72 @@
|
||||
### 4.7.1 - 2020-06-10
|
||||
### Unreleased
|
||||
|
||||
|
||||
|
||||
### 4.9.1 - 2023-03-31
|
||||
|
||||
* enhancements
|
||||
* Allow resource class scopes to override the global configuration for `sign_in_after_reset_password` behaviour. [#5429](https://github.com/heartcombo/devise/pull/5429) [@mattr](https://github.com/mattr)
|
||||
* Refactor conditional dirty tracking logic to a centralized module to simplify usage throughout the codebase. [#5575](https://github.com/heartcombo/devise/pull/5575)
|
||||
* Improve support for Devise in apps with Active Record and Mongoid ORMs loaded, so it does not incorrectly uses new Active Record dirty tracking APIs with a Mongoid Devise model. [#5576](https://github.com/heartcombo/devise/pull/5576)
|
||||
|
||||
* bug fixes
|
||||
* Failure app will respond with configured `redirect_status` instead of `error_status` if the recall app returns a redirect status (300..399) [#5573](https://github.com/heartcombo/devise/pull/5573)
|
||||
* Fix frozen string exception in validatable. [#5563](https://github.com/heartcombo/devise/pull/5563) [#5465](https://github.com/heartcombo/devise/pull/5465) [@mameier](https://github.com/mameier)
|
||||
|
||||
### 4.9.0 - 2023-02-17
|
||||
|
||||
* enhancements
|
||||
* Add support for Ruby 3.1/3.2.
|
||||
* Add support for Hotwire + Turbo, default in Rails 7+.
|
||||
* Devise uses the latest `responders` version (v3.1.0 or higher), which allows configuring the status used for validation error responses (`error_status`) and for redirects after POST/PUT/PATCH/DELETE requests (`redirect_status`). For backwards compatibility, Devise keeps `error_status` as `:ok` which returns a `200 OK` response, and `redirect_status` to `:found` which returns a `302 Found` response, but you can configure it to return `422 Unprocessable Entity` and `303 See Other` respectively, to match the behavior expected by Hotwire/Turbo:
|
||||
|
||||
```ruby
|
||||
# config/initializers/devise.rb
|
||||
Devise.setup do |config|
|
||||
# ...
|
||||
config.responder.error_status = :unprocessable_entity
|
||||
config.responder.redirect_status = :see_other
|
||||
# ...
|
||||
end
|
||||
```
|
||||
|
||||
These configs are already generated by default with new apps, and existing apps may opt-in as described above. Trying to set these with an older version of `responders` will issue a warning and have no effect, so please upgrade the `responders` version if you're upgrading Devise for this integration. Note that these defaults may change in future versions of Devise, to better match the Rails + Hotwire/Turbo defaults across the board.
|
||||
* If you have a custom responder set on your application and expect it to affect Devise as well, you may need to override the Devise responder entirely with `config.responder = MyApplicationResponder`, so that it uses your custom one. The main reason Devise uses a custom responder is to be able to configure the statuses as described above, but you can also change that config on your own responder if you want. Check the `responders` readme for more info on that.
|
||||
* If you have created a custom responder and/or failure app just to customize responses for better Hotwire/Turbo integration, they should no longer be necessary.
|
||||
* `:turbo_stream` is now treated as a navigational format, so it works like HTML navigation when using Turbo. Note: if you relied on `:turbo_stream` to be treated as a non-navigational format before, you can reconfigure your `navigational_formats` in the Devise initializer file to exclude it.
|
||||
* OmniAuth "Sign in with" links were changed to buttons that generate HTML forms with method=POST, instead of using link + method=POST that required rails-ujs to work. Since rails-ujs is no longer the default for new Rails apps, this allows the OmniAuth buttons to work in any scenario, with or without rails-ujs and/or Turbo. This only affects apps that are using the default `devise/shared/_links.html.erb` partial from Devise with OmniAuth enabled.
|
||||
* The "Cancel my account" button was changed to include the `data-turbo-confirm` option, so that it works with both rails-ujs and Turbo by default.
|
||||
* Devise does not provide "sign out" links/buttons in its shared views, but if you're using `sign_out_via` with `:delete` (the default), and are using links with `method: :delete`, those need to be updated with `data: { turbo_method: :delete }` instead for Turbo.
|
||||
* Check [this upgrade guide](https://github.com/heartcombo/devise/wiki/How-To:-Upgrade-to-Devise-4.9.0-[Hotwire-Turbo-integration]) for more detailed information.
|
||||
|
||||
### 4.8.1 - 2021-12-16
|
||||
|
||||
* enhancements
|
||||
* Add support for Rails 7.0. Please note that Turbo integration is not fully supported by Devise yet.
|
||||
|
||||
### 4.8.0 - 2021-04-29
|
||||
|
||||
* enhancements
|
||||
* Devise now enables the upgrade of OmniAuth 2+. Previously Devise would raise an error if you'd try to upgrade. Please note that OmniAuth 2 is considered a security upgrade and recommended to everyone. You can read more about the details (and possible necessary changes to your app as part of the upgrade) in [their release notes](https://github.com/omniauth/omniauth/releases/tag/v2.0.0). [Devise's OmniAuth Overview wiki](https://github.com/heartcombo/devise/wiki/OmniAuth:-Overview) was also updated to cover OmniAuth 2.0 requirements.
|
||||
- Note that the upgrade required Devise shared links that initiate the OmniAuth flow to be changed to `method: :post`, which is now a requirement for OmniAuth, part of the security improvement. If you have copied and customized the Devise shared links partial to your app, or if you have other links in your app that initiate the OmniAuth flow, they will have to be updated to use `method: :post`, or changed to use buttons (e.g. `button_to`) to work with OmniAuth 2. (if you're using links with `method: :post`, make sure your app has `rails-ujs` or `jquery-ujs` included in order for these links to work properly.)
|
||||
- As part of the OmniAuth 2.0 upgrade you might also need to add the [`omniauth-rails_csrf_protection`](https://github.com/cookpad/omniauth-rails_csrf_protection) gem to your app if you don't have it already. (and you don't want to roll your own code to verify requests.) Check the OmniAuth v2 release notes for more info.
|
||||
* Introduce `Lockable#reset_failed_attempts!` model method to reset failed attempts counter to 0 after the user signs in.
|
||||
- This logic existed inside the lockable warden hook and is triggered automatically after the user signs in. The new model method is an extraction to allow you to override it in the application to implement things like switching to a write database if you're using the new multi-DB infrastructure from Rails for example, similar to how it's already possible with `Trackable#update_tracked_fields!`.
|
||||
* Add support for Ruby 3.
|
||||
* Add support for Rails 6.1.
|
||||
* Move CI to GitHub Actions.
|
||||
|
||||
* deprecations
|
||||
* `Devise::Models::Authenticatable::BLACKLIST_FOR_SERIALIZATION` is deprecated in favor of `Devise::Models::Authenticatable::UNSAFE_ATTRIBUTES_FOR_SERIALIZATION` (@hanachin)
|
||||
|
||||
### 4.7.3 - 2020-09-20
|
||||
|
||||
* bug fixes
|
||||
* Do not modify `:except` option given to `#serializable_hash`. (by @dpep)
|
||||
* Fix thor deprecation when running the devise generator. (by @deivid-rodriguez)
|
||||
* Fix hanging tests for streaming controllers using Devise. (by @afn)
|
||||
|
||||
### 4.7.2 - 2020-06-10
|
||||
|
||||
* enhancements
|
||||
* Increase default stretches to 12 (by @sergey-alekseev)
|
||||
|
||||
7
Gemfile
7
Gemfile
@@ -4,20 +4,19 @@ source "https://rubygems.org"
|
||||
|
||||
gemspec
|
||||
|
||||
gem "rails", "~> 6.0.0"
|
||||
gem "rails", "~> 7.0.0"
|
||||
gem "omniauth"
|
||||
gem "omniauth-oauth2"
|
||||
gem "rdoc"
|
||||
|
||||
gem "activemodel-serializers-xml", github: "rails/activemodel-serializers-xml"
|
||||
|
||||
gem "rails-controller-testing", github: "rails/rails-controller-testing"
|
||||
|
||||
gem "responders", "~> 3.0"
|
||||
gem "responders", "~> 3.1"
|
||||
|
||||
group :test do
|
||||
gem "omniauth-facebook"
|
||||
gem "omniauth-openid"
|
||||
gem "rexml"
|
||||
gem "timecop"
|
||||
gem "webrat", "0.7.3", require: false
|
||||
gem "mocha", "~> 1.1", require: false
|
||||
|
||||
304
Gemfile.lock
304
Gemfile.lock
@@ -1,17 +1,8 @@
|
||||
GIT
|
||||
remote: git://github.com/rails/activemodel-serializers-xml.git
|
||||
revision: 93689638c28525acc65afb638fce866826532641
|
||||
remote: https://github.com/rails/rails-controller-testing.git
|
||||
revision: 351c0162df0771c0c48e6a5a886c4c2f0a5d1a74
|
||||
specs:
|
||||
activemodel-serializers-xml (1.0.2)
|
||||
activemodel (>= 5.0.0.a)
|
||||
activesupport (>= 5.0.0.a)
|
||||
builder (~> 3.1)
|
||||
|
||||
GIT
|
||||
remote: git://github.com/rails/rails-controller-testing.git
|
||||
revision: a60b3da1c1c77959b28606dd087c058c64b5a08f
|
||||
specs:
|
||||
rails-controller-testing (1.0.4)
|
||||
rails-controller-testing (1.0.5)
|
||||
actionpack (>= 5.0.1.rc1)
|
||||
actionview (>= 5.0.1.rc1)
|
||||
activesupport (>= 5.0.1.rc1)
|
||||
@@ -19,7 +10,7 @@ GIT
|
||||
PATH
|
||||
remote: .
|
||||
specs:
|
||||
devise (4.7.2)
|
||||
devise (4.9.1)
|
||||
bcrypt (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
railties (>= 4.1.0)
|
||||
@@ -29,191 +20,222 @@ PATH
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
actioncable (6.0.3.1)
|
||||
actionpack (= 6.0.3.1)
|
||||
actioncable (7.0.4.3)
|
||||
actionpack (= 7.0.4.3)
|
||||
activesupport (= 7.0.4.3)
|
||||
nio4r (~> 2.0)
|
||||
websocket-driver (>= 0.6.1)
|
||||
actionmailbox (6.0.3.1)
|
||||
actionpack (= 6.0.3.1)
|
||||
activejob (= 6.0.3.1)
|
||||
activerecord (= 6.0.3.1)
|
||||
activestorage (= 6.0.3.1)
|
||||
activesupport (= 6.0.3.1)
|
||||
actionmailbox (7.0.4.3)
|
||||
actionpack (= 7.0.4.3)
|
||||
activejob (= 7.0.4.3)
|
||||
activerecord (= 7.0.4.3)
|
||||
activestorage (= 7.0.4.3)
|
||||
activesupport (= 7.0.4.3)
|
||||
mail (>= 2.7.1)
|
||||
actionmailer (6.0.3.1)
|
||||
actionpack (= 6.0.3.1)
|
||||
actionview (= 6.0.3.1)
|
||||
activejob (= 6.0.3.1)
|
||||
net-imap
|
||||
net-pop
|
||||
net-smtp
|
||||
actionmailer (7.0.4.3)
|
||||
actionpack (= 7.0.4.3)
|
||||
actionview (= 7.0.4.3)
|
||||
activejob (= 7.0.4.3)
|
||||
activesupport (= 7.0.4.3)
|
||||
mail (~> 2.5, >= 2.5.4)
|
||||
net-imap
|
||||
net-pop
|
||||
net-smtp
|
||||
rails-dom-testing (~> 2.0)
|
||||
actionpack (6.0.3.1)
|
||||
actionview (= 6.0.3.1)
|
||||
activesupport (= 6.0.3.1)
|
||||
rack (~> 2.0, >= 2.0.8)
|
||||
actionpack (7.0.4.3)
|
||||
actionview (= 7.0.4.3)
|
||||
activesupport (= 7.0.4.3)
|
||||
rack (~> 2.0, >= 2.2.0)
|
||||
rack-test (>= 0.6.3)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
||||
actiontext (6.0.3.1)
|
||||
actionpack (= 6.0.3.1)
|
||||
activerecord (= 6.0.3.1)
|
||||
activestorage (= 6.0.3.1)
|
||||
activesupport (= 6.0.3.1)
|
||||
actiontext (7.0.4.3)
|
||||
actionpack (= 7.0.4.3)
|
||||
activerecord (= 7.0.4.3)
|
||||
activestorage (= 7.0.4.3)
|
||||
activesupport (= 7.0.4.3)
|
||||
globalid (>= 0.6.0)
|
||||
nokogiri (>= 1.8.5)
|
||||
actionview (6.0.3.1)
|
||||
activesupport (= 6.0.3.1)
|
||||
actionview (7.0.4.3)
|
||||
activesupport (= 7.0.4.3)
|
||||
builder (~> 3.1)
|
||||
erubi (~> 1.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
||||
activejob (6.0.3.1)
|
||||
activesupport (= 6.0.3.1)
|
||||
activejob (7.0.4.3)
|
||||
activesupport (= 7.0.4.3)
|
||||
globalid (>= 0.3.6)
|
||||
activemodel (6.0.3.1)
|
||||
activesupport (= 6.0.3.1)
|
||||
activerecord (6.0.3.1)
|
||||
activemodel (= 6.0.3.1)
|
||||
activesupport (= 6.0.3.1)
|
||||
activestorage (6.0.3.1)
|
||||
actionpack (= 6.0.3.1)
|
||||
activejob (= 6.0.3.1)
|
||||
activerecord (= 6.0.3.1)
|
||||
marcel (~> 0.3.1)
|
||||
activesupport (6.0.3.1)
|
||||
activemodel (7.0.4.3)
|
||||
activesupport (= 7.0.4.3)
|
||||
activerecord (7.0.4.3)
|
||||
activemodel (= 7.0.4.3)
|
||||
activesupport (= 7.0.4.3)
|
||||
activestorage (7.0.4.3)
|
||||
actionpack (= 7.0.4.3)
|
||||
activejob (= 7.0.4.3)
|
||||
activerecord (= 7.0.4.3)
|
||||
activesupport (= 7.0.4.3)
|
||||
marcel (~> 1.0)
|
||||
mini_mime (>= 1.1.0)
|
||||
activesupport (7.0.4.3)
|
||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||
i18n (>= 0.7, < 2)
|
||||
minitest (~> 5.1)
|
||||
tzinfo (~> 1.1)
|
||||
zeitwerk (~> 2.2, >= 2.2.2)
|
||||
bcrypt (3.1.13)
|
||||
i18n (>= 1.6, < 2)
|
||||
minitest (>= 5.1)
|
||||
tzinfo (~> 2.0)
|
||||
bcrypt (3.1.18)
|
||||
builder (3.2.4)
|
||||
concurrent-ruby (1.1.6)
|
||||
concurrent-ruby (1.2.2)
|
||||
crass (1.0.6)
|
||||
erubi (1.9.0)
|
||||
faraday (1.0.1)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
globalid (0.4.2)
|
||||
activesupport (>= 4.2.0)
|
||||
hashie (4.1.0)
|
||||
i18n (1.8.3)
|
||||
date (3.3.3)
|
||||
erubi (1.12.0)
|
||||
faraday (2.7.4)
|
||||
faraday-net_http (>= 2.0, < 3.1)
|
||||
ruby2_keywords (>= 0.0.4)
|
||||
faraday-net_http (3.0.2)
|
||||
globalid (1.1.0)
|
||||
activesupport (>= 5.0)
|
||||
hashie (5.0.0)
|
||||
i18n (1.12.0)
|
||||
concurrent-ruby (~> 1.0)
|
||||
jwt (2.2.1)
|
||||
loofah (2.5.0)
|
||||
jwt (2.7.0)
|
||||
loofah (2.19.1)
|
||||
crass (~> 1.0.2)
|
||||
nokogiri (>= 1.5.9)
|
||||
mail (2.7.1)
|
||||
mail (2.8.1)
|
||||
mini_mime (>= 0.1.1)
|
||||
marcel (0.3.3)
|
||||
mimemagic (~> 0.3.2)
|
||||
net-imap
|
||||
net-pop
|
||||
net-smtp
|
||||
marcel (1.0.2)
|
||||
method_source (1.0.0)
|
||||
mimemagic (0.3.5)
|
||||
mini_mime (1.0.2)
|
||||
mini_portile2 (2.4.0)
|
||||
minitest (5.14.1)
|
||||
mocha (1.11.2)
|
||||
multi_json (1.14.1)
|
||||
mini_mime (1.1.2)
|
||||
mini_portile2 (2.8.1)
|
||||
minitest (5.18.0)
|
||||
mocha (1.16.1)
|
||||
multi_xml (0.6.0)
|
||||
multipart-post (2.1.1)
|
||||
nio4r (2.5.2)
|
||||
nokogiri (1.10.9)
|
||||
mini_portile2 (~> 2.4.0)
|
||||
oauth2 (1.4.4)
|
||||
faraday (>= 0.8, < 2.0)
|
||||
net-imap (0.3.4)
|
||||
date
|
||||
net-protocol
|
||||
net-pop (0.1.2)
|
||||
net-protocol
|
||||
net-protocol (0.2.1)
|
||||
timeout
|
||||
net-smtp (0.3.3)
|
||||
net-protocol
|
||||
nio4r (2.5.8)
|
||||
nokogiri (1.14.2)
|
||||
mini_portile2 (~> 2.8.0)
|
||||
racc (~> 1.4)
|
||||
oauth2 (2.0.9)
|
||||
faraday (>= 0.17.3, < 3.0)
|
||||
jwt (>= 1.0, < 3.0)
|
||||
multi_json (~> 1.3)
|
||||
multi_xml (~> 0.5)
|
||||
rack (>= 1.2, < 3)
|
||||
omniauth (1.9.1)
|
||||
rack (>= 1.2, < 4)
|
||||
snaky_hash (~> 2.0)
|
||||
version_gem (~> 1.1)
|
||||
omniauth (2.1.1)
|
||||
hashie (>= 3.4.6)
|
||||
rack (>= 1.6.2, < 3)
|
||||
omniauth-facebook (6.0.0)
|
||||
rack (>= 2.2.3)
|
||||
rack-protection
|
||||
omniauth-facebook (9.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)
|
||||
omniauth-oauth2 (1.8.0)
|
||||
oauth2 (>= 1.4, < 3)
|
||||
omniauth (~> 2.0)
|
||||
omniauth-openid (2.0.1)
|
||||
omniauth (>= 1.0, < 3.0)
|
||||
rack-openid (~> 1.4.0)
|
||||
orm_adapter (0.5.0)
|
||||
rack (2.2.2)
|
||||
rack-openid (1.3.1)
|
||||
psych (5.1.0)
|
||||
stringio
|
||||
racc (1.6.2)
|
||||
rack (2.2.6.4)
|
||||
rack-openid (1.4.2)
|
||||
rack (>= 1.1.0)
|
||||
ruby-openid (>= 2.1.8)
|
||||
rack-test (1.1.0)
|
||||
rack (>= 1.0, < 3)
|
||||
rails (6.0.3.1)
|
||||
actioncable (= 6.0.3.1)
|
||||
actionmailbox (= 6.0.3.1)
|
||||
actionmailer (= 6.0.3.1)
|
||||
actionpack (= 6.0.3.1)
|
||||
actiontext (= 6.0.3.1)
|
||||
actionview (= 6.0.3.1)
|
||||
activejob (= 6.0.3.1)
|
||||
activemodel (= 6.0.3.1)
|
||||
activerecord (= 6.0.3.1)
|
||||
activestorage (= 6.0.3.1)
|
||||
activesupport (= 6.0.3.1)
|
||||
bundler (>= 1.3.0)
|
||||
railties (= 6.0.3.1)
|
||||
sprockets-rails (>= 2.0.0)
|
||||
rack-protection (3.0.5)
|
||||
rack
|
||||
rack-test (2.1.0)
|
||||
rack (>= 1.3)
|
||||
rails (7.0.4.3)
|
||||
actioncable (= 7.0.4.3)
|
||||
actionmailbox (= 7.0.4.3)
|
||||
actionmailer (= 7.0.4.3)
|
||||
actionpack (= 7.0.4.3)
|
||||
actiontext (= 7.0.4.3)
|
||||
actionview (= 7.0.4.3)
|
||||
activejob (= 7.0.4.3)
|
||||
activemodel (= 7.0.4.3)
|
||||
activerecord (= 7.0.4.3)
|
||||
activestorage (= 7.0.4.3)
|
||||
activesupport (= 7.0.4.3)
|
||||
bundler (>= 1.15.0)
|
||||
railties (= 7.0.4.3)
|
||||
rails-dom-testing (2.0.3)
|
||||
activesupport (>= 4.2.0)
|
||||
nokogiri (>= 1.6)
|
||||
rails-html-sanitizer (1.3.0)
|
||||
loofah (~> 2.3)
|
||||
railties (6.0.3.1)
|
||||
actionpack (= 6.0.3.1)
|
||||
activesupport (= 6.0.3.1)
|
||||
rails-html-sanitizer (1.5.0)
|
||||
loofah (~> 2.19, >= 2.19.1)
|
||||
railties (7.0.4.3)
|
||||
actionpack (= 7.0.4.3)
|
||||
activesupport (= 7.0.4.3)
|
||||
method_source
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.20.3, < 2.0)
|
||||
rake (13.0.1)
|
||||
rdoc (6.2.1)
|
||||
responders (3.0.1)
|
||||
actionpack (>= 5.0)
|
||||
railties (>= 5.0)
|
||||
rake (>= 12.2)
|
||||
thor (~> 1.0)
|
||||
zeitwerk (~> 2.5)
|
||||
rake (13.0.6)
|
||||
rdoc (6.5.0)
|
||||
psych (>= 4.0.0)
|
||||
responders (3.1.0)
|
||||
actionpack (>= 5.2)
|
||||
railties (>= 5.2)
|
||||
rexml (3.2.5)
|
||||
ruby-openid (2.9.2)
|
||||
sprockets (4.0.1)
|
||||
ruby2_keywords (0.0.5)
|
||||
snaky_hash (2.0.1)
|
||||
hashie
|
||||
version_gem (~> 1.1, >= 1.1.1)
|
||||
sqlite3 (1.6.1)
|
||||
mini_portile2 (~> 2.8.0)
|
||||
stringio (3.0.5)
|
||||
thor (1.2.1)
|
||||
timecop (0.9.6)
|
||||
timeout (0.3.2)
|
||||
tzinfo (2.0.6)
|
||||
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.2)
|
||||
thor (1.0.1)
|
||||
thread_safe (0.3.6)
|
||||
timecop (0.9.1)
|
||||
tzinfo (1.2.7)
|
||||
thread_safe (~> 0.1)
|
||||
warden (1.2.8)
|
||||
rack (>= 2.0.6)
|
||||
version_gem (1.1.2)
|
||||
warden (1.2.9)
|
||||
rack (>= 2.0.9)
|
||||
webrat (0.7.3)
|
||||
nokogiri (>= 1.2.0)
|
||||
rack (>= 1.0)
|
||||
rack-test (>= 0.5.3)
|
||||
websocket-driver (0.7.2)
|
||||
websocket-driver (0.7.5)
|
||||
websocket-extensions (>= 0.1.0)
|
||||
websocket-extensions (0.1.5)
|
||||
zeitwerk (2.3.0)
|
||||
zeitwerk (2.6.7)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
activemodel-serializers-xml!
|
||||
devise!
|
||||
mocha (~> 1.1)
|
||||
omniauth
|
||||
omniauth-facebook
|
||||
omniauth-oauth2
|
||||
omniauth-openid
|
||||
rails (~> 6.0.0)
|
||||
rails (~> 7.0.0)
|
||||
rails-controller-testing!
|
||||
rdoc
|
||||
responders (~> 3.0)
|
||||
responders (~> 3.1)
|
||||
rexml
|
||||
sqlite3 (~> 1.4)
|
||||
timecop
|
||||
webrat (= 0.7.3)
|
||||
|
||||
BUNDLED WITH
|
||||
1.17.3
|
||||
2.4.5
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Copyright 2020 Rafael França, Leonardo Tegon, Carlos Antônio da Silva.
|
||||
Copyright 2020-2023 Rafael França, Leonardo Tegon, Carlos Antônio da Silva.
|
||||
Copyright 2009-2019 Plataformatec.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
|
||||
84
README.md
84
README.md
@@ -1,7 +1,4 @@
|
||||

|
||||
|
||||
[](http://travis-ci.org/heartcombo/devise)
|
||||
[](https://codeclimate.com/github/heartcombo/devise)
|
||||

|
||||
|
||||
Devise is a flexible authentication solution for Rails based on Warden. It:
|
||||
|
||||
@@ -12,16 +9,16 @@ Devise is a flexible authentication solution for Rails based on Warden. It:
|
||||
|
||||
It's composed of 10 modules:
|
||||
|
||||
* [Database Authenticatable](http://www.rubydoc.info/github/heartcombo/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/heartcombo/devise/master/Devise/Models/Omniauthable): adds OmniAuth (https://github.com/omniauth/omniauth) support.
|
||||
* [Confirmable](http://www.rubydoc.info/github/heartcombo/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/heartcombo/devise/master/Devise/Models/Recoverable): resets the user password and sends reset instructions.
|
||||
* [Registerable](http://www.rubydoc.info/github/heartcombo/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/heartcombo/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/heartcombo/devise/master/Devise/Models/Trackable): tracks sign in count, timestamps and IP address.
|
||||
* [Timeoutable](http://www.rubydoc.info/github/heartcombo/devise/master/Devise/Models/Timeoutable): expires sessions that have not been active in a specified period of time.
|
||||
* [Validatable](http://www.rubydoc.info/github/heartcombo/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/heartcombo/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/heartcombo/devise/main/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/heartcombo/devise/main/Devise/Models/Omniauthable): adds OmniAuth (https://github.com/omniauth/omniauth) support.
|
||||
* [Confirmable](http://www.rubydoc.info/github/heartcombo/devise/main/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/heartcombo/devise/main/Devise/Models/Recoverable): resets the user password and sends reset instructions.
|
||||
* [Registerable](http://www.rubydoc.info/github/heartcombo/devise/main/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/heartcombo/devise/main/Devise/Models/Rememberable): manages generating and clearing a token for remembering the user from a saved cookie.
|
||||
* [Trackable](http://www.rubydoc.info/github/heartcombo/devise/main/Devise/Models/Trackable): tracks sign in count, timestamps and IP address.
|
||||
* [Timeoutable](http://www.rubydoc.info/github/heartcombo/devise/main/Devise/Models/Timeoutable): expires sessions that have not been active in a specified period of time.
|
||||
* [Validatable](http://www.rubydoc.info/github/heartcombo/devise/main/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/heartcombo/devise/main/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
|
||||
|
||||
@@ -54,7 +51,6 @@ It's composed of 10 modules:
|
||||
- [Other ORMs](#other-orms)
|
||||
- [Rails API mode](#rails-api-mode)
|
||||
- [Additional information](#additional-information)
|
||||
- [Heroku](#heroku)
|
||||
- [Warden](#warden)
|
||||
- [Contributors](#contributors)
|
||||
- [License](#license)
|
||||
@@ -93,7 +89,7 @@ https://groups.google.com/group/plataformatec-devise
|
||||
|
||||
You can view the Devise documentation in RDoc format here:
|
||||
|
||||
http://rubydoc.info/github/heartcombo/devise/master/frames
|
||||
http://rubydoc.info/github/heartcombo/devise/main/frames
|
||||
|
||||
If you need to use Devise with previous versions of Rails, you can always run "gem server" from the command line after you install the gem to access the old documentation.
|
||||
|
||||
@@ -119,8 +115,8 @@ You will usually want to write tests for your changes. To run the test suite, g
|
||||
Devise works with multiple Ruby and Rails versions, and ActiveRecord and Mongoid ORMs, which means you can run the test suite with some modifiers: `DEVISE_ORM` and `BUNDLE_GEMFILE`.
|
||||
|
||||
### DEVISE_ORM
|
||||
Since Devise support both Mongoid and ActiveRecord, we rely on this variable to run specific code for each ORM.
|
||||
The default value of `DEVISE_ORM` is `active_record`. To run the tests for mongoid, you can pass `mongoid`:
|
||||
Since Devise supports both Mongoid and ActiveRecord, we rely on this variable to run specific code for each ORM.
|
||||
The default value of `DEVISE_ORM` is `active_record`. To run the tests for Mongoid, you can pass `mongoid`:
|
||||
```
|
||||
DEVISE_ORM=mongoid bin/test
|
||||
|
||||
@@ -132,7 +128,7 @@ 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/heartcombo/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.
|
||||
Inside the [gemfiles](https://github.com/heartcombo/devise/tree/main/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 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:
|
||||
```bash
|
||||
rbenv shell 2.4.2 # or rvm use 2.4.2
|
||||
@@ -273,7 +269,7 @@ Besides `:stretches`, you can define `:pepper`, `:encryptor`, `:confirm_within`,
|
||||
|
||||
### Strong Parameters
|
||||
|
||||

|
||||
The Parameter Sanitizer API has changed for Devise 4 :warning:
|
||||
|
||||
*For previous Devise versions see https://github.com/heartcombo/devise/tree/3-stable#strong-parameters*
|
||||
|
||||
@@ -313,7 +309,7 @@ class ApplicationController < ActionController::Base
|
||||
end
|
||||
```
|
||||
|
||||
Devise allows you to completely change Devise defaults or invoke custom behaviour by passing a block:
|
||||
Devise allows you to completely change Devise defaults or invoke custom behavior by passing a block:
|
||||
|
||||
To permit simple scalar values for username and email, use this
|
||||
|
||||
@@ -386,7 +382,7 @@ $ rails generate devise:views users
|
||||
```
|
||||
|
||||
If you would like to generate only a few sets of views, like the ones for the `registerable` and `confirmable` module,
|
||||
you can pass a list of modules to the generator with the `-v` flag.
|
||||
you can pass a list of views to the generator with the `-v` flag.
|
||||
|
||||
```console
|
||||
$ rails generate devise:views -v registrations confirmations
|
||||
@@ -414,7 +410,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`)
|
||||
Use the `-c` flag to specify one or more controllers, for example: `rails generate devise:controllers users -c sessions`)
|
||||
|
||||
2. Tell the router to use this controller:
|
||||
|
||||
@@ -422,7 +418,7 @@ If the customization at the views level is not enough, you can customize each co
|
||||
devise_for :users, controllers: { sessions: 'users/sessions' }
|
||||
```
|
||||
|
||||
3. Copy the views from `devise/sessions` to `users/sessions`. Since the controller was changed, it won't use the default views located in `devise/sessions`.
|
||||
3. Recommended but not required: copy (or move) the views from `devise/sessions` to `users/sessions`. Rails will continue using the views from `devise/sessions` due to inheritance if you skip this step, but having the views matching the controller(s) keeps things consistent.
|
||||
|
||||
4. Finally, change or extend the desired controller actions.
|
||||
|
||||
@@ -436,7 +432,7 @@ If the customization at the views level is not enough, you can customize each co
|
||||
end
|
||||
```
|
||||
|
||||
Or you can simply add new behaviour to it:
|
||||
Or you can simply add new behavior to it:
|
||||
|
||||
```ruby
|
||||
class Users::SessionsController < Devise::SessionsController
|
||||
@@ -460,7 +456,7 @@ Devise also ships with default routes. If you need to customize them, you should
|
||||
devise_for :users, path: 'auth', path_names: { sign_in: 'login', sign_out: 'logout', password: 'secret', confirmation: 'verification', unlock: 'unblock', registration: 'register', sign_up: 'cmon_let_me_in' }
|
||||
```
|
||||
|
||||
Be sure to check `devise_for` [documentation](http://www.rubydoc.info/github/heartcombo/devise/master/ActionDispatch/Routing/Mapper%3Adevise_for) for details.
|
||||
Be sure to check `devise_for` [documentation](http://www.rubydoc.info/github/heartcombo/devise/main/ActionDispatch/Routing/Mapper%3Adevise_for) for details.
|
||||
|
||||
If you have the need for more deep customization, for instance to also allow "/sign_in" besides "/users/sign_in", all you need to do is create your routes normally and wrap them in a `devise_scope` block in the router:
|
||||
|
||||
@@ -478,6 +474,36 @@ Please note: You will still need to add `devise_for` in your routes in order to
|
||||
devise_for :users, skip: :all
|
||||
```
|
||||
|
||||
### Hotwire/Turbo
|
||||
|
||||
Devise integrates with Hotwire/Turbo by treating such requests as navigational, and configuring certain responses for errors and redirects to match the expected behavior. New apps are generated with the following response configuration by default, and existing apps may opt-in by adding the config to their Devise initializers:
|
||||
|
||||
```ruby
|
||||
Devise.setup do |config|
|
||||
# ...
|
||||
# When using Devise with Hotwire/Turbo, the http status for error responses
|
||||
# and some redirects must match the following. The default in Devise for existing
|
||||
# apps is `200 OK` and `302 Found respectively`, but new apps are generated with
|
||||
# these new defaults that match Hotwire/Turbo behavior.
|
||||
# Note: These might become the new default in future versions of Devise.
|
||||
config.responder.error_status = :unprocessable_entity
|
||||
config.responder.redirect_status = :see_other
|
||||
end
|
||||
```
|
||||
|
||||
**Important**: these custom responses require the `responders` gem version to be `3.1.0` or higher, please make sure you update it if you're going to use this configuration. Check [this upgrade guide](https://github.com/heartcombo/devise/wiki/How-To:-Upgrade-to-Devise-4.9.0-[Hotwire-Turbo-integration]) for more info.
|
||||
|
||||
_Note_: the above statuses configuration may become the default for Devise in a future release.
|
||||
|
||||
There are a couple other changes you might need to make in your app to work with Hotwire/Turbo, if you're migrating from rails-ujs:
|
||||
|
||||
* The `data-confirm` option that adds a confirmation modal to buttons/forms before submission needs to change to `data-turbo-confirm`, so that Turbo handles those appropriately.
|
||||
* The `data-method` option that sets the request method for link submissions needs to change to `data-turbo-method`. This is not necessary for `button_to` or `form`s since Turbo can handle those.
|
||||
|
||||
If you're setting up Devise to sign out via `:delete`, and you're using links (instead of buttons wrapped in a form) to sign out with the `method: :delete` option, they will need to be updated as described above. (Devise does not provide sign out links/buttons in its shared views.)
|
||||
|
||||
Make sure to inspect your views looking for those, and change appropriately.
|
||||
|
||||
### I18n
|
||||
|
||||
Devise uses flash messages with I18n, in conjunction with the flash keys :notice and :alert. To customize your app, you can set up your locale file:
|
||||
@@ -681,12 +707,12 @@ end
|
||||
|
||||
### Password reset tokens and Rails logs
|
||||
|
||||
If you enable the [Recoverable](http://rubydoc.info/github/heartcombo/devise/master/Devise/Models/Recoverable) module, note that a stolen password reset token could give an attacker access to your application. Devise takes effort to generate random, secure tokens, and stores only token digests in the database, never plaintext. However the default logging behavior in Rails can cause plaintext tokens to leak into log files:
|
||||
If you enable the [Recoverable](http://rubydoc.info/github/heartcombo/devise/main/Devise/Models/Recoverable) module, note that a stolen password reset token could give an attacker access to your application. Devise takes effort to generate random, secure tokens, and stores only token digests in the database, never plaintext. However the default logging behavior in Rails can cause plaintext tokens to leak into log files:
|
||||
|
||||
1. Action Mailer logs the entire contents of all outgoing emails to the DEBUG level. Password reset tokens delivered to users in email will be leaked.
|
||||
2. Active Job logs all arguments to every enqueued job at the INFO level. If you configure Devise to use `deliver_later` to send password reset emails, password reset tokens will be leaked.
|
||||
|
||||
Rails sets the production logger level to DEBUG by default. Consider changing your production logger level to WARN if you wish to prevent tokens from being leaked into your logs. In `config/environments/production.rb`:
|
||||
Rails sets the production logger level to INFO by default. Consider changing your production logger level to WARN if you wish to prevent tokens from being leaked into your logs. In `config/environments/production.rb`:
|
||||
|
||||
```ruby
|
||||
config.log_level = :warn
|
||||
@@ -741,6 +767,6 @@ https://github.com/heartcombo/devise/graphs/contributors
|
||||
|
||||
## License
|
||||
|
||||
MIT License. Copyright 2020 Rafael França, Leaonardo Tegon, Carlos Antônio da Silva. Copyright 2009-2019 Plataformatec.
|
||||
MIT License. Copyright 2020-2023 Rafael França, Leonardo Tegon, Carlos Antônio da Silva. Copyright 2009-2019 Plataformatec.
|
||||
|
||||
The Devise logo is licensed under [Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License](https://creativecommons.org/licenses/by-nc-nd/4.0/).
|
||||
|
||||
@@ -27,6 +27,7 @@ class Devise::ConfirmationsController < DeviseController
|
||||
set_flash_message!(:notice, :confirmed)
|
||||
respond_with_navigational(resource){ redirect_to after_confirmation_path_for(resource_name, resource) }
|
||||
else
|
||||
# TODO: use `error_status` when the default changes to `:unprocessable_entity`.
|
||||
respond_with_navigational(resource.errors, status: :unprocessable_entity){ render :new }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -36,7 +36,7 @@ class Devise::PasswordsController < DeviseController
|
||||
|
||||
if resource.errors.empty?
|
||||
resource.unlock_access! if unlockable?(resource)
|
||||
if Devise.sign_in_after_reset_password
|
||||
if resource_class.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
|
||||
@@ -53,7 +53,7 @@ class Devise::PasswordsController < DeviseController
|
||||
|
||||
protected
|
||||
def after_resetting_password_path_for(resource)
|
||||
Devise.sign_in_after_reset_password ? after_sign_in_path_for(resource) : new_session_path(resource_name)
|
||||
resource_class.sign_in_after_reset_password ? after_sign_in_path_for(resource) : new_session_path(resource_name)
|
||||
end
|
||||
|
||||
# The path used after sending reset password instructions
|
||||
|
||||
@@ -67,7 +67,7 @@ class Devise::RegistrationsController < DeviseController
|
||||
Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name)
|
||||
set_flash_message! :notice, :destroyed
|
||||
yield resource if block_given?
|
||||
respond_with_navigational(resource){ redirect_to after_sign_out_path_for(resource_name) }
|
||||
respond_with_navigational(resource){ redirect_to after_sign_out_path_for(resource_name), status: Devise.responder.redirect_status }
|
||||
end
|
||||
|
||||
# GET /resource/cancel
|
||||
|
||||
@@ -77,7 +77,7 @@ class Devise::SessionsController < DeviseController
|
||||
# support returning empty response on GET request
|
||||
respond_to do |format|
|
||||
format.all { head :no_content }
|
||||
format.any(*navigational_formats) { redirect_to after_sign_out_path_for(resource_name) }
|
||||
format.any(*navigational_formats) { redirect_to after_sign_out_path_for(resource_name), status: Devise.responder.redirect_status }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -29,6 +29,7 @@ class Devise::UnlocksController < DeviseController
|
||||
set_flash_message! :notice, :unlocked
|
||||
respond_with_navigational(resource){ redirect_to after_unlock_path_for(resource) }
|
||||
else
|
||||
# TODO: use `error_status` when the default changes to `:unprocessable_entity`.
|
||||
respond_with_navigational(resource.errors, status: :unprocessable_entity){ render :new }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -15,6 +15,7 @@ class DeviseController < Devise.parent_controller.constantize
|
||||
end
|
||||
|
||||
prepend_before_action :assert_is_devise_resource!
|
||||
self.responder = Devise.responder
|
||||
respond_to :html if mimes_for_respond_to.empty?
|
||||
|
||||
# Override prefixes to consider the scoped view.
|
||||
|
||||
@@ -1,14 +1,26 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module DeviseHelper
|
||||
# Retain this method for backwards compatibility, deprecated in favour of modifying the
|
||||
# devise/shared/error_messages partial
|
||||
# Retain this method for backwards compatibility, deprecated in favor 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.
|
||||
[Devise] `DeviseHelper#devise_error_messages!` is deprecated and will be
|
||||
removed in the next major version.
|
||||
|
||||
Devise now uses a partial under "devise/shared/error_messages" to display
|
||||
error messages by default, and make them easier to customize. Update your
|
||||
views changing calls from:
|
||||
|
||||
<%= devise_error_messages! %>
|
||||
|
||||
to:
|
||||
|
||||
<%= render "devise/shared/error_messages", resource: resource %>
|
||||
|
||||
To start customizing how errors are displayed, you can copy the partial
|
||||
from devise to your `app/views` folder. Alternatively, you can run
|
||||
`rails g devise:views` which will copy all of them again to your app.
|
||||
DEPRECATION
|
||||
|
||||
return "" if resource.errors.empty?
|
||||
|
||||
@@ -4,26 +4,26 @@ if defined?(ActionMailer)
|
||||
class Devise::Mailer < Devise.parent_mailer.constantize
|
||||
include Devise::Mailers::Helpers
|
||||
|
||||
def confirmation_instructions(record, token, opts={})
|
||||
def confirmation_instructions(record, token, opts = {})
|
||||
@token = token
|
||||
devise_mail(record, :confirmation_instructions, opts)
|
||||
end
|
||||
|
||||
def reset_password_instructions(record, token, opts={})
|
||||
def reset_password_instructions(record, token, opts = {})
|
||||
@token = token
|
||||
devise_mail(record, :reset_password_instructions, opts)
|
||||
end
|
||||
|
||||
def unlock_instructions(record, token, opts={})
|
||||
def unlock_instructions(record, token, opts = {})
|
||||
@token = token
|
||||
devise_mail(record, :unlock_instructions, opts)
|
||||
end
|
||||
|
||||
def email_changed(record, opts={})
|
||||
def email_changed(record, opts = {})
|
||||
devise_mail(record, :email_changed, opts)
|
||||
end
|
||||
|
||||
def password_change(record, opts={})
|
||||
def password_change(record, opts = {})
|
||||
devise_mail(record, :password_change, opts)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -38,6 +38,6 @@
|
||||
|
||||
<h3>Cancel my account</h3>
|
||||
|
||||
<p>Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %></p>
|
||||
<div>Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?", turbo_confirm: "Are you sure?" }, method: :delete %></div>
|
||||
|
||||
<%= link_to "Back", :back %>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<% if resource.errors.any? %>
|
||||
<div id="error_explanation">
|
||||
<div id="error_explanation" data-turbo-cache="false">
|
||||
<h2>
|
||||
<%= I18n.t("errors.messages.not_saved",
|
||||
count: resource.errors.count,
|
||||
|
||||
@@ -20,6 +20,6 @@
|
||||
|
||||
<%- 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 />
|
||||
<%= button_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider), data: { turbo: false } %><br />
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
@@ -44,7 +44,7 @@ en:
|
||||
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 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"
|
||||
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."
|
||||
|
||||
@@ -14,6 +14,14 @@ Gem::Specification.new do |s|
|
||||
s.homepage = "https://github.com/heartcombo/devise"
|
||||
s.description = "Flexible authentication solution for Rails with Warden"
|
||||
s.authors = ['José Valim', 'Carlos Antônio']
|
||||
s.metadata = {
|
||||
"homepage_uri" => "https://github.com/heartcombo/devise",
|
||||
"documentation_uri" => "https://rubydoc.info/github/heartcombo/devise",
|
||||
"changelog_uri" => "https://github.com/heartcombo/devise/blob/main/CHANGELOG.md",
|
||||
"source_code_uri" => "https://github.com/heartcombo/devise",
|
||||
"bug_tracker_uri" => "https://github.com/heartcombo/devise/issues",
|
||||
"wiki_uri" => "https://github.com/heartcombo/devise/wiki"
|
||||
}
|
||||
|
||||
s.files = Dir["{app,config,lib}/**/*", "CHANGELOG.md", "MIT-LICENSE", "README.md"]
|
||||
s.require_paths = ["lib"]
|
||||
@@ -24,4 +32,11 @@ Gem::Specification.new do |s|
|
||||
s.add_dependency("bcrypt", "~> 3.0")
|
||||
s.add_dependency("railties", ">= 4.1.0")
|
||||
s.add_dependency("responders")
|
||||
|
||||
s.post_install_message = %q{
|
||||
[DEVISE] Please review the [changelog] and [upgrade guide] for more info on Hotwire / Turbo integration.
|
||||
|
||||
[changelog] https://github.com/heartcombo/devise/blob/main/CHANGELOG.md
|
||||
[upgrade guide] https://github.com/heartcombo/devise/wiki/How-To:-Upgrade-to-Devise-4.9.0-%5BHotwire-Turbo-integration%5D
|
||||
}
|
||||
end
|
||||
|
||||
@@ -2,6 +2,11 @@
|
||||
|
||||
source "https://rubygems.org"
|
||||
|
||||
git_source(:github) do |repo_name|
|
||||
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?('/')
|
||||
"https://github.com/#{repo_name}.git"
|
||||
end
|
||||
|
||||
gemspec path: ".."
|
||||
|
||||
gem "rails", github: "rails/rails", branch: "4-1-stable"
|
||||
@@ -33,3 +38,9 @@ end
|
||||
group :mongoid do
|
||||
gem "mongoid", "~> 4.0"
|
||||
end
|
||||
|
||||
if RUBY_VERSION < "2.3.0"
|
||||
# We're getting version 2.2.0 which doesn't play nice with Ruby 2.2, using
|
||||
# `Object.deprecate_constant` which isn't available.
|
||||
gem "multipart-post", "2.1.1"
|
||||
end
|
||||
@@ -2,6 +2,11 @@
|
||||
|
||||
source "https://rubygems.org"
|
||||
|
||||
git_source(:github) do |repo_name|
|
||||
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?('/')
|
||||
"https://github.com/#{repo_name}.git"
|
||||
end
|
||||
|
||||
gemspec path: ".."
|
||||
|
||||
gem "rails", github: "rails/rails", branch: "4-2-stable"
|
||||
@@ -32,3 +37,9 @@ end
|
||||
group :mongoid do
|
||||
gem "mongoid", "~> 4.0"
|
||||
end
|
||||
|
||||
if RUBY_VERSION < "2.3.0"
|
||||
# We're getting version 2.2.0 which doesn't play nice with Ruby 2.2, using
|
||||
# `Object.deprecate_constant` which isn't available.
|
||||
gem "multipart-post", "2.1.1"
|
||||
end
|
||||
@@ -9,8 +9,6 @@ gem "omniauth"
|
||||
gem "omniauth-oauth2"
|
||||
gem "rdoc"
|
||||
|
||||
gem "activemodel-serializers-xml", github: "rails/activemodel-serializers-xml"
|
||||
|
||||
gem "rails-controller-testing"
|
||||
|
||||
gem "responders", "~> 2.1"
|
||||
@@ -31,3 +29,9 @@ end
|
||||
# group :mongoid do
|
||||
# gem "mongoid", "~> 4.0.0"
|
||||
# end
|
||||
|
||||
if RUBY_VERSION < "2.3.0"
|
||||
# We're getting version 2.2.0 which doesn't play nice with Ruby 2.2, using
|
||||
# `Object.deprecate_constant` which isn't available.
|
||||
gem "multipart-post", "2.1.1"
|
||||
end
|
||||
@@ -7,8 +7,6 @@ gem "omniauth"
|
||||
gem "omniauth-oauth2"
|
||||
gem "rdoc"
|
||||
|
||||
gem "activemodel-serializers-xml", github: "rails/activemodel-serializers-xml"
|
||||
|
||||
gem "rails-controller-testing"
|
||||
|
||||
gem "responders", "~> 2.1"
|
||||
@@ -24,3 +22,9 @@ end
|
||||
platforms :ruby do
|
||||
gem "sqlite3", "~> 1.3.6"
|
||||
end
|
||||
|
||||
if RUBY_VERSION < "2.3.0"
|
||||
# We're getting version 2.2.0 which doesn't play nice with Ruby 2.2, using
|
||||
# `Object.deprecate_constant` which isn't available.
|
||||
gem "multipart-post", "2.1.1"
|
||||
end
|
||||
@@ -7,8 +7,6 @@ gem "omniauth"
|
||||
gem "omniauth-oauth2"
|
||||
gem "rdoc"
|
||||
|
||||
gem "activemodel-serializers-xml", github: "rails/activemodel-serializers-xml"
|
||||
|
||||
gem "rails-controller-testing"
|
||||
|
||||
gem "responders", "~> 2.1"
|
||||
@@ -2,20 +2,19 @@ source "https://rubygems.org"
|
||||
|
||||
gemspec path: ".."
|
||||
|
||||
gem "rails", '~> 6.0.0'
|
||||
gem "rails", '~> 6.0.0', github: 'rails/rails', branch: '6-0-stable'
|
||||
gem "omniauth"
|
||||
gem "omniauth-oauth2"
|
||||
gem "rdoc"
|
||||
|
||||
gem "activemodel-serializers-xml", github: "rails/activemodel-serializers-xml"
|
||||
|
||||
gem "rails-controller-testing", github: "rails/rails-controller-testing"
|
||||
|
||||
gem "responders", "~> 3.0"
|
||||
gem "responders", "~> 3.1"
|
||||
|
||||
group :test do
|
||||
gem "omniauth-facebook"
|
||||
gem "omniauth-openid"
|
||||
gem "rexml"
|
||||
gem "timecop"
|
||||
gem "webrat", "0.7.3", require: false
|
||||
gem "mocha", "~> 1.1", require: false
|
||||
31
gemfiles/Gemfile-rails-6-1
Normal file
31
gemfiles/Gemfile-rails-6-1
Normal file
@@ -0,0 +1,31 @@
|
||||
source "https://rubygems.org"
|
||||
|
||||
gemspec path: ".."
|
||||
|
||||
gem "rails", '~> 6.1.0'
|
||||
gem "omniauth"
|
||||
gem "omniauth-oauth2"
|
||||
gem "rdoc"
|
||||
|
||||
gem "rails-controller-testing", github: "rails/rails-controller-testing"
|
||||
|
||||
gem "responders", "~> 3.1"
|
||||
|
||||
if RUBY_VERSION >= "3.1"
|
||||
gem "net-smtp", require: false
|
||||
gem "net-imap", require: false
|
||||
gem "net-pop", require: false
|
||||
end
|
||||
|
||||
group :test do
|
||||
gem "omniauth-facebook"
|
||||
gem "omniauth-openid"
|
||||
gem "rexml"
|
||||
gem "timecop"
|
||||
gem "webrat", "0.7.3", require: false
|
||||
gem "mocha", "~> 1.1", require: false
|
||||
end
|
||||
|
||||
platforms :ruby do
|
||||
gem "sqlite3", "~> 1.4"
|
||||
end
|
||||
25
gemfiles/Gemfile-rails-main
Normal file
25
gemfiles/Gemfile-rails-main
Normal file
@@ -0,0 +1,25 @@
|
||||
source "https://rubygems.org"
|
||||
|
||||
gemspec path: ".."
|
||||
|
||||
gem "rails", github: "rails/rails", branch: "main"
|
||||
gem "omniauth"
|
||||
gem "omniauth-oauth2"
|
||||
gem "rdoc"
|
||||
|
||||
gem "rails-controller-testing", github: "rails/rails-controller-testing"
|
||||
|
||||
gem "responders", "~> 3.1"
|
||||
|
||||
group :test do
|
||||
gem "omniauth-facebook"
|
||||
gem "omniauth-openid"
|
||||
gem "rexml"
|
||||
gem "timecop"
|
||||
gem "webrat", "0.7.3", require: false
|
||||
gem "mocha", "~> 1.1", require: false
|
||||
end
|
||||
|
||||
platforms :ruby do
|
||||
gem "sqlite3", "~> 1.4"
|
||||
end
|
||||
@@ -1,171 +0,0 @@
|
||||
GIT
|
||||
remote: git://github.com/rails/rails.git
|
||||
revision: 0cad778c2605a5204a05a9f1dbd3344e39f248d8
|
||||
branch: 4-1-stable
|
||||
specs:
|
||||
actionmailer (4.1.16)
|
||||
actionpack (= 4.1.16)
|
||||
actionview (= 4.1.16)
|
||||
mail (~> 2.5, >= 2.5.4)
|
||||
actionpack (4.1.16)
|
||||
actionview (= 4.1.16)
|
||||
activesupport (= 4.1.16)
|
||||
rack (~> 1.5.2)
|
||||
rack-test (~> 0.6.2)
|
||||
actionview (4.1.16)
|
||||
activesupport (= 4.1.16)
|
||||
builder (~> 3.1)
|
||||
erubis (~> 2.7.0)
|
||||
activemodel (4.1.16)
|
||||
activesupport (= 4.1.16)
|
||||
builder (~> 3.1)
|
||||
activerecord (4.1.16)
|
||||
activemodel (= 4.1.16)
|
||||
activesupport (= 4.1.16)
|
||||
arel (~> 5.0.0)
|
||||
activesupport (4.1.16)
|
||||
i18n (~> 0.6, >= 0.6.9)
|
||||
json (~> 1.7, >= 1.7.7)
|
||||
minitest (~> 5.1)
|
||||
thread_safe (~> 0.1)
|
||||
tzinfo (~> 1.1)
|
||||
rails (4.1.16)
|
||||
actionmailer (= 4.1.16)
|
||||
actionpack (= 4.1.16)
|
||||
actionview (= 4.1.16)
|
||||
activemodel (= 4.1.16)
|
||||
activerecord (= 4.1.16)
|
||||
activesupport (= 4.1.16)
|
||||
bundler (>= 1.3.0, < 2.0)
|
||||
railties (= 4.1.16)
|
||||
sprockets-rails (~> 2.0)
|
||||
railties (4.1.16)
|
||||
actionpack (= 4.1.16)
|
||||
activesupport (= 4.1.16)
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.18.1, < 2.0)
|
||||
|
||||
PATH
|
||||
remote: ..
|
||||
specs:
|
||||
devise (4.7.2)
|
||||
bcrypt (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
railties (>= 4.1.0)
|
||||
responders
|
||||
warden (~> 1.2.3)
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
arel (5.0.1.20140414130214)
|
||||
bcrypt (3.1.13)
|
||||
bson (3.2.7)
|
||||
builder (3.2.4)
|
||||
concurrent-ruby (1.1.6)
|
||||
connection_pool (2.2.3)
|
||||
erubis (2.7.0)
|
||||
faraday (1.0.1)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
hashie (3.6.0)
|
||||
i18n (0.9.5)
|
||||
concurrent-ruby (~> 1.0)
|
||||
json (1.8.6)
|
||||
jwt (2.2.1)
|
||||
mail (2.7.1)
|
||||
mini_mime (>= 0.1.1)
|
||||
mini_mime (1.0.2)
|
||||
mini_portile2 (2.4.0)
|
||||
minitest (5.14.1)
|
||||
mocha (1.11.2)
|
||||
mongoid (4.0.2)
|
||||
activemodel (~> 4.0)
|
||||
moped (~> 2.0.0)
|
||||
origin (~> 2.1)
|
||||
tzinfo (>= 0.3.37)
|
||||
moped (2.0.7)
|
||||
bson (~> 3.0)
|
||||
connection_pool (~> 2.0)
|
||||
optionable (~> 0.2.0)
|
||||
multi_json (1.14.1)
|
||||
multi_xml (0.6.0)
|
||||
multipart-post (2.1.1)
|
||||
nokogiri (1.9.1)
|
||||
mini_portile2 (~> 2.4.0)
|
||||
oauth2 (1.4.4)
|
||||
faraday (>= 0.8, < 2.0)
|
||||
jwt (>= 1.0, < 3.0)
|
||||
multi_json (~> 1.3)
|
||||
multi_xml (~> 0.5)
|
||||
rack (>= 1.2, < 3)
|
||||
omniauth (1.4.2)
|
||||
hashie (>= 1.2, < 4)
|
||||
rack (>= 1.0, < 3)
|
||||
omniauth-facebook (6.0.0)
|
||||
omniauth-oauth2 (~> 1.2)
|
||||
omniauth-oauth2 (1.5.0)
|
||||
oauth2 (~> 1.1)
|
||||
omniauth (~> 1.2)
|
||||
omniauth-openid (1.0.1)
|
||||
omniauth (~> 1.0)
|
||||
rack-openid (~> 1.3.1)
|
||||
optionable (0.2.0)
|
||||
origin (2.3.1)
|
||||
orm_adapter (0.5.0)
|
||||
rack (1.5.5)
|
||||
rack-openid (1.3.1)
|
||||
rack (>= 1.1.0)
|
||||
ruby-openid (>= 2.1.8)
|
||||
rack-test (0.6.3)
|
||||
rack (>= 1.0)
|
||||
rake (13.0.1)
|
||||
rdoc (5.1.0)
|
||||
responders (1.1.2)
|
||||
railties (>= 3.2, < 4.2)
|
||||
ruby-openid (2.9.2)
|
||||
sprockets (3.7.2)
|
||||
concurrent-ruby (~> 1.0)
|
||||
rack (> 1, < 3)
|
||||
sprockets-rails (2.3.3)
|
||||
actionpack (>= 3.0)
|
||||
activesupport (>= 3.0)
|
||||
sprockets (>= 2.8, < 4.0)
|
||||
sqlite3 (1.3.13)
|
||||
test_after_commit (1.2.2)
|
||||
activerecord (>= 3.2, < 5.0)
|
||||
thor (1.0.1)
|
||||
thread_safe (0.3.6)
|
||||
timecop (0.9.1)
|
||||
tzinfo (1.2.7)
|
||||
thread_safe (~> 0.1)
|
||||
warden (1.2.7)
|
||||
rack (>= 1.0)
|
||||
webrat (0.7.3)
|
||||
nokogiri (>= 1.2.0)
|
||||
rack (>= 1.0)
|
||||
rack-test (>= 0.5.3)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
activerecord-jdbc-adapter
|
||||
activerecord-jdbcsqlite3-adapter
|
||||
devise!
|
||||
jruby-openssl
|
||||
mocha (~> 1.1)
|
||||
mongoid (~> 4.0)
|
||||
nokogiri (= 1.9.1)
|
||||
omniauth
|
||||
omniauth-facebook
|
||||
omniauth-oauth2
|
||||
omniauth-openid
|
||||
rails!
|
||||
rdoc (~> 5.1)
|
||||
sqlite3 (~> 1.3.6)
|
||||
test_after_commit
|
||||
timecop
|
||||
webrat (= 0.7.3)
|
||||
|
||||
BUNDLED WITH
|
||||
1.17.3
|
||||
@@ -1,194 +0,0 @@
|
||||
GIT
|
||||
remote: git://github.com/rails/rails.git
|
||||
revision: c0cb0cbf976a3cf8ad1b0e2d0f813602a712e997
|
||||
branch: 4-2-stable
|
||||
specs:
|
||||
actionmailer (4.2.11.3)
|
||||
actionpack (= 4.2.11.3)
|
||||
actionview (= 4.2.11.3)
|
||||
activejob (= 4.2.11.3)
|
||||
mail (~> 2.5, >= 2.5.4)
|
||||
rails-dom-testing (~> 1.0, >= 1.0.5)
|
||||
actionpack (4.2.11.3)
|
||||
actionview (= 4.2.11.3)
|
||||
activesupport (= 4.2.11.3)
|
||||
rack (~> 1.6)
|
||||
rack-test (~> 0.6.2)
|
||||
rails-dom-testing (~> 1.0, >= 1.0.5)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||
actionview (4.2.11.3)
|
||||
activesupport (= 4.2.11.3)
|
||||
builder (~> 3.1)
|
||||
erubis (~> 2.7.0)
|
||||
rails-dom-testing (~> 1.0, >= 1.0.5)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
||||
activejob (4.2.11.3)
|
||||
activesupport (= 4.2.11.3)
|
||||
globalid (>= 0.3.0)
|
||||
activemodel (4.2.11.3)
|
||||
activesupport (= 4.2.11.3)
|
||||
builder (~> 3.1)
|
||||
activerecord (4.2.11.3)
|
||||
activemodel (= 4.2.11.3)
|
||||
activesupport (= 4.2.11.3)
|
||||
arel (~> 6.0)
|
||||
activesupport (4.2.11.3)
|
||||
i18n (~> 0.7)
|
||||
minitest (~> 5.1)
|
||||
thread_safe (~> 0.3, >= 0.3.4)
|
||||
tzinfo (~> 1.1)
|
||||
rails (4.2.11.3)
|
||||
actionmailer (= 4.2.11.3)
|
||||
actionpack (= 4.2.11.3)
|
||||
actionview (= 4.2.11.3)
|
||||
activejob (= 4.2.11.3)
|
||||
activemodel (= 4.2.11.3)
|
||||
activerecord (= 4.2.11.3)
|
||||
activesupport (= 4.2.11.3)
|
||||
bundler (>= 1.3.0, < 2.0)
|
||||
railties (= 4.2.11.3)
|
||||
sprockets-rails
|
||||
railties (4.2.11.3)
|
||||
actionpack (= 4.2.11.3)
|
||||
activesupport (= 4.2.11.3)
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.18.1, < 2.0)
|
||||
|
||||
PATH
|
||||
remote: ..
|
||||
specs:
|
||||
devise (4.7.2)
|
||||
bcrypt (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
railties (>= 4.1.0)
|
||||
responders
|
||||
warden (~> 1.2.3)
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
arel (6.0.4)
|
||||
bcrypt (3.1.13)
|
||||
bson (3.2.7)
|
||||
builder (3.2.4)
|
||||
concurrent-ruby (1.1.6)
|
||||
connection_pool (2.2.3)
|
||||
crass (1.0.6)
|
||||
erubis (2.7.0)
|
||||
faraday (1.0.1)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
globalid (0.4.2)
|
||||
activesupport (>= 4.2.0)
|
||||
hashie (4.1.0)
|
||||
i18n (0.9.5)
|
||||
concurrent-ruby (~> 1.0)
|
||||
jwt (2.2.1)
|
||||
loofah (2.5.0)
|
||||
crass (~> 1.0.2)
|
||||
nokogiri (>= 1.5.9)
|
||||
mail (2.7.1)
|
||||
mini_mime (>= 0.1.1)
|
||||
mini_mime (1.0.2)
|
||||
mini_portile2 (2.4.0)
|
||||
minitest (5.14.1)
|
||||
mocha (1.11.2)
|
||||
mongoid (4.0.2)
|
||||
activemodel (~> 4.0)
|
||||
moped (~> 2.0.0)
|
||||
origin (~> 2.1)
|
||||
tzinfo (>= 0.3.37)
|
||||
moped (2.0.7)
|
||||
bson (~> 3.0)
|
||||
connection_pool (~> 2.0)
|
||||
optionable (~> 0.2.0)
|
||||
multi_json (1.14.1)
|
||||
multi_xml (0.6.0)
|
||||
multipart-post (2.1.1)
|
||||
nokogiri (1.9.1)
|
||||
mini_portile2 (~> 2.4.0)
|
||||
oauth2 (1.4.4)
|
||||
faraday (>= 0.8, < 2.0)
|
||||
jwt (>= 1.0, < 3.0)
|
||||
multi_json (~> 1.3)
|
||||
multi_xml (~> 0.5)
|
||||
rack (>= 1.2, < 3)
|
||||
omniauth (1.9.1)
|
||||
hashie (>= 3.4.6)
|
||||
rack (>= 1.6.2, < 3)
|
||||
omniauth-facebook (6.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)
|
||||
optionable (0.2.0)
|
||||
origin (2.3.1)
|
||||
orm_adapter (0.5.0)
|
||||
rack (1.6.13)
|
||||
rack-openid (1.3.1)
|
||||
rack (>= 1.1.0)
|
||||
ruby-openid (>= 2.1.8)
|
||||
rack-test (0.6.3)
|
||||
rack (>= 1.0)
|
||||
rails-deprecated_sanitizer (1.0.3)
|
||||
activesupport (>= 4.2.0.alpha)
|
||||
rails-dom-testing (1.0.9)
|
||||
activesupport (>= 4.2.0, < 5.0)
|
||||
nokogiri (~> 1.6)
|
||||
rails-deprecated_sanitizer (>= 1.0.1)
|
||||
rails-html-sanitizer (1.3.0)
|
||||
loofah (~> 2.3)
|
||||
rake (13.0.1)
|
||||
rdoc (5.1.0)
|
||||
responders (2.4.1)
|
||||
actionpack (>= 4.2.0, < 6.0)
|
||||
railties (>= 4.2.0, < 6.0)
|
||||
ruby-openid (2.9.2)
|
||||
sprockets (4.0.1)
|
||||
concurrent-ruby (~> 1.0)
|
||||
rack (> 1, < 3)
|
||||
sprockets-rails (3.2.1)
|
||||
actionpack (>= 4.0)
|
||||
activesupport (>= 4.0)
|
||||
sprockets (>= 3.0.0)
|
||||
sqlite3 (1.3.13)
|
||||
test_after_commit (1.2.2)
|
||||
activerecord (>= 3.2, < 5.0)
|
||||
thor (1.0.1)
|
||||
thread_safe (0.3.6)
|
||||
timecop (0.9.1)
|
||||
tzinfo (1.2.7)
|
||||
thread_safe (~> 0.1)
|
||||
warden (1.2.7)
|
||||
rack (>= 1.0)
|
||||
webrat (0.7.3)
|
||||
nokogiri (>= 1.2.0)
|
||||
rack (>= 1.0)
|
||||
rack-test (>= 0.5.3)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
activerecord-jdbc-adapter
|
||||
activerecord-jdbcsqlite3-adapter
|
||||
devise!
|
||||
jruby-openssl
|
||||
mocha (~> 1.1)
|
||||
mongoid (~> 4.0)
|
||||
nokogiri (= 1.9.1)
|
||||
omniauth
|
||||
omniauth-facebook
|
||||
omniauth-oauth2
|
||||
omniauth-openid
|
||||
rails!
|
||||
rdoc (~> 5.1)
|
||||
sqlite3 (~> 1.3.6)
|
||||
test_after_commit
|
||||
timecop
|
||||
webrat (= 0.7.3)
|
||||
|
||||
BUNDLED WITH
|
||||
1.17.3
|
||||
@@ -1,190 +0,0 @@
|
||||
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.2)
|
||||
bcrypt (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
railties (>= 4.1.0)
|
||||
responders
|
||||
warden (~> 1.2.3)
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
actioncable (5.0.7.2)
|
||||
actionpack (= 5.0.7.2)
|
||||
nio4r (>= 1.2, < 3.0)
|
||||
websocket-driver (~> 0.6.1)
|
||||
actionmailer (5.0.7.2)
|
||||
actionpack (= 5.0.7.2)
|
||||
actionview (= 5.0.7.2)
|
||||
activejob (= 5.0.7.2)
|
||||
mail (~> 2.5, >= 2.5.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
actionpack (5.0.7.2)
|
||||
actionview (= 5.0.7.2)
|
||||
activesupport (= 5.0.7.2)
|
||||
rack (~> 2.0)
|
||||
rack-test (~> 0.6.3)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||
actionview (5.0.7.2)
|
||||
activesupport (= 5.0.7.2)
|
||||
builder (~> 3.1)
|
||||
erubis (~> 2.7.0)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
||||
activejob (5.0.7.2)
|
||||
activesupport (= 5.0.7.2)
|
||||
globalid (>= 0.3.6)
|
||||
activemodel (5.0.7.2)
|
||||
activesupport (= 5.0.7.2)
|
||||
activerecord (5.0.7.2)
|
||||
activemodel (= 5.0.7.2)
|
||||
activesupport (= 5.0.7.2)
|
||||
arel (~> 7.0)
|
||||
activesupport (5.0.7.2)
|
||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||
i18n (>= 0.7, < 2)
|
||||
minitest (~> 5.1)
|
||||
tzinfo (~> 1.1)
|
||||
arel (7.1.4)
|
||||
bcrypt (3.1.13)
|
||||
builder (3.2.4)
|
||||
concurrent-ruby (1.1.6)
|
||||
crass (1.0.6)
|
||||
erubis (2.7.0)
|
||||
faraday (1.0.1)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
globalid (0.4.2)
|
||||
activesupport (>= 4.2.0)
|
||||
hashie (4.1.0)
|
||||
i18n (1.8.3)
|
||||
concurrent-ruby (~> 1.0)
|
||||
jwt (2.2.1)
|
||||
loofah (2.5.0)
|
||||
crass (~> 1.0.2)
|
||||
nokogiri (>= 1.5.9)
|
||||
mail (2.7.1)
|
||||
mini_mime (>= 0.1.1)
|
||||
method_source (1.0.0)
|
||||
mini_mime (1.0.2)
|
||||
mini_portile2 (2.4.0)
|
||||
minitest (5.14.1)
|
||||
mocha (1.11.2)
|
||||
multi_json (1.14.1)
|
||||
multi_xml (0.6.0)
|
||||
multipart-post (2.1.1)
|
||||
nio4r (2.5.2)
|
||||
nokogiri (1.10.9)
|
||||
mini_portile2 (~> 2.4.0)
|
||||
oauth2 (1.4.4)
|
||||
faraday (>= 0.8, < 2.0)
|
||||
jwt (>= 1.0, < 3.0)
|
||||
multi_json (~> 1.3)
|
||||
multi_xml (~> 0.5)
|
||||
rack (>= 1.2, < 3)
|
||||
omniauth (1.9.1)
|
||||
hashie (>= 3.4.6)
|
||||
rack (>= 1.6.2, < 3)
|
||||
omniauth-facebook (6.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.2.2)
|
||||
rack-openid (1.3.1)
|
||||
rack (>= 1.1.0)
|
||||
ruby-openid (>= 2.1.8)
|
||||
rack-test (0.6.3)
|
||||
rack (>= 1.0)
|
||||
rails (5.0.7.2)
|
||||
actioncable (= 5.0.7.2)
|
||||
actionmailer (= 5.0.7.2)
|
||||
actionpack (= 5.0.7.2)
|
||||
actionview (= 5.0.7.2)
|
||||
activejob (= 5.0.7.2)
|
||||
activemodel (= 5.0.7.2)
|
||||
activerecord (= 5.0.7.2)
|
||||
activesupport (= 5.0.7.2)
|
||||
bundler (>= 1.3.0)
|
||||
railties (= 5.0.7.2)
|
||||
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.3.0)
|
||||
loofah (~> 2.3)
|
||||
railties (5.0.7.2)
|
||||
actionpack (= 5.0.7.2)
|
||||
activesupport (= 5.0.7.2)
|
||||
method_source
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.18.1, < 2.0)
|
||||
rake (13.0.1)
|
||||
rdoc (6.2.1)
|
||||
responders (2.4.1)
|
||||
actionpack (>= 4.2.0, < 6.0)
|
||||
railties (>= 4.2.0, < 6.0)
|
||||
ruby-openid (2.9.2)
|
||||
sprockets (4.0.1)
|
||||
concurrent-ruby (~> 1.0)
|
||||
rack (> 1, < 3)
|
||||
sprockets-rails (3.2.1)
|
||||
actionpack (>= 4.0)
|
||||
activesupport (>= 4.0)
|
||||
sprockets (>= 3.0.0)
|
||||
sqlite3 (1.3.13)
|
||||
thor (1.0.1)
|
||||
thread_safe (0.3.6)
|
||||
timecop (0.9.1)
|
||||
tzinfo (1.2.7)
|
||||
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.6.5)
|
||||
websocket-extensions (>= 0.1.0)
|
||||
websocket-extensions (0.1.5)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
activemodel-serializers-xml!
|
||||
devise!
|
||||
mocha (~> 1.1)
|
||||
omniauth
|
||||
omniauth-facebook
|
||||
omniauth-oauth2
|
||||
omniauth-openid
|
||||
rails (~> 5.0.0)
|
||||
rails-controller-testing
|
||||
rdoc
|
||||
responders (~> 2.1)
|
||||
sqlite3 (~> 1.3.6)
|
||||
timecop
|
||||
webrat (= 0.7.3)
|
||||
|
||||
BUNDLED WITH
|
||||
1.17.3
|
||||
@@ -1,190 +0,0 @@
|
||||
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.2)
|
||||
bcrypt (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
railties (>= 4.1.0)
|
||||
responders
|
||||
warden (~> 1.2.3)
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
actioncable (5.1.7)
|
||||
actionpack (= 5.1.7)
|
||||
nio4r (~> 2.0)
|
||||
websocket-driver (~> 0.6.1)
|
||||
actionmailer (5.1.7)
|
||||
actionpack (= 5.1.7)
|
||||
actionview (= 5.1.7)
|
||||
activejob (= 5.1.7)
|
||||
mail (~> 2.5, >= 2.5.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
actionpack (5.1.7)
|
||||
actionview (= 5.1.7)
|
||||
activesupport (= 5.1.7)
|
||||
rack (~> 2.0)
|
||||
rack-test (>= 0.6.3)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||
actionview (5.1.7)
|
||||
activesupport (= 5.1.7)
|
||||
builder (~> 3.1)
|
||||
erubi (~> 1.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
||||
activejob (5.1.7)
|
||||
activesupport (= 5.1.7)
|
||||
globalid (>= 0.3.6)
|
||||
activemodel (5.1.7)
|
||||
activesupport (= 5.1.7)
|
||||
activerecord (5.1.7)
|
||||
activemodel (= 5.1.7)
|
||||
activesupport (= 5.1.7)
|
||||
arel (~> 8.0)
|
||||
activesupport (5.1.7)
|
||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||
i18n (>= 0.7, < 2)
|
||||
minitest (~> 5.1)
|
||||
tzinfo (~> 1.1)
|
||||
arel (8.0.0)
|
||||
bcrypt (3.1.13)
|
||||
builder (3.2.4)
|
||||
concurrent-ruby (1.1.6)
|
||||
crass (1.0.6)
|
||||
erubi (1.9.0)
|
||||
faraday (1.0.1)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
globalid (0.4.2)
|
||||
activesupport (>= 4.2.0)
|
||||
hashie (4.1.0)
|
||||
i18n (1.8.3)
|
||||
concurrent-ruby (~> 1.0)
|
||||
jwt (2.2.1)
|
||||
loofah (2.5.0)
|
||||
crass (~> 1.0.2)
|
||||
nokogiri (>= 1.5.9)
|
||||
mail (2.7.1)
|
||||
mini_mime (>= 0.1.1)
|
||||
method_source (1.0.0)
|
||||
mini_mime (1.0.2)
|
||||
mini_portile2 (2.4.0)
|
||||
minitest (5.14.1)
|
||||
mocha (1.11.2)
|
||||
multi_json (1.14.1)
|
||||
multi_xml (0.6.0)
|
||||
multipart-post (2.1.1)
|
||||
nio4r (2.5.2)
|
||||
nokogiri (1.10.9)
|
||||
mini_portile2 (~> 2.4.0)
|
||||
oauth2 (1.4.4)
|
||||
faraday (>= 0.8, < 2.0)
|
||||
jwt (>= 1.0, < 3.0)
|
||||
multi_json (~> 1.3)
|
||||
multi_xml (~> 0.5)
|
||||
rack (>= 1.2, < 3)
|
||||
omniauth (1.9.1)
|
||||
hashie (>= 3.4.6)
|
||||
rack (>= 1.6.2, < 3)
|
||||
omniauth-facebook (6.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.2.2)
|
||||
rack-openid (1.3.1)
|
||||
rack (>= 1.1.0)
|
||||
ruby-openid (>= 2.1.8)
|
||||
rack-test (1.1.0)
|
||||
rack (>= 1.0, < 3)
|
||||
rails (5.1.7)
|
||||
actioncable (= 5.1.7)
|
||||
actionmailer (= 5.1.7)
|
||||
actionpack (= 5.1.7)
|
||||
actionview (= 5.1.7)
|
||||
activejob (= 5.1.7)
|
||||
activemodel (= 5.1.7)
|
||||
activerecord (= 5.1.7)
|
||||
activesupport (= 5.1.7)
|
||||
bundler (>= 1.3.0)
|
||||
railties (= 5.1.7)
|
||||
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.3.0)
|
||||
loofah (~> 2.3)
|
||||
railties (5.1.7)
|
||||
actionpack (= 5.1.7)
|
||||
activesupport (= 5.1.7)
|
||||
method_source
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.18.1, < 2.0)
|
||||
rake (13.0.1)
|
||||
rdoc (6.2.1)
|
||||
responders (2.4.1)
|
||||
actionpack (>= 4.2.0, < 6.0)
|
||||
railties (>= 4.2.0, < 6.0)
|
||||
ruby-openid (2.9.2)
|
||||
sprockets (4.0.1)
|
||||
concurrent-ruby (~> 1.0)
|
||||
rack (> 1, < 3)
|
||||
sprockets-rails (3.2.1)
|
||||
actionpack (>= 4.0)
|
||||
activesupport (>= 4.0)
|
||||
sprockets (>= 3.0.0)
|
||||
sqlite3 (1.3.13)
|
||||
thor (1.0.1)
|
||||
thread_safe (0.3.6)
|
||||
timecop (0.9.1)
|
||||
tzinfo (1.2.7)
|
||||
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.6.5)
|
||||
websocket-extensions (>= 0.1.0)
|
||||
websocket-extensions (0.1.5)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
activemodel-serializers-xml!
|
||||
devise!
|
||||
mocha (~> 1.1)
|
||||
omniauth
|
||||
omniauth-facebook
|
||||
omniauth-oauth2
|
||||
omniauth-openid
|
||||
rails (~> 5.1.0)
|
||||
rails-controller-testing
|
||||
rdoc
|
||||
responders (~> 2.1)
|
||||
sqlite3 (~> 1.3.6)
|
||||
timecop
|
||||
webrat (= 0.7.3)
|
||||
|
||||
BUNDLED WITH
|
||||
1.17.3
|
||||
@@ -1,198 +0,0 @@
|
||||
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.2)
|
||||
bcrypt (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
railties (>= 4.1.0)
|
||||
responders
|
||||
warden (~> 1.2.3)
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
actioncable (5.2.4.3)
|
||||
actionpack (= 5.2.4.3)
|
||||
nio4r (~> 2.0)
|
||||
websocket-driver (>= 0.6.1)
|
||||
actionmailer (5.2.4.3)
|
||||
actionpack (= 5.2.4.3)
|
||||
actionview (= 5.2.4.3)
|
||||
activejob (= 5.2.4.3)
|
||||
mail (~> 2.5, >= 2.5.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
actionpack (5.2.4.3)
|
||||
actionview (= 5.2.4.3)
|
||||
activesupport (= 5.2.4.3)
|
||||
rack (~> 2.0, >= 2.0.8)
|
||||
rack-test (>= 0.6.3)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||
actionview (5.2.4.3)
|
||||
activesupport (= 5.2.4.3)
|
||||
builder (~> 3.1)
|
||||
erubi (~> 1.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
||||
activejob (5.2.4.3)
|
||||
activesupport (= 5.2.4.3)
|
||||
globalid (>= 0.3.6)
|
||||
activemodel (5.2.4.3)
|
||||
activesupport (= 5.2.4.3)
|
||||
activerecord (5.2.4.3)
|
||||
activemodel (= 5.2.4.3)
|
||||
activesupport (= 5.2.4.3)
|
||||
arel (>= 9.0)
|
||||
activestorage (5.2.4.3)
|
||||
actionpack (= 5.2.4.3)
|
||||
activerecord (= 5.2.4.3)
|
||||
marcel (~> 0.3.1)
|
||||
activesupport (5.2.4.3)
|
||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||
i18n (>= 0.7, < 2)
|
||||
minitest (~> 5.1)
|
||||
tzinfo (~> 1.1)
|
||||
arel (9.0.0)
|
||||
bcrypt (3.1.13)
|
||||
builder (3.2.4)
|
||||
concurrent-ruby (1.1.6)
|
||||
crass (1.0.6)
|
||||
erubi (1.9.0)
|
||||
faraday (1.0.1)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
globalid (0.4.2)
|
||||
activesupport (>= 4.2.0)
|
||||
hashie (4.1.0)
|
||||
i18n (1.8.3)
|
||||
concurrent-ruby (~> 1.0)
|
||||
jwt (2.2.1)
|
||||
loofah (2.5.0)
|
||||
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)
|
||||
method_source (1.0.0)
|
||||
mimemagic (0.3.5)
|
||||
mini_mime (1.0.2)
|
||||
mini_portile2 (2.4.0)
|
||||
minitest (5.14.1)
|
||||
mocha (1.11.2)
|
||||
multi_json (1.14.1)
|
||||
multi_xml (0.6.0)
|
||||
multipart-post (2.1.1)
|
||||
nio4r (2.5.2)
|
||||
nokogiri (1.10.9)
|
||||
mini_portile2 (~> 2.4.0)
|
||||
oauth2 (1.4.4)
|
||||
faraday (>= 0.8, < 2.0)
|
||||
jwt (>= 1.0, < 3.0)
|
||||
multi_json (~> 1.3)
|
||||
multi_xml (~> 0.5)
|
||||
rack (>= 1.2, < 3)
|
||||
omniauth (1.9.1)
|
||||
hashie (>= 3.4.6)
|
||||
rack (>= 1.6.2, < 3)
|
||||
omniauth-facebook (6.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.2.2)
|
||||
rack-openid (1.3.1)
|
||||
rack (>= 1.1.0)
|
||||
ruby-openid (>= 2.1.8)
|
||||
rack-test (1.1.0)
|
||||
rack (>= 1.0, < 3)
|
||||
rails (5.2.4.3)
|
||||
actioncable (= 5.2.4.3)
|
||||
actionmailer (= 5.2.4.3)
|
||||
actionpack (= 5.2.4.3)
|
||||
actionview (= 5.2.4.3)
|
||||
activejob (= 5.2.4.3)
|
||||
activemodel (= 5.2.4.3)
|
||||
activerecord (= 5.2.4.3)
|
||||
activestorage (= 5.2.4.3)
|
||||
activesupport (= 5.2.4.3)
|
||||
bundler (>= 1.3.0)
|
||||
railties (= 5.2.4.3)
|
||||
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.3.0)
|
||||
loofah (~> 2.3)
|
||||
railties (5.2.4.3)
|
||||
actionpack (= 5.2.4.3)
|
||||
activesupport (= 5.2.4.3)
|
||||
method_source
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.19.0, < 2.0)
|
||||
rake (13.0.1)
|
||||
rdoc (6.2.1)
|
||||
responders (2.4.1)
|
||||
actionpack (>= 4.2.0, < 6.0)
|
||||
railties (>= 4.2.0, < 6.0)
|
||||
ruby-openid (2.9.2)
|
||||
sprockets (4.0.1)
|
||||
concurrent-ruby (~> 1.0)
|
||||
rack (> 1, < 3)
|
||||
sprockets-rails (3.2.1)
|
||||
actionpack (>= 4.0)
|
||||
activesupport (>= 4.0)
|
||||
sprockets (>= 3.0.0)
|
||||
sqlite3 (1.3.13)
|
||||
thor (1.0.1)
|
||||
thread_safe (0.3.6)
|
||||
timecop (0.9.1)
|
||||
tzinfo (1.2.7)
|
||||
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.2)
|
||||
websocket-extensions (>= 0.1.0)
|
||||
websocket-extensions (0.1.5)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
activemodel-serializers-xml!
|
||||
devise!
|
||||
mocha (~> 1.1)
|
||||
omniauth
|
||||
omniauth-facebook
|
||||
omniauth-oauth2
|
||||
omniauth-openid
|
||||
rails (~> 5.2.0)
|
||||
rails-controller-testing
|
||||
rdoc
|
||||
responders (~> 2.1)
|
||||
sqlite3 (~> 1.3.6)
|
||||
timecop
|
||||
webrat (= 0.7.3)
|
||||
|
||||
BUNDLED WITH
|
||||
1.17.3
|
||||
@@ -1,219 +0,0 @@
|
||||
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)
|
||||
|
||||
GIT
|
||||
remote: git://github.com/rails/rails-controller-testing.git
|
||||
revision: a60b3da1c1c77959b28606dd087c058c64b5a08f
|
||||
specs:
|
||||
rails-controller-testing (1.0.4)
|
||||
actionpack (>= 5.0.1.rc1)
|
||||
actionview (>= 5.0.1.rc1)
|
||||
activesupport (>= 5.0.1.rc1)
|
||||
|
||||
PATH
|
||||
remote: ..
|
||||
specs:
|
||||
devise (4.7.2)
|
||||
bcrypt (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
railties (>= 4.1.0)
|
||||
responders
|
||||
warden (~> 1.2.3)
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
actioncable (6.0.3.1)
|
||||
actionpack (= 6.0.3.1)
|
||||
nio4r (~> 2.0)
|
||||
websocket-driver (>= 0.6.1)
|
||||
actionmailbox (6.0.3.1)
|
||||
actionpack (= 6.0.3.1)
|
||||
activejob (= 6.0.3.1)
|
||||
activerecord (= 6.0.3.1)
|
||||
activestorage (= 6.0.3.1)
|
||||
activesupport (= 6.0.3.1)
|
||||
mail (>= 2.7.1)
|
||||
actionmailer (6.0.3.1)
|
||||
actionpack (= 6.0.3.1)
|
||||
actionview (= 6.0.3.1)
|
||||
activejob (= 6.0.3.1)
|
||||
mail (~> 2.5, >= 2.5.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
actionpack (6.0.3.1)
|
||||
actionview (= 6.0.3.1)
|
||||
activesupport (= 6.0.3.1)
|
||||
rack (~> 2.0, >= 2.0.8)
|
||||
rack-test (>= 0.6.3)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
||||
actiontext (6.0.3.1)
|
||||
actionpack (= 6.0.3.1)
|
||||
activerecord (= 6.0.3.1)
|
||||
activestorage (= 6.0.3.1)
|
||||
activesupport (= 6.0.3.1)
|
||||
nokogiri (>= 1.8.5)
|
||||
actionview (6.0.3.1)
|
||||
activesupport (= 6.0.3.1)
|
||||
builder (~> 3.1)
|
||||
erubi (~> 1.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
||||
activejob (6.0.3.1)
|
||||
activesupport (= 6.0.3.1)
|
||||
globalid (>= 0.3.6)
|
||||
activemodel (6.0.3.1)
|
||||
activesupport (= 6.0.3.1)
|
||||
activerecord (6.0.3.1)
|
||||
activemodel (= 6.0.3.1)
|
||||
activesupport (= 6.0.3.1)
|
||||
activestorage (6.0.3.1)
|
||||
actionpack (= 6.0.3.1)
|
||||
activejob (= 6.0.3.1)
|
||||
activerecord (= 6.0.3.1)
|
||||
marcel (~> 0.3.1)
|
||||
activesupport (6.0.3.1)
|
||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||
i18n (>= 0.7, < 2)
|
||||
minitest (~> 5.1)
|
||||
tzinfo (~> 1.1)
|
||||
zeitwerk (~> 2.2, >= 2.2.2)
|
||||
bcrypt (3.1.13)
|
||||
builder (3.2.4)
|
||||
concurrent-ruby (1.1.6)
|
||||
crass (1.0.6)
|
||||
erubi (1.9.0)
|
||||
faraday (1.0.1)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
globalid (0.4.2)
|
||||
activesupport (>= 4.2.0)
|
||||
hashie (4.1.0)
|
||||
i18n (1.8.3)
|
||||
concurrent-ruby (~> 1.0)
|
||||
jwt (2.2.1)
|
||||
loofah (2.5.0)
|
||||
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)
|
||||
method_source (1.0.0)
|
||||
mimemagic (0.3.5)
|
||||
mini_mime (1.0.2)
|
||||
mini_portile2 (2.4.0)
|
||||
minitest (5.14.1)
|
||||
mocha (1.11.2)
|
||||
multi_json (1.14.1)
|
||||
multi_xml (0.6.0)
|
||||
multipart-post (2.1.1)
|
||||
nio4r (2.5.2)
|
||||
nokogiri (1.10.9)
|
||||
mini_portile2 (~> 2.4.0)
|
||||
oauth2 (1.4.4)
|
||||
faraday (>= 0.8, < 2.0)
|
||||
jwt (>= 1.0, < 3.0)
|
||||
multi_json (~> 1.3)
|
||||
multi_xml (~> 0.5)
|
||||
rack (>= 1.2, < 3)
|
||||
omniauth (1.9.1)
|
||||
hashie (>= 3.4.6)
|
||||
rack (>= 1.6.2, < 3)
|
||||
omniauth-facebook (6.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.2.2)
|
||||
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.3.1)
|
||||
actioncable (= 6.0.3.1)
|
||||
actionmailbox (= 6.0.3.1)
|
||||
actionmailer (= 6.0.3.1)
|
||||
actionpack (= 6.0.3.1)
|
||||
actiontext (= 6.0.3.1)
|
||||
actionview (= 6.0.3.1)
|
||||
activejob (= 6.0.3.1)
|
||||
activemodel (= 6.0.3.1)
|
||||
activerecord (= 6.0.3.1)
|
||||
activestorage (= 6.0.3.1)
|
||||
activesupport (= 6.0.3.1)
|
||||
bundler (>= 1.3.0)
|
||||
railties (= 6.0.3.1)
|
||||
sprockets-rails (>= 2.0.0)
|
||||
rails-dom-testing (2.0.3)
|
||||
activesupport (>= 4.2.0)
|
||||
nokogiri (>= 1.6)
|
||||
rails-html-sanitizer (1.3.0)
|
||||
loofah (~> 2.3)
|
||||
railties (6.0.3.1)
|
||||
actionpack (= 6.0.3.1)
|
||||
activesupport (= 6.0.3.1)
|
||||
method_source
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.20.3, < 2.0)
|
||||
rake (13.0.1)
|
||||
rdoc (6.2.1)
|
||||
responders (3.0.1)
|
||||
actionpack (>= 5.0)
|
||||
railties (>= 5.0)
|
||||
ruby-openid (2.9.2)
|
||||
sprockets (4.0.1)
|
||||
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.2)
|
||||
thor (1.0.1)
|
||||
thread_safe (0.3.6)
|
||||
timecop (0.9.1)
|
||||
tzinfo (1.2.7)
|
||||
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.2)
|
||||
websocket-extensions (>= 0.1.0)
|
||||
websocket-extensions (0.1.5)
|
||||
zeitwerk (2.3.0)
|
||||
|
||||
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)
|
||||
timecop
|
||||
webrat (= 0.7.3)
|
||||
|
||||
BUNDLED WITH
|
||||
1.17.3
|
||||
@@ -13,6 +13,7 @@ module Devise
|
||||
autoload :Encryptor, 'devise/encryptor'
|
||||
autoload :FailureApp, 'devise/failure_app'
|
||||
autoload :OmniAuth, 'devise/omniauth'
|
||||
autoload :Orm, 'devise/orm'
|
||||
autoload :ParameterFilter, 'devise/parameter_filter'
|
||||
autoload :ParameterSanitizer, 'devise/parameter_sanitizer'
|
||||
autoload :TestHelpers, 'devise/test_helpers'
|
||||
@@ -23,6 +24,7 @@ module Devise
|
||||
module Controllers
|
||||
autoload :Helpers, 'devise/controllers/helpers'
|
||||
autoload :Rememberable, 'devise/controllers/rememberable'
|
||||
autoload :Responder, 'devise/controllers/responder'
|
||||
autoload :ScopedViews, 'devise/controllers/scoped_views'
|
||||
autoload :SignInOut, 'devise/controllers/sign_in_out'
|
||||
autoload :StoreLocation, 'devise/controllers/store_location'
|
||||
@@ -217,7 +219,16 @@ module Devise
|
||||
|
||||
# Which formats should be treated as navigational.
|
||||
mattr_accessor :navigational_formats
|
||||
@@navigational_formats = ["*/*", :html]
|
||||
@@navigational_formats = ["*/*", :html, :turbo_stream]
|
||||
|
||||
# The default responder used by Devise, used to customize status codes with:
|
||||
#
|
||||
# `config.responder.error_status`
|
||||
# `config.responder.redirect_status`
|
||||
#
|
||||
# Can be replaced by a custom application responder.
|
||||
mattr_accessor :responder
|
||||
@@responder = Devise::Controllers::Responder
|
||||
|
||||
# When set to true, signing out a user signs out all other scopes.
|
||||
mattr_accessor :sign_out_all_scopes
|
||||
@@ -297,10 +308,6 @@ module Devise
|
||||
mattr_accessor :sign_in_after_change_password
|
||||
@@sign_in_after_change_password = true
|
||||
|
||||
def self.activerecord51? # :nodoc:
|
||||
defined?(ActiveRecord) && ActiveRecord.gem_version >= Gem::Version.new("5.1.x")
|
||||
end
|
||||
|
||||
# Default way to set up Devise. Run rails generate devise_install to create
|
||||
# a fresh initializer with all configuration values.
|
||||
def self.setup
|
||||
@@ -313,12 +320,20 @@ module Devise
|
||||
end
|
||||
|
||||
def get
|
||||
ActiveSupport::Dependencies.constantize(@name)
|
||||
# TODO: Remove AS::Dependencies usage when dropping support to Rails < 7.
|
||||
if ActiveSupport::Dependencies.respond_to?(:constantize)
|
||||
ActiveSupport::Dependencies.constantize(@name)
|
||||
else
|
||||
@name.constantize
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.ref(arg)
|
||||
ActiveSupport::Dependencies.reference(arg)
|
||||
# TODO: Remove AS::Dependencies usage when dropping support to Rails < 7.
|
||||
if ActiveSupport::Dependencies.respond_to?(:reference)
|
||||
ActiveSupport::Dependencies.reference(arg)
|
||||
end
|
||||
Getter.new(arg)
|
||||
end
|
||||
|
||||
|
||||
@@ -36,14 +36,14 @@ module Devise
|
||||
# before_action ->{ authenticate_blogger! :admin } # Redirects to the admin login page
|
||||
# current_blogger :user # Preferably returns a User if one is signed in
|
||||
#
|
||||
def devise_group(group_name, opts={})
|
||||
def devise_group(group_name, opts = {})
|
||||
mappings = "[#{ opts[:contains].map { |m| ":#{m}" }.join(',') }]"
|
||||
|
||||
class_eval <<-METHODS, __FILE__, __LINE__ + 1
|
||||
def authenticate_#{group_name}!(favourite=nil, opts={})
|
||||
def authenticate_#{group_name}!(favorite = nil, opts = {})
|
||||
unless #{group_name}_signed_in?
|
||||
mappings = #{mappings}
|
||||
mappings.unshift mappings.delete(favourite.to_sym) if favourite
|
||||
mappings.unshift mappings.delete(favorite.to_sym) if favorite
|
||||
mappings.each do |mapping|
|
||||
opts[:scope] = mapping
|
||||
warden.authenticate!(opts) if !devise_controller? || opts.delete(:force)
|
||||
@@ -57,9 +57,9 @@ module Devise
|
||||
end
|
||||
end
|
||||
|
||||
def current_#{group_name}(favourite=nil)
|
||||
def current_#{group_name}(favorite = nil)
|
||||
mappings = #{mappings}
|
||||
mappings.unshift mappings.delete(favourite.to_sym) if favourite
|
||||
mappings.unshift mappings.delete(favorite.to_sym) if favorite
|
||||
mappings.each do |mapping|
|
||||
current = warden.authenticate(scope: mapping)
|
||||
return current if current
|
||||
@@ -113,7 +113,7 @@ module Devise
|
||||
mapping = mapping.name
|
||||
|
||||
class_eval <<-METHODS, __FILE__, __LINE__ + 1
|
||||
def authenticate_#{mapping}!(opts={})
|
||||
def authenticate_#{mapping}!(opts = {})
|
||||
opts[:scope] = :#{mapping}
|
||||
warden.authenticate!(opts) if !devise_controller? || opts.delete(:force)
|
||||
end
|
||||
@@ -252,7 +252,7 @@ module Devise
|
||||
# Overwrite Rails' handle unverified request to sign out all scopes,
|
||||
# clear run strategies and remove cached variables.
|
||||
def handle_unverified_request
|
||||
super # call the default behaviour which resets/nullifies/raises
|
||||
super # call the default behavior which resets/nullifies/raises
|
||||
request.env["devise.skip_storage"] = true
|
||||
sign_out_all_scopes(false)
|
||||
end
|
||||
|
||||
35
lib/devise/controllers/responder.rb
Normal file
35
lib/devise/controllers/responder.rb
Normal file
@@ -0,0 +1,35 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Devise
|
||||
module Controllers
|
||||
# Custom Responder to configure default statuses that only apply to Devise,
|
||||
# and allow to integrate more easily with Hotwire/Turbo.
|
||||
class Responder < ActionController::Responder
|
||||
if respond_to?(:error_status=) && respond_to?(:redirect_status=)
|
||||
self.error_status = :ok
|
||||
self.redirect_status = :found
|
||||
else
|
||||
# TODO: remove this support for older Rails versions, which aren't supported by Turbo
|
||||
# and/or responders. It won't allow configuring a custom response, but it allows Devise
|
||||
# to use these methods and defaults across the implementation more easily.
|
||||
def self.error_status
|
||||
:ok
|
||||
end
|
||||
|
||||
def self.redirect_status
|
||||
:found
|
||||
end
|
||||
|
||||
def self.error_status=(*)
|
||||
warn "[DEVISE] Setting the error status on the Devise responder has no effect with this " \
|
||||
"version of `responders`, please make sure you're using a newer version. Check the changelog for more info."
|
||||
end
|
||||
|
||||
def self.redirect_status=(*)
|
||||
warn "[DEVISE] Setting the redirect status on the Devise responder has no effect with this " \
|
||||
"version of `responders`, please make sure you're using a newer version. Check the changelog for more info."
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -10,7 +10,7 @@ module Devise
|
||||
# cause exceptions to be thrown from this method; if you simply want to check
|
||||
# if a scope has already previously been authenticated without running
|
||||
# authentication hooks, you can directly call `warden.authenticated?(scope: scope)`
|
||||
def signed_in?(scope=nil)
|
||||
def signed_in?(scope = nil)
|
||||
[scope || Devise.mappings.keys].flatten.any? do |_scope|
|
||||
warden.authenticate?(scope: _scope)
|
||||
end
|
||||
@@ -21,7 +21,7 @@ module Devise
|
||||
# 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/heartcombo/devise/blob/master/app/controllers/devise/sessions_controller.rb#L7
|
||||
# in the sessions controller: https://github.com/heartcombo/devise/blob/main/app/controllers/devise/sessions_controller.rb#L7
|
||||
#
|
||||
# Examples:
|
||||
#
|
||||
@@ -77,7 +77,7 @@ module Devise
|
||||
# sign_out :user # sign_out(scope)
|
||||
# sign_out @user # sign_out(resource)
|
||||
#
|
||||
def sign_out(resource_or_scope=nil)
|
||||
def sign_out(resource_or_scope = nil)
|
||||
return sign_out_all_scopes unless resource_or_scope
|
||||
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
||||
user = warden.user(scope: scope, run_callbacks: false) # If there is no user
|
||||
@@ -92,7 +92,7 @@ module Devise
|
||||
# Sign out all active users or scopes. This helper is useful for signing out all roles
|
||||
# in one click. This signs out ALL scopes in warden. Returns true if there was at least one logout
|
||||
# and false if there was no user logged in on all scopes.
|
||||
def sign_out_all_scopes(lock=true)
|
||||
def sign_out_all_scopes(lock = true)
|
||||
users = Devise.mappings.keys.map { |s| warden.user(scope: s, run_callbacks: false) }
|
||||
|
||||
warden.logout
|
||||
@@ -106,10 +106,12 @@ module Devise
|
||||
private
|
||||
|
||||
def expire_data_after_sign_in!
|
||||
# TODO: remove once Rails 5.2+ and forward are only supported.
|
||||
# session.keys will return an empty array if the session is not yet loaded.
|
||||
# This is a bug in both Rack and Rails.
|
||||
# A call to #empty? forces the session to be loaded.
|
||||
session.empty?
|
||||
|
||||
session.keys.grep(/^devise\./).each { |k| session.delete(k) }
|
||||
end
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ module Devise
|
||||
end
|
||||
end
|
||||
|
||||
def self.generate_helpers!(routes=nil)
|
||||
def self.generate_helpers!(routes = nil)
|
||||
routes ||= begin
|
||||
mappings = Devise.mappings.values.map(&:used_helpers).flatten.uniq
|
||||
Devise::URL_HELPERS.slice(*mappings)
|
||||
|
||||
@@ -71,8 +71,11 @@ module Devise
|
||||
end
|
||||
|
||||
flash.now[:alert] = i18n_message(:invalid) if is_flashing_format?
|
||||
# self.response = recall_app(warden_options[:recall]).call(env)
|
||||
self.response = recall_app(warden_options[:recall]).call(request.env)
|
||||
self.response = recall_app(warden_options[:recall]).call(request.env).tap { |response|
|
||||
response[0] = Rack::Utils.status_code(
|
||||
response[0].in?(300..399) ? Devise.responder.redirect_status : Devise.responder.error_status
|
||||
)
|
||||
}
|
||||
end
|
||||
|
||||
def redirect
|
||||
@@ -168,7 +171,7 @@ module Devise
|
||||
end
|
||||
|
||||
def skip_format?
|
||||
%w(html */*).include? request_format.to_s
|
||||
%w(html */* turbo_stream).include? request_format.to_s
|
||||
end
|
||||
|
||||
# Choose whether we should respond in an HTTP authentication fashion,
|
||||
|
||||
@@ -4,6 +4,11 @@ Warden::Manager.after_authentication do |record, warden, options|
|
||||
clean_up_for_winning_strategy = !warden.winning_strategy.respond_to?(:clean_up_csrf?) ||
|
||||
warden.winning_strategy.clean_up_csrf?
|
||||
if Devise.clean_up_csrf_token_on_authentication && clean_up_for_winning_strategy
|
||||
warden.request.session.try(:delete, :_csrf_token)
|
||||
if warden.request.respond_to?(:reset_csrf_token)
|
||||
# Rails 7.1+
|
||||
warden.request.reset_csrf_token
|
||||
else
|
||||
warden.request.session.try(:delete, :_csrf_token)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,10 +3,7 @@
|
||||
# After each sign in, if resource responds to failed_attempts, sets it to 0
|
||||
# This is only triggered when the user is explicitly set (with set_user)
|
||||
Warden::Manager.after_set_user except: :fetch do |record, warden, options|
|
||||
if record.respond_to?(:failed_attempts) && warden.authenticated?(options[:scope])
|
||||
unless record.failed_attempts.to_i.zero?
|
||||
record.failed_attempts = 0
|
||||
record.save(validate: false)
|
||||
end
|
||||
if record.respond_to?(:reset_failed_attempts!) && warden.authenticated?(options[:scope])
|
||||
record.reset_failed_attempts!
|
||||
end
|
||||
end
|
||||
|
||||
@@ -46,7 +46,7 @@ module Devise
|
||||
raise "Could not find a valid mapping for #{obj.inspect}"
|
||||
end
|
||||
|
||||
def self.find_by_path!(path, path_type=:fullpath)
|
||||
def self.find_by_path!(path, path_type = :fullpath)
|
||||
Devise.mappings.each_value { |m| return m if path.include?(m.send(path_type)) }
|
||||
raise "Could not find a valid mapping for path #{path.inspect}"
|
||||
end
|
||||
|
||||
@@ -84,6 +84,7 @@ module Devise
|
||||
end
|
||||
|
||||
devise_modules_hook! do
|
||||
include Devise::Orm
|
||||
include Devise::Models::Authenticatable
|
||||
|
||||
selected_modules.each do |m|
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
require 'devise/hooks/activatable'
|
||||
require 'devise/hooks/csrf_cleaner'
|
||||
require 'devise/rails/deprecated_constant_accessor'
|
||||
|
||||
module Devise
|
||||
module Models
|
||||
@@ -9,7 +10,7 @@ module Devise
|
||||
#
|
||||
# == Options
|
||||
#
|
||||
# Authenticatable adds the following options to devise_for:
|
||||
# Authenticatable adds the following options to +devise+:
|
||||
#
|
||||
# * +authentication_keys+: parameters used for authentication. By default [:email].
|
||||
#
|
||||
@@ -55,11 +56,14 @@ module Devise
|
||||
module Authenticatable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
BLACKLIST_FOR_SERIALIZATION = [:encrypted_password, :reset_password_token, :reset_password_sent_at,
|
||||
UNSAFE_ATTRIBUTES_FOR_SERIALIZATION = [:encrypted_password, :reset_password_token, :reset_password_sent_at,
|
||||
:remember_created_at, :sign_in_count, :current_sign_in_at, :last_sign_in_at, :current_sign_in_ip,
|
||||
:last_sign_in_ip, :password_salt, :confirmation_token, :confirmed_at, :confirmation_sent_at,
|
||||
:remember_token, :unconfirmed_email, :failed_attempts, :unlock_token, :locked_at]
|
||||
|
||||
include Devise::DeprecatedConstantAccessor
|
||||
deprecate_constant "BLACKLIST_FOR_SERIALIZATION", "Devise::Models::Authenticatable::UNSAFE_ATTRIBUTES_FOR_SERIALIZATION"
|
||||
|
||||
included do
|
||||
class_attribute :devise_modules, instance_writer: false
|
||||
self.devise_modules ||= []
|
||||
@@ -104,12 +108,12 @@ module Devise
|
||||
# given to :except will simply add names to exempt to Devise internal list.
|
||||
def serializable_hash(options = nil)
|
||||
options = options.try(:dup) || {}
|
||||
options[:except] = Array(options[:except])
|
||||
options[:except] = Array(options[:except]).dup
|
||||
|
||||
if options[:force_except]
|
||||
options[:except].concat Array(options[:force_except])
|
||||
else
|
||||
options[:except].concat BLACKLIST_FOR_SERIALIZATION
|
||||
options[:except].concat UNSAFE_ATTRIBUTES_FOR_SERIALIZATION
|
||||
end
|
||||
|
||||
super(options)
|
||||
@@ -272,17 +276,17 @@ module Devise
|
||||
find_first_by_auth_conditions(tainted_conditions)
|
||||
end
|
||||
|
||||
def find_first_by_auth_conditions(tainted_conditions, opts={})
|
||||
def find_first_by_auth_conditions(tainted_conditions, opts = {})
|
||||
to_adapter.find_first(devise_parameter_filter.filter(tainted_conditions).merge(opts))
|
||||
end
|
||||
|
||||
# Find or initialize a record setting an error if it can't be found.
|
||||
def find_or_initialize_with_error_by(attribute, value, error=:invalid) #:nodoc:
|
||||
def find_or_initialize_with_error_by(attribute, value, error = :invalid) #:nodoc:
|
||||
find_or_initialize_with_errors([attribute], { attribute => value }, error)
|
||||
end
|
||||
|
||||
# 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:
|
||||
def find_or_initialize_with_errors(required_attributes, attributes, error = :invalid) #:nodoc:
|
||||
attributes.try(:permit!)
|
||||
attributes = attributes.to_h.with_indifferent_access
|
||||
.slice(*required_attributes)
|
||||
|
||||
@@ -48,7 +48,7 @@ module Devise
|
||||
included do
|
||||
before_create :generate_confirmation_token, if: :confirmation_required?
|
||||
after_create :skip_reconfirmation_in_callback!, if: :send_confirmation_notification?
|
||||
if defined?(ActiveRecord) && self < ActiveRecord::Base # ActiveRecord
|
||||
if Devise::Orm.active_record?(self) # ActiveRecord
|
||||
after_commit :send_on_create_confirmation_instructions, on: :create, if: :send_confirmation_notification?
|
||||
after_commit :send_reconfirmation_instructions, on: :update, if: :reconfirmation_required?
|
||||
else # Mongoid
|
||||
@@ -76,7 +76,7 @@ module Devise
|
||||
# Confirm a user by setting it's confirmed_at to actual time. If the user
|
||||
# is already confirmed, add an error to email field. If the user is invalid
|
||||
# add errors
|
||||
def confirm(args={})
|
||||
def confirm(args = {})
|
||||
pending_any_confirmation do
|
||||
if confirmation_period_expired?
|
||||
self.errors.add(:email, :confirmation_period_expired,
|
||||
@@ -258,44 +258,23 @@ module Devise
|
||||
generate_confirmation_token && save(validate: false)
|
||||
end
|
||||
|
||||
if Devise.activerecord51?
|
||||
def postpone_email_change_until_confirmation_and_regenerate_confirmation_token
|
||||
@reconfirmation_required = true
|
||||
self.unconfirmed_email = self.email
|
||||
self.email = self.email_in_database
|
||||
self.confirmation_token = nil
|
||||
generate_confirmation_token
|
||||
end
|
||||
else
|
||||
def postpone_email_change_until_confirmation_and_regenerate_confirmation_token
|
||||
@reconfirmation_required = true
|
||||
self.unconfirmed_email = self.email
|
||||
self.email = self.email_was
|
||||
self.confirmation_token = nil
|
||||
generate_confirmation_token
|
||||
end
|
||||
|
||||
def postpone_email_change_until_confirmation_and_regenerate_confirmation_token
|
||||
@reconfirmation_required = true
|
||||
self.unconfirmed_email = self.email
|
||||
self.email = self.devise_email_in_database
|
||||
self.confirmation_token = nil
|
||||
generate_confirmation_token
|
||||
end
|
||||
|
||||
if Devise.activerecord51?
|
||||
def postpone_email_change?
|
||||
postpone = self.class.reconfirmable &&
|
||||
will_save_change_to_email? &&
|
||||
!@bypass_confirmation_postpone &&
|
||||
self.email.present? &&
|
||||
(!@skip_reconfirmation_in_callback || !self.email_in_database.nil?)
|
||||
@bypass_confirmation_postpone = false
|
||||
postpone
|
||||
end
|
||||
else
|
||||
def postpone_email_change?
|
||||
postpone = self.class.reconfirmable &&
|
||||
email_changed? &&
|
||||
!@bypass_confirmation_postpone &&
|
||||
self.email.present? &&
|
||||
(!@skip_reconfirmation_in_callback || !self.email_was.nil?)
|
||||
@bypass_confirmation_postpone = false
|
||||
postpone
|
||||
end
|
||||
def postpone_email_change?
|
||||
postpone = self.class.reconfirmable &&
|
||||
devise_will_save_change_to_email? &&
|
||||
!@bypass_confirmation_postpone &&
|
||||
self.email.present? &&
|
||||
(!@skip_reconfirmation_in_callback || !self.devise_email_in_database.nil?)
|
||||
@bypass_confirmation_postpone = false
|
||||
postpone
|
||||
end
|
||||
|
||||
def reconfirmation_required?
|
||||
@@ -334,7 +313,7 @@ module Devise
|
||||
# confirmation instructions to it. If not, try searching for a user by unconfirmed_email
|
||||
# field. If no user is found, returns a new user with an email not found error.
|
||||
# Options must contain the user email
|
||||
def send_confirmation_instructions(attributes={})
|
||||
def send_confirmation_instructions(attributes = {})
|
||||
confirmable = find_by_unconfirmed_email_with_errors(attributes) if reconfirmable
|
||||
unless confirmable.try(:persisted?)
|
||||
confirmable = find_or_initialize_with_errors(confirmation_keys, attributes, :not_found)
|
||||
|
||||
@@ -13,7 +13,7 @@ module Devise
|
||||
#
|
||||
# == Options
|
||||
#
|
||||
# DatabaseAuthenticatable adds the following options to devise_for:
|
||||
# DatabaseAuthenticatable adds the following options to +devise+:
|
||||
#
|
||||
# * +pepper+: a random string used to provide a more secure hash. Use
|
||||
# `rails secret` to generate new keys.
|
||||
@@ -42,7 +42,7 @@ module Devise
|
||||
def initialize(*args, &block)
|
||||
@skip_email_changed_notification = false
|
||||
@skip_password_change_notification = false
|
||||
super
|
||||
super
|
||||
end
|
||||
|
||||
# Skips sending the email changed notification after_update
|
||||
@@ -177,16 +177,9 @@ module Devise
|
||||
encrypted_password[0,29] if encrypted_password
|
||||
end
|
||||
|
||||
if Devise.activerecord51?
|
||||
# Send notification to user when email changes.
|
||||
def send_email_changed_notification
|
||||
send_devise_notification(:email_changed, to: email_before_last_save)
|
||||
end
|
||||
else
|
||||
# Send notification to user when email changes.
|
||||
def send_email_changed_notification
|
||||
send_devise_notification(:email_changed, to: email_was)
|
||||
end
|
||||
# Send notification to user when email changes.
|
||||
def send_email_changed_notification
|
||||
send_devise_notification(:email_changed, to: devise_email_before_last_save)
|
||||
end
|
||||
|
||||
# Send notification to user when password changes.
|
||||
@@ -205,24 +198,12 @@ module Devise
|
||||
Devise::Encryptor.digest(self.class, password)
|
||||
end
|
||||
|
||||
if Devise.activerecord51?
|
||||
def send_email_changed_notification?
|
||||
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? && !@skip_email_changed_notification
|
||||
end
|
||||
def send_email_changed_notification?
|
||||
self.class.send_email_changed_notification && devise_saved_change_to_email? && !@skip_email_changed_notification
|
||||
end
|
||||
|
||||
if Devise.activerecord51?
|
||||
def send_password_change_notification?
|
||||
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? && !@skip_password_change_notification
|
||||
end
|
||||
def send_password_change_notification?
|
||||
self.class.send_password_change_notification && devise_saved_change_to_encrypted_password? && !@skip_password_change_notification
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
|
||||
@@ -18,7 +18,7 @@ module Devise
|
||||
# * +maximum_attempts+: how many attempts should be accepted before blocking the user.
|
||||
# * +lock_strategy+: lock the user account by :failed_attempts or :none.
|
||||
# * +unlock_strategy+: unlock the user account by :time, :email, :both or :none.
|
||||
# * +unlock_in+: the time you want to lock the user after to lock happens. Only available when unlock_strategy is :time or :both.
|
||||
# * +unlock_in+: the time you want to unlock the user after lock happens. Only available when unlock_strategy is :time or :both.
|
||||
# * +unlock_keys+: the keys you want to use when locking and unlocking an account
|
||||
#
|
||||
module Lockable
|
||||
@@ -57,6 +57,14 @@ module Devise
|
||||
save(validate: false)
|
||||
end
|
||||
|
||||
# Resets failed attempts counter to 0.
|
||||
def reset_failed_attempts!
|
||||
if respond_to?(:failed_attempts) && !failed_attempts.to_i.zero?
|
||||
self.failed_attempts = 0
|
||||
save(validate: false)
|
||||
end
|
||||
end
|
||||
|
||||
# Verifies whether a user is locked or not.
|
||||
def access_locked?
|
||||
!!locked_at && !lock_expired?
|
||||
@@ -110,7 +118,7 @@ module Devise
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def increment_failed_attempts
|
||||
self.class.increment_counter(:failed_attempts, id)
|
||||
reload
|
||||
@@ -168,7 +176,7 @@ module Devise
|
||||
# unlock instructions to it. If not user is found, returns a new user
|
||||
# with an email not found error.
|
||||
# Options must contain the user's unlock keys
|
||||
def send_unlock_instructions(attributes={})
|
||||
def send_unlock_instructions(attributes = {})
|
||||
lockable = find_or_initialize_with_errors(unlock_keys, attributes, :not_found)
|
||||
lockable.resend_unlock_instructions if lockable.persisted?
|
||||
lockable
|
||||
|
||||
@@ -8,11 +8,11 @@ module Devise
|
||||
#
|
||||
# == Options
|
||||
#
|
||||
# Oauthable adds the following options to devise_for:
|
||||
# Oauthable adds the following options to +devise+:
|
||||
#
|
||||
# * +omniauth_providers+: Which providers are available to this model. It expects an array:
|
||||
#
|
||||
# devise_for :database_authenticatable, :omniauthable, omniauth_providers: [:twitter]
|
||||
# devise :database_authenticatable, :omniauthable, omniauth_providers: [:twitter]
|
||||
#
|
||||
module Omniauthable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
@@ -7,7 +7,7 @@ module Devise
|
||||
#
|
||||
# ==Options
|
||||
#
|
||||
# Recoverable adds the following options to devise_for:
|
||||
# Recoverable adds the following options to +devise+:
|
||||
#
|
||||
# * +reset_password_keys+: the keys you want to use when recovering the password for an account
|
||||
# * +reset_password_within+: the time period within which the password must be reset or the token expires.
|
||||
@@ -99,24 +99,13 @@ module Devise
|
||||
send_devise_notification(:reset_password_instructions, token, {})
|
||||
end
|
||||
|
||||
if Devise.activerecord51?
|
||||
def clear_reset_password_token?
|
||||
encrypted_password_changed = respond_to?(:will_save_change_to_encrypted_password?) && will_save_change_to_encrypted_password?
|
||||
authentication_keys_changed = self.class.authentication_keys.any? do |attribute|
|
||||
respond_to?("will_save_change_to_#{attribute}?") && send("will_save_change_to_#{attribute}?")
|
||||
end
|
||||
|
||||
authentication_keys_changed || encrypted_password_changed
|
||||
def clear_reset_password_token?
|
||||
encrypted_password_changed = devise_respond_to_and_will_save_change_to_attribute?(:encrypted_password)
|
||||
authentication_keys_changed = self.class.authentication_keys.any? do |attribute|
|
||||
devise_respond_to_and_will_save_change_to_attribute?(attribute)
|
||||
end
|
||||
else
|
||||
def clear_reset_password_token?
|
||||
encrypted_password_changed = respond_to?(:encrypted_password_changed?) && encrypted_password_changed?
|
||||
authentication_keys_changed = self.class.authentication_keys.any? do |attribute|
|
||||
respond_to?("#{attribute}_changed?") && send("#{attribute}_changed?")
|
||||
end
|
||||
|
||||
authentication_keys_changed || encrypted_password_changed
|
||||
end
|
||||
authentication_keys_changed || encrypted_password_changed
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
@@ -131,7 +120,7 @@ module Devise
|
||||
# password instructions to it. If user is not found, returns a new user
|
||||
# with an email not found error.
|
||||
# Attributes must contain the user's email
|
||||
def send_reset_password_instructions(attributes={})
|
||||
def send_reset_password_instructions(attributes = {})
|
||||
recoverable = find_or_initialize_with_errors(reset_password_keys, attributes, :not_found)
|
||||
recoverable.send_reset_password_instructions if recoverable.persisted?
|
||||
recoverable
|
||||
@@ -142,7 +131,7 @@ module Devise
|
||||
# try saving the record. If not user is found, returns a new user
|
||||
# containing an error in reset_password_token attribute.
|
||||
# Attributes must contain reset_password_token, password and confirmation
|
||||
def reset_password_by_token(attributes={})
|
||||
def reset_password_by_token(attributes = {})
|
||||
original_token = attributes[:reset_password_token]
|
||||
reset_password_token = Devise.token_generator.digest(self, :reset_password_token, original_token)
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ module Devise
|
||||
#
|
||||
# == Options
|
||||
#
|
||||
# Rememberable adds the following options in devise_for:
|
||||
# Rememberable adds the following options to +devise+:
|
||||
#
|
||||
# * +remember_for+: the time you want the user will be remembered without
|
||||
# asking for credentials. After this time the user will be blocked and
|
||||
|
||||
@@ -11,7 +11,7 @@ module Devise
|
||||
#
|
||||
# == Options
|
||||
#
|
||||
# Timeoutable adds the following options to devise_for:
|
||||
# Timeoutable adds the following options to +devise+:
|
||||
#
|
||||
# * +timeout_in+: the interval to timeout the user session without activity.
|
||||
#
|
||||
|
||||
@@ -9,7 +9,7 @@ module Devise
|
||||
#
|
||||
# == Options
|
||||
#
|
||||
# Validatable adds the following options to devise_for:
|
||||
# Validatable adds the following options to +devise+:
|
||||
#
|
||||
# * +email_regexp+: the regular expression used to validate e-mails;
|
||||
# * +password_length+: a range expressing password length. Defaults to 6..128.
|
||||
@@ -29,13 +29,8 @@ module Devise
|
||||
|
||||
base.class_eval do
|
||||
validates_presence_of :email, if: :email_required?
|
||||
if Devise.activerecord51?
|
||||
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?
|
||||
validates_format_of :email, with: email_regexp, allow_blank: true, if: :email_changed?
|
||||
end
|
||||
validates_uniqueness_of :email, allow_blank: true, case_sensitive: true, if: :devise_will_save_change_to_email?
|
||||
validates_format_of :email, with: email_regexp, allow_blank: true, if: :devise_will_save_change_to_email?
|
||||
|
||||
validates_presence_of :password, if: :password_required?
|
||||
validates_confirmation_of :password, if: :password_required?
|
||||
@@ -47,7 +42,7 @@ module Devise
|
||||
unavailable_validations = VALIDATIONS.select { |v| !base.respond_to?(v) }
|
||||
|
||||
unless unavailable_validations.empty?
|
||||
raise "Could not use :validatable module since #{base} does not respond " <<
|
||||
raise "Could not use :validatable module since #{base} does not respond " \
|
||||
"to the following methods: #{unavailable_validations.to_sentence}."
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
begin
|
||||
gem "omniauth", ">= 1.0.0"
|
||||
|
||||
require "omniauth"
|
||||
require "omniauth/version"
|
||||
rescue LoadError
|
||||
warn "Could not load 'omniauth'. Please ensure you have the omniauth gem >= 1.0.0 installed and listed in your Gemfile."
|
||||
raise
|
||||
end
|
||||
|
||||
unless OmniAuth::VERSION =~ /^1\./
|
||||
raise "You are using an old OmniAuth version, please ensure you have 1.0.0.pr2 version or later installed."
|
||||
end
|
||||
|
||||
# Clean up the default path_prefix. It will be automatically set by Devise.
|
||||
OmniAuth.config.path_prefix = nil
|
||||
|
||||
|
||||
71
lib/devise/orm.rb
Normal file
71
lib/devise/orm.rb
Normal file
@@ -0,0 +1,71 @@
|
||||
module Devise
|
||||
module Orm # :nodoc:
|
||||
def self.active_record?(model)
|
||||
defined?(ActiveRecord) && model < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def self.active_record_51?(model)
|
||||
active_record?(model) && ActiveRecord.gem_version >= Gem::Version.new("5.1.x")
|
||||
end
|
||||
|
||||
def self.included(model)
|
||||
if Devise::Orm.active_record_51?(model)
|
||||
model.include DirtyTrackingNewMethods
|
||||
else
|
||||
model.include DirtyTrackingOldMethods
|
||||
end
|
||||
end
|
||||
|
||||
module DirtyTrackingNewMethods
|
||||
def devise_email_before_last_save
|
||||
email_before_last_save
|
||||
end
|
||||
|
||||
def devise_email_in_database
|
||||
email_in_database
|
||||
end
|
||||
|
||||
def devise_saved_change_to_email?
|
||||
saved_change_to_email?
|
||||
end
|
||||
|
||||
def devise_saved_change_to_encrypted_password?
|
||||
saved_change_to_encrypted_password?
|
||||
end
|
||||
|
||||
def devise_will_save_change_to_email?
|
||||
will_save_change_to_email?
|
||||
end
|
||||
|
||||
def devise_respond_to_and_will_save_change_to_attribute?(attribute)
|
||||
respond_to?("will_save_change_to_#{attribute}?") && send("will_save_change_to_#{attribute}?")
|
||||
end
|
||||
end
|
||||
|
||||
module DirtyTrackingOldMethods
|
||||
def devise_email_before_last_save
|
||||
email_was
|
||||
end
|
||||
|
||||
def devise_email_in_database
|
||||
email_was
|
||||
end
|
||||
|
||||
def devise_saved_change_to_email?
|
||||
email_changed?
|
||||
end
|
||||
|
||||
def devise_saved_change_to_encrypted_password?
|
||||
encrypted_password_changed?
|
||||
end
|
||||
|
||||
def devise_will_save_change_to_email?
|
||||
email_changed?
|
||||
end
|
||||
|
||||
def devise_respond_to_and_will_save_change_to_attribute?(attribute)
|
||||
respond_to?("#{attribute}_changed?") && send("#{attribute}_changed?")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
39
lib/devise/rails/deprecated_constant_accessor.rb
Normal file
39
lib/devise/rails/deprecated_constant_accessor.rb
Normal file
@@ -0,0 +1,39 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
begin
|
||||
require 'active_support/deprecation/constant_accessor'
|
||||
|
||||
module Devise
|
||||
DeprecatedConstantAccessor = ActiveSupport::Deprecation::DeprecatedConstantAccessor #:nodoc:
|
||||
end
|
||||
rescue LoadError
|
||||
|
||||
# Copy of constant deprecation module from Rails / Active Support version 6, so we can use it
|
||||
# with Rails <= 5.0 versions. This can be removed once we support only Rails 5.1 or greater.
|
||||
module Devise
|
||||
module DeprecatedConstantAccessor #:nodoc:
|
||||
def self.included(base)
|
||||
require "active_support/inflector/methods"
|
||||
|
||||
extension = Module.new do
|
||||
def const_missing(missing_const_name)
|
||||
if class_variable_defined?(:@@_deprecated_constants)
|
||||
if (replacement = class_variable_get(:@@_deprecated_constants)[missing_const_name.to_s])
|
||||
replacement[:deprecator].warn(replacement[:message] || "#{name}::#{missing_const_name} is deprecated! Use #{replacement[:new]} instead.", Rails::VERSION::MAJOR == 4 ? caller : caller_locations)
|
||||
return ActiveSupport::Inflector.constantize(replacement[:new].to_s)
|
||||
end
|
||||
end
|
||||
super
|
||||
end
|
||||
|
||||
def deprecate_constant(const_name, new_constant, message: nil, deprecator: ActiveSupport::Deprecation.instance)
|
||||
class_variable_set(:@@_deprecated_constants, {}) unless class_variable_defined?(:@@_deprecated_constants)
|
||||
class_variable_get(:@@_deprecated_constants)[const_name.to_s] = { new: new_constant, message: message, deprecator: deprecator }
|
||||
end
|
||||
end
|
||||
base.singleton_class.prepend extension
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -287,7 +287,7 @@ module ActionDispatch::Routing
|
||||
# root to: "admin/dashboard#show", as: :user_root
|
||||
# end
|
||||
#
|
||||
def authenticate(scope=nil, block=nil)
|
||||
def authenticate(scope = nil, block = nil)
|
||||
constraints_for(:authenticate!, scope, block) do
|
||||
yield
|
||||
end
|
||||
@@ -311,7 +311,7 @@ module ActionDispatch::Routing
|
||||
#
|
||||
# root to: 'landing#show'
|
||||
#
|
||||
def authenticated(scope=nil, block=nil)
|
||||
def authenticated(scope = nil, block = nil)
|
||||
constraints_for(:authenticate?, scope, block) do
|
||||
yield
|
||||
end
|
||||
@@ -328,7 +328,7 @@ module ActionDispatch::Routing
|
||||
#
|
||||
# root to: 'dashboard#show'
|
||||
#
|
||||
def unauthenticated(scope=nil)
|
||||
def unauthenticated(scope = nil)
|
||||
constraint = lambda do |request|
|
||||
not request.env["warden"].authenticate? scope: scope
|
||||
end
|
||||
@@ -474,7 +474,7 @@ ERROR
|
||||
@scope = current_scope
|
||||
end
|
||||
|
||||
def constraints_for(method_to_apply, scope=nil, block=nil)
|
||||
def constraints_for(method_to_apply, scope = nil, block = nil)
|
||||
constraint = lambda do |request|
|
||||
request.env['warden'].send(method_to_apply, scope: scope) &&
|
||||
(block.nil? || block.call(request.env["warden"].user(scope)))
|
||||
|
||||
@@ -143,7 +143,7 @@ module Devise
|
||||
@controller.response.headers.merge!(headers)
|
||||
@controller.response.content_type = headers["Content-Type"] unless Rails::VERSION::MAJOR >= 5
|
||||
@controller.status = status
|
||||
@controller.response.body = response.body
|
||||
@controller.response_body = response.body
|
||||
nil # causes process return @response
|
||||
end
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Devise
|
||||
VERSION = "4.7.2".freeze
|
||||
VERSION = "4.9.1".freeze
|
||||
end
|
||||
|
||||
@@ -86,9 +86,24 @@ RUBY
|
||||
Rails::VERSION::MAJOR >= 5
|
||||
end
|
||||
|
||||
def rails61_and_up?
|
||||
Rails::VERSION::MAJOR > 6 || (Rails::VERSION::MAJOR == 6 && Rails::VERSION::MINOR >= 1)
|
||||
end
|
||||
|
||||
def postgresql?
|
||||
config = ActiveRecord::Base.configurations[Rails.env]
|
||||
config && config['adapter'] == 'postgresql'
|
||||
ar_config && ar_config['adapter'] == 'postgresql'
|
||||
end
|
||||
|
||||
def ar_config
|
||||
if ActiveRecord::Base.configurations.respond_to?(:configs_for)
|
||||
if rails61_and_up?
|
||||
ActiveRecord::Base.configurations.configs_for(env_name: Rails.env, name: "primary").configuration_hash
|
||||
else
|
||||
ActiveRecord::Base.configurations.configs_for(env_name: Rails.env, spec_name: "primary").config
|
||||
end
|
||||
else
|
||||
ActiveRecord::Base.configurations[Rails.env]
|
||||
end
|
||||
end
|
||||
|
||||
def migration_version
|
||||
|
||||
@@ -13,7 +13,7 @@ module Devise
|
||||
desc "Generates a model with the given NAME (if one does not exist) with devise " \
|
||||
"configuration plus a migration file and devise routes."
|
||||
|
||||
hook_for :orm, type: :boolean
|
||||
hook_for :orm, required: true
|
||||
|
||||
class_option :routes, desc: "Generate routes", type: :boolean, default: true
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ module Devise
|
||||
source_root File.expand_path("../../templates", __FILE__)
|
||||
|
||||
desc "Creates a Devise initializer and copy locale files to your application."
|
||||
class_option :orm
|
||||
class_option :orm, required: true
|
||||
|
||||
def copy_initializer
|
||||
unless options[:orm]
|
||||
|
||||
@@ -256,14 +256,14 @@ Devise.setup do |config|
|
||||
|
||||
# ==> Navigation configuration
|
||||
# Lists the formats that should be treated as navigational. Formats like
|
||||
# :html, should redirect to the sign in page when the user does not have
|
||||
# :html should redirect to the sign in page when the user does not have
|
||||
# access, but formats like :xml or :json, should return 401.
|
||||
#
|
||||
# If you have any extra navigational formats, like :iphone or :mobile, you
|
||||
# should add them to the navigational formats lists.
|
||||
#
|
||||
# The "*/*" below is required to match Internet Explorer requests.
|
||||
# config.navigational_formats = ['*/*', :html]
|
||||
# config.navigational_formats = ['*/*', :html, :turbo_stream]
|
||||
|
||||
# The default HTTP method used to sign out a resource. Default is :delete.
|
||||
config.sign_out_via = :delete
|
||||
@@ -296,12 +296,14 @@ Devise.setup do |config|
|
||||
# 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
|
||||
# ==> Hotwire/Turbo configuration
|
||||
# When using Devise with Hotwire/Turbo, the http status for error responses
|
||||
# and some redirects must match the following. The default in Devise for existing
|
||||
# apps is `200 OK` and `302 Found respectively`, but new apps are generated with
|
||||
# these new defaults that match Hotwire/Turbo behavior.
|
||||
# Note: These might become the new default in future versions of Devise.
|
||||
config.responder.error_status = :unprocessable_entity
|
||||
config.responder.redirect_status = :see_other
|
||||
|
||||
# ==> Configuration for :registerable
|
||||
|
||||
|
||||
@@ -30,6 +30,6 @@
|
||||
|
||||
<h3>Cancel my account</h3>
|
||||
|
||||
<p>Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %></p>
|
||||
<div>Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?", turbo_confirm: "Are you sure?" }, method: :delete %></div>
|
||||
|
||||
<%= link_to "Back", :back %>
|
||||
|
||||
@@ -42,9 +42,7 @@ class CustomStrategyTest < Devise::ControllerTestCase
|
||||
test "custom strategy can return its own status code" do
|
||||
ret = get :new
|
||||
|
||||
# check the returned rack array
|
||||
# assert ret.is_a?(Array)
|
||||
# assert_equal 400, ret.first
|
||||
# check the returned response
|
||||
assert ret.is_a?(ActionDispatch::TestResponse)
|
||||
|
||||
# check the saved response as well. This is purely so that the response is available to the testing framework
|
||||
@@ -55,12 +53,10 @@ class CustomStrategyTest < Devise::ControllerTestCase
|
||||
test "custom strategy can return custom headers" do
|
||||
ret = get :new
|
||||
|
||||
# check the returned rack array
|
||||
# assert ret.is_a?(Array)
|
||||
# assert_equal ret.third['X-FOO'], 'BAR'
|
||||
# check the returned response
|
||||
assert ret.is_a?(ActionDispatch::TestResponse)
|
||||
|
||||
# check the saved response headers as well.
|
||||
assert_equal response.headers['X-FOO'], 'BAR'
|
||||
assert_equal 'BAR', response.headers['X-FOO']
|
||||
end
|
||||
end
|
||||
|
||||
@@ -14,8 +14,8 @@ class HelperMethodsTest < Devise::ControllerTestCase
|
||||
end
|
||||
|
||||
test 'does not respond_to helper or helper_method' do
|
||||
refute_respond_to @controller.class, :helper
|
||||
refute_respond_to @controller.class, :helper_method
|
||||
assert_not_respond_to @controller.class, :helper
|
||||
assert_not_respond_to @controller.class, :helper_method
|
||||
end
|
||||
|
||||
test 'defines methods like current_user' do
|
||||
|
||||
@@ -98,7 +98,7 @@ class ControllerAuthenticatableTest < Devise::ControllerTestCase
|
||||
|
||||
test 'proxy admin_signed_in? to authenticatewith admin scope' do
|
||||
@mock_warden.expects(:authenticate).with(scope: :admin)
|
||||
refute @controller.admin_signed_in?
|
||||
assert_not @controller.admin_signed_in?
|
||||
end
|
||||
|
||||
test 'proxy publisher_account_signed_in? to authenticate with namespaced publisher account scope' do
|
||||
@@ -319,10 +319,10 @@ class ControllerAuthenticatableTest < Devise::ControllerTestCase
|
||||
|
||||
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?
|
||||
assert_not @controller.is_flashing_format?
|
||||
end
|
||||
|
||||
test 'is not a devise controller' do
|
||||
refute @controller.devise_controller?
|
||||
assert_not @controller.devise_controller?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -51,7 +51,7 @@ class HelpersTest < Devise::ControllerTestCase
|
||||
end
|
||||
|
||||
test 'resources methods are not controller actions' do
|
||||
assert @controller.class.action_methods.delete_if { |m| m.include? 'commenter' }.empty?
|
||||
assert_empty @controller.class.action_methods.delete_if { |m| m.include? 'commenter' }
|
||||
end
|
||||
|
||||
test 'require no authentication tests current mapping' do
|
||||
@@ -121,7 +121,7 @@ class HelpersTest < Devise::ControllerTestCase
|
||||
MyController.send(:public, :navigational_formats)
|
||||
|
||||
swap Devise, navigational_formats: ['*/*', :html] do
|
||||
refute @controller.navigational_formats.include?("*/*")
|
||||
assert_not @controller.navigational_formats.include?("*/*")
|
||||
end
|
||||
|
||||
MyController.send(:protected, :navigational_formats)
|
||||
|
||||
@@ -16,6 +16,6 @@ class LoadHooksControllerTest < Devise::ControllerTestCase
|
||||
end
|
||||
|
||||
test 'load hook called when controller is loaded' do
|
||||
assert DeviseController.instance_methods.include? :defined_by_load_hook
|
||||
assert_includes DeviseController.instance_methods, :defined_by_load_hook
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,7 +5,7 @@ require 'test_helper'
|
||||
class RoutesTest < Devise::ControllerTestCase
|
||||
tests ApplicationController
|
||||
|
||||
def assert_path_and_url(name, prepend_path=nil)
|
||||
def assert_path_and_url(name, prepend_path = nil)
|
||||
@request.path = '/users/session'
|
||||
prepend_path = "#{prepend_path}_" if prepend_path
|
||||
|
||||
|
||||
@@ -71,8 +71,8 @@ class DeviseTest < ActiveSupport::TestCase
|
||||
test 'add new module using the helper method' do
|
||||
Devise.add_module(:coconut)
|
||||
assert_equal 1, Devise::ALL.select { |v| v == :coconut }.size
|
||||
refute Devise::STRATEGIES.include?(:coconut)
|
||||
refute defined?(Devise::Models::Coconut)
|
||||
assert_not Devise::STRATEGIES.include?(:coconut)
|
||||
assert_not defined?(Devise::Models::Coconut)
|
||||
Devise::ALL.delete(:coconut)
|
||||
|
||||
Devise.add_module(:banana, strategy: :fruits)
|
||||
@@ -88,11 +88,11 @@ class DeviseTest < ActiveSupport::TestCase
|
||||
|
||||
test 'should complain when comparing empty or different sized passes' do
|
||||
[nil, ""].each do |empty|
|
||||
refute Devise.secure_compare(empty, "something")
|
||||
refute Devise.secure_compare("something", empty)
|
||||
refute Devise.secure_compare(empty, empty)
|
||||
assert_not Devise.secure_compare(empty, "something")
|
||||
assert_not Devise.secure_compare("something", empty)
|
||||
assert_not Devise.secure_compare(empty, empty)
|
||||
end
|
||||
refute Devise.secure_compare("size_1", "size_four")
|
||||
assert_not Devise.secure_compare("size_1", "size_four")
|
||||
end
|
||||
|
||||
test 'Devise.email_regexp should match valid email addresses' do
|
||||
|
||||
@@ -73,13 +73,12 @@ class FailureTest < ActiveSupport::TestCase
|
||||
instance_eval(&block)
|
||||
end
|
||||
|
||||
def call_failure(env_params={})
|
||||
def call_failure(env_params = {})
|
||||
env = {
|
||||
'REQUEST_URI' => 'http://test.host/',
|
||||
'HTTP_HOST' => 'test.host',
|
||||
'REQUEST_METHOD' => 'GET',
|
||||
'warden.options' => { scope: :user },
|
||||
'rack.session' => {},
|
||||
'action_dispatch.request.formats' => Array(env_params.delete('formats') || Mime[:html]),
|
||||
'rack.input' => "",
|
||||
'warden' => OpenStruct.new(message: nil)
|
||||
@@ -214,14 +213,18 @@ class FailureTest < ActiveSupport::TestCase
|
||||
|
||||
test 'set up a default message' do
|
||||
call_failure
|
||||
assert_match(/You are being/, @response.last.body)
|
||||
assert_match(/redirected/, @response.last.body)
|
||||
assert_match(/users\/sign_in/, @response.last.body)
|
||||
if Devise::Test.rails71_and_up?
|
||||
assert_empty @response.last.body
|
||||
else
|
||||
assert_match(/You are being/, @response.last.body)
|
||||
assert_match(/redirected/, @response.last.body)
|
||||
assert_match(/users\/sign_in/, @response.last.body)
|
||||
end
|
||||
end
|
||||
|
||||
test 'works for any navigational format' do
|
||||
swap Devise, navigational_formats: [:xml] do
|
||||
call_failure('formats' => Mime[:xml])
|
||||
swap Devise, navigational_formats: [:json] do
|
||||
call_failure('formats' => Mime[:json])
|
||||
assert_equal 302, @response.first
|
||||
end
|
||||
end
|
||||
@@ -236,7 +239,7 @@ class FailureTest < ActiveSupport::TestCase
|
||||
|
||||
context 'For HTTP request' do
|
||||
test 'return 401 status' do
|
||||
call_failure('formats' => Mime[:xml])
|
||||
call_failure('formats' => Mime[:json])
|
||||
assert_equal 401, @response.first
|
||||
end
|
||||
|
||||
@@ -258,13 +261,13 @@ class FailureTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
test 'return WWW-authenticate headers if model allows' do
|
||||
call_failure('formats' => Mime[:xml])
|
||||
call_failure('formats' => Mime[:json])
|
||||
assert_equal 'Basic realm="Application"', @response.second["WWW-Authenticate"]
|
||||
end
|
||||
|
||||
test 'does not return WWW-authenticate headers if model does not allow' do
|
||||
swap Devise, http_authenticatable: false do
|
||||
call_failure('formats' => Mime[:xml])
|
||||
call_failure('formats' => Mime[:json])
|
||||
assert_nil @response.second["WWW-Authenticate"]
|
||||
end
|
||||
end
|
||||
@@ -326,8 +329,8 @@ class FailureTest < ActiveSupport::TestCase
|
||||
"warden" => stub_everything
|
||||
}
|
||||
call_failure(env)
|
||||
assert @response.third.body.include?('<h2>Log in</h2>')
|
||||
assert @response.third.body.include?('Invalid Email or password.')
|
||||
assert_includes @response.third.body, '<h2>Log in</h2>'
|
||||
assert_includes @response.third.body, 'Invalid Email or password.'
|
||||
end
|
||||
|
||||
test 'calls the original controller if not confirmed email' do
|
||||
@@ -337,8 +340,8 @@ class FailureTest < ActiveSupport::TestCase
|
||||
"warden" => stub_everything
|
||||
}
|
||||
call_failure(env)
|
||||
assert @response.third.body.include?('<h2>Log in</h2>')
|
||||
assert @response.third.body.include?('You have to confirm your email address before continuing.')
|
||||
assert_includes @response.third.body, '<h2>Log in</h2>'
|
||||
assert_includes @response.third.body, 'You have to confirm your email address before continuing.'
|
||||
end
|
||||
|
||||
test 'calls the original controller if inactive account' do
|
||||
@@ -348,8 +351,8 @@ class FailureTest < ActiveSupport::TestCase
|
||||
"warden" => stub_everything
|
||||
}
|
||||
call_failure(env)
|
||||
assert @response.third.body.include?('<h2>Log in</h2>')
|
||||
assert @response.third.body.include?('Your account is not activated yet.')
|
||||
assert_includes @response.third.body, '<h2>Log in</h2>'
|
||||
assert_includes @response.third.body, 'Your account is not activated yet.'
|
||||
end
|
||||
|
||||
if Rails.application.config.respond_to?(:relative_url_root)
|
||||
@@ -361,18 +364,71 @@ class FailureTest < ActiveSupport::TestCase
|
||||
"warden" => stub_everything
|
||||
}
|
||||
call_failure(env)
|
||||
assert @response.third.body.include?('<h2>Log in</h2>')
|
||||
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'
|
||||
assert_includes @response.third.body, '<h2>Log in</h2>'
|
||||
assert_includes @response.third.body, 'Invalid Email or password.'
|
||||
assert_equal '/sample', @request.env["SCRIPT_NAME"]
|
||||
assert_equal '/users/sign_in', @request.env["PATH_INFO"]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# TODO: remove conditional/else when supporting only responders 3.1+
|
||||
if ActionController::Responder.respond_to?(:error_status=)
|
||||
test 'respects the configured responder `error_status` for the status code' do
|
||||
swap Devise.responder, error_status: :unprocessable_entity do
|
||||
env = {
|
||||
"warden.options" => { recall: "devise/sessions#new", attempted_path: "/users/sign_in" },
|
||||
"devise.mapping" => Devise.mappings[:user],
|
||||
"warden" => stub_everything
|
||||
}
|
||||
call_failure(env)
|
||||
|
||||
assert_equal 422, @response.first
|
||||
assert_includes @response.third.body, 'Invalid Email or password.'
|
||||
end
|
||||
end
|
||||
|
||||
test 'respects the configured responder `redirect_status` if the recall app returns a redirect status code' do
|
||||
swap Devise.responder, redirect_status: :see_other do
|
||||
env = {
|
||||
"warden.options" => { recall: "devise/registrations#cancel", attempted_path: "/users/cancel" },
|
||||
"devise.mapping" => Devise.mappings[:user],
|
||||
"warden" => stub_everything
|
||||
}
|
||||
call_failure(env)
|
||||
|
||||
assert_equal 303, @response.first
|
||||
end
|
||||
end
|
||||
else
|
||||
test 'uses default hardcoded responder `error_status` for the status code since responders version does not support configuring it' do
|
||||
env = {
|
||||
"warden.options" => { recall: "devise/sessions#new", attempted_path: "/users/sign_in" },
|
||||
"devise.mapping" => Devise.mappings[:user],
|
||||
"warden" => stub_everything
|
||||
}
|
||||
call_failure(env)
|
||||
|
||||
assert_equal 200, @response.first
|
||||
assert_includes @response.third.body, 'Invalid Email or password.'
|
||||
end
|
||||
|
||||
test 'users default hardcoded responder `redirect_status` for the status code since responders version does not support configuring it' do
|
||||
env = {
|
||||
"warden.options" => { recall: "devise/registrations#cancel", attempted_path: "/users/cancel" },
|
||||
"devise.mapping" => Devise.mappings[:user],
|
||||
"warden" => stub_everything
|
||||
}
|
||||
call_failure(env)
|
||||
|
||||
assert_equal 302, @response.first
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "Lazy loading" do
|
||||
test "loads" do
|
||||
assert_equal Devise::FailureApp.new.lazy_loading_works?, "yes it does"
|
||||
assert_equal "yes it does", Devise::FailureApp.new.lazy_loading_works?
|
||||
end
|
||||
end
|
||||
context "Without Flash Support" do
|
||||
|
||||
@@ -77,7 +77,7 @@ class ViewsGeneratorTest < Rails::Generators::TestCase
|
||||
assert_file "app/views/devise/mailer/reset_password_instructions.markerb"
|
||||
end
|
||||
|
||||
def assert_files(scope = nil, options={})
|
||||
def assert_files(scope = nil, options = {})
|
||||
scope = "devise" if scope.nil?
|
||||
mail_template_engine = options[:mail_template_engine] || "html.erb"
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ class AuthenticationSanityTest < Devise::IntegrationTest
|
||||
test 'sign in should not run model validations' do
|
||||
sign_in_as_user
|
||||
|
||||
refute User.validations_performed
|
||||
assert_not User.validations_performed
|
||||
end
|
||||
|
||||
test 'home should be accessible without sign in' do
|
||||
@@ -18,13 +18,13 @@ class AuthenticationSanityTest < Devise::IntegrationTest
|
||||
test 'sign in as user should not authenticate admin scope' do
|
||||
sign_in_as_user
|
||||
assert warden.authenticated?(:user)
|
||||
refute warden.authenticated?(:admin)
|
||||
assert_not warden.authenticated?(:admin)
|
||||
end
|
||||
|
||||
test 'sign in as admin should not authenticate user scope' do
|
||||
sign_in_as_admin
|
||||
assert warden.authenticated?(:admin)
|
||||
refute warden.authenticated?(:user)
|
||||
assert_not warden.authenticated?(:user)
|
||||
end
|
||||
|
||||
test 'sign in as both user and admin at same time' do
|
||||
@@ -39,7 +39,7 @@ class AuthenticationSanityTest < Devise::IntegrationTest
|
||||
sign_in_as_user
|
||||
sign_in_as_admin
|
||||
delete destroy_user_session_path
|
||||
refute warden.authenticated?(:user)
|
||||
assert_not warden.authenticated?(:user)
|
||||
assert warden.authenticated?(:admin)
|
||||
end
|
||||
end
|
||||
@@ -50,7 +50,7 @@ class AuthenticationSanityTest < Devise::IntegrationTest
|
||||
sign_in_as_admin
|
||||
|
||||
delete destroy_admin_session_path
|
||||
refute warden.authenticated?(:admin)
|
||||
assert_not warden.authenticated?(:admin)
|
||||
assert warden.authenticated?(:user)
|
||||
end
|
||||
end
|
||||
@@ -61,8 +61,8 @@ class AuthenticationSanityTest < Devise::IntegrationTest
|
||||
sign_in_as_admin
|
||||
|
||||
delete destroy_user_session_path
|
||||
refute warden.authenticated?(:user)
|
||||
refute warden.authenticated?(:admin)
|
||||
assert_not warden.authenticated?(:user)
|
||||
assert_not warden.authenticated?(:admin)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -72,21 +72,21 @@ class AuthenticationSanityTest < Devise::IntegrationTest
|
||||
sign_in_as_admin
|
||||
|
||||
delete destroy_admin_session_path
|
||||
refute warden.authenticated?(:admin)
|
||||
refute warden.authenticated?(:user)
|
||||
assert_not warden.authenticated?(:admin)
|
||||
assert_not warden.authenticated?(:user)
|
||||
end
|
||||
end
|
||||
|
||||
test 'not signed in as admin should not be able to access admins actions' do
|
||||
get admins_path
|
||||
assert_redirected_to new_admin_session_path
|
||||
refute warden.authenticated?(:admin)
|
||||
assert_not warden.authenticated?(:admin)
|
||||
end
|
||||
|
||||
test 'signed in as user should not be able to access admins actions' do
|
||||
sign_in_as_user
|
||||
assert warden.authenticated?(:user)
|
||||
refute warden.authenticated?(:admin)
|
||||
assert_not warden.authenticated?(:admin)
|
||||
|
||||
get admins_path
|
||||
assert_redirected_to new_admin_session_path
|
||||
@@ -95,7 +95,7 @@ class AuthenticationSanityTest < Devise::IntegrationTest
|
||||
test 'signed in as admin should be able to access admin actions' do
|
||||
sign_in_as_admin
|
||||
assert warden.authenticated?(:admin)
|
||||
refute warden.authenticated?(:user)
|
||||
assert_not warden.authenticated?(:user)
|
||||
|
||||
get admins_path
|
||||
|
||||
@@ -123,7 +123,7 @@ class AuthenticationSanityTest < Devise::IntegrationTest
|
||||
|
||||
get root_path
|
||||
assert_contain 'Signed out successfully'
|
||||
refute warden.authenticated?(:admin)
|
||||
assert_not warden.authenticated?(:admin)
|
||||
end
|
||||
|
||||
test 'unauthenticated admin set message on sign out' do
|
||||
@@ -146,13 +146,13 @@ class AuthenticationRoutesRestrictions < Devise::IntegrationTest
|
||||
test 'not signed in should not be able to access private route (authenticate denied)' do
|
||||
get private_path
|
||||
assert_redirected_to new_admin_session_path
|
||||
refute warden.authenticated?(:admin)
|
||||
assert_not warden.authenticated?(:admin)
|
||||
end
|
||||
|
||||
test 'signed in as user should not be able to access private route restricted to admins (authenticate denied)' do
|
||||
sign_in_as_user
|
||||
assert warden.authenticated?(:user)
|
||||
refute warden.authenticated?(:admin)
|
||||
assert_not warden.authenticated?(:admin)
|
||||
get private_path
|
||||
assert_redirected_to new_admin_session_path
|
||||
end
|
||||
@@ -160,7 +160,7 @@ class AuthenticationRoutesRestrictions < Devise::IntegrationTest
|
||||
test 'signed in as admin should be able to access private route restricted to admins (authenticate accepted)' do
|
||||
sign_in_as_admin
|
||||
assert warden.authenticated?(:admin)
|
||||
refute warden.authenticated?(:user)
|
||||
assert_not warden.authenticated?(:user)
|
||||
|
||||
get private_path
|
||||
|
||||
@@ -172,7 +172,7 @@ class AuthenticationRoutesRestrictions < Devise::IntegrationTest
|
||||
test 'signed in as inactive admin should not be able to access private/active route restricted to active admins (authenticate denied)' do
|
||||
sign_in_as_admin(active: false)
|
||||
assert warden.authenticated?(:admin)
|
||||
refute warden.authenticated?(:user)
|
||||
assert_not warden.authenticated?(:user)
|
||||
|
||||
assert_raises ActionController::RoutingError do
|
||||
get "/private/active"
|
||||
@@ -182,7 +182,7 @@ class AuthenticationRoutesRestrictions < Devise::IntegrationTest
|
||||
test 'signed in as active admin should be able to access private/active route restricted to active admins (authenticate accepted)' do
|
||||
sign_in_as_admin(active: true)
|
||||
assert warden.authenticated?(:admin)
|
||||
refute warden.authenticated?(:user)
|
||||
assert_not warden.authenticated?(:user)
|
||||
|
||||
get private_active_path
|
||||
|
||||
@@ -194,7 +194,7 @@ class AuthenticationRoutesRestrictions < Devise::IntegrationTest
|
||||
test 'signed in as admin should get admin dashboard (authenticated accepted)' do
|
||||
sign_in_as_admin
|
||||
assert warden.authenticated?(:admin)
|
||||
refute warden.authenticated?(:user)
|
||||
assert_not warden.authenticated?(:user)
|
||||
|
||||
get dashboard_path
|
||||
|
||||
@@ -206,7 +206,7 @@ class AuthenticationRoutesRestrictions < Devise::IntegrationTest
|
||||
test 'signed in as user should get user dashboard (authenticated accepted)' do
|
||||
sign_in_as_user
|
||||
assert warden.authenticated?(:user)
|
||||
refute warden.authenticated?(:admin)
|
||||
assert_not warden.authenticated?(:admin)
|
||||
|
||||
get dashboard_path
|
||||
|
||||
@@ -224,7 +224,7 @@ class AuthenticationRoutesRestrictions < Devise::IntegrationTest
|
||||
test 'signed in as inactive admin should not be able to access dashboard/active route restricted to active admins (authenticated denied)' do
|
||||
sign_in_as_admin(active: false)
|
||||
assert warden.authenticated?(:admin)
|
||||
refute warden.authenticated?(:user)
|
||||
assert_not warden.authenticated?(:user)
|
||||
|
||||
assert_raises ActionController::RoutingError do
|
||||
get "/dashboard/active"
|
||||
@@ -234,7 +234,7 @@ class AuthenticationRoutesRestrictions < Devise::IntegrationTest
|
||||
test 'signed in as active admin should be able to access dashboard/active route restricted to active admins (authenticated accepted)' do
|
||||
sign_in_as_admin(active: true)
|
||||
assert warden.authenticated?(:admin)
|
||||
refute warden.authenticated?(:user)
|
||||
assert_not warden.authenticated?(:user)
|
||||
|
||||
get dashboard_active_path
|
||||
|
||||
@@ -246,7 +246,7 @@ class AuthenticationRoutesRestrictions < Devise::IntegrationTest
|
||||
test 'signed in user should not see unauthenticated page (unauthenticated denied)' do
|
||||
sign_in_as_user
|
||||
assert warden.authenticated?(:user)
|
||||
refute warden.authenticated?(:admin)
|
||||
assert_not warden.authenticated?(:admin)
|
||||
|
||||
assert_raises ActionController::RoutingError do
|
||||
get join_path
|
||||
@@ -321,14 +321,14 @@ class AuthenticationRedirectTest < Devise::IntegrationTest
|
||||
test 'require_no_authentication should set the already_authenticated flash message' do
|
||||
sign_in_as_user
|
||||
visit new_user_session_path
|
||||
assert_equal flash[:alert], I18n.t("devise.failure.already_authenticated")
|
||||
assert_equal I18n.t("devise.failure.already_authenticated"), flash[:alert]
|
||||
end
|
||||
|
||||
test 'require_no_authentication should set the already_authenticated flash message as admin' do
|
||||
store_translations :en, devise: { failure: { admin: { already_authenticated: 'You are already signed in as admin.' } } } do
|
||||
sign_in_as_admin
|
||||
visit new_admin_session_path
|
||||
assert_equal flash[:alert], "You are already signed in as admin."
|
||||
assert_equal "You are already signed in as admin.", flash[:alert]
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -344,16 +344,20 @@ class AuthenticationSessionTest < Devise::IntegrationTest
|
||||
end
|
||||
|
||||
test 'refreshes _csrf_token' do
|
||||
ApplicationController.allow_forgery_protection = true
|
||||
|
||||
begin
|
||||
swap ApplicationController, allow_forgery_protection: true do
|
||||
get new_user_session_path
|
||||
token = request.session[:_csrf_token]
|
||||
token_from_session = request.session[:_csrf_token]
|
||||
|
||||
if Devise::Test.rails71_and_up?
|
||||
token_from_env = request.env["action_controller.csrf_token"]
|
||||
end
|
||||
|
||||
sign_in_as_user
|
||||
assert_not_equal request.session[:_csrf_token], token
|
||||
ensure
|
||||
ApplicationController.allow_forgery_protection = false
|
||||
assert_not_equal request.session[:_csrf_token], token_from_session
|
||||
|
||||
if Devise::Test.rails71_and_up?
|
||||
assert_not_equal request.env["action_controller.csrf_token"], token_from_env
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -393,7 +397,7 @@ class AuthenticationWithScopedViewsTest < Devise::IntegrationTest
|
||||
end
|
||||
|
||||
assert_match %r{Special user view}, response.body
|
||||
assert !Devise::PasswordsController.scoped_views?
|
||||
assert_not Devise::PasswordsController.scoped_views?
|
||||
ensure
|
||||
Devise::SessionsController.send :remove_instance_variable, :@scoped_views
|
||||
end
|
||||
@@ -420,13 +424,13 @@ class AuthenticationOthersTest < Devise::IntegrationTest
|
||||
test 'handles unverified requests gets rid of caches' do
|
||||
swap ApplicationController, allow_forgery_protection: true do
|
||||
post exhibit_user_url(1)
|
||||
refute warden.authenticated?(:user)
|
||||
assert_not warden.authenticated?(:user)
|
||||
|
||||
sign_in_as_user
|
||||
assert warden.authenticated?(:user)
|
||||
|
||||
post exhibit_user_url(1)
|
||||
refute warden.authenticated?(:user)
|
||||
assert_not warden.authenticated?(:user)
|
||||
assert_equal "User is not authenticated", response.body
|
||||
end
|
||||
end
|
||||
@@ -462,14 +466,6 @@ class AuthenticationOthersTest < Devise::IntegrationTest
|
||||
end
|
||||
end
|
||||
|
||||
test 'sign in stub in xml format' do
|
||||
get new_user_session_path(format: 'xml')
|
||||
assert_match '<?xml version="1.0" encoding="UTF-8"?>', response.body
|
||||
assert_match %r{<user>.*</user>}m, response.body
|
||||
assert_match '<email></email>', response.body
|
||||
assert_match '<password nil="true"', response.body
|
||||
end
|
||||
|
||||
test 'sign in stub in json format' do
|
||||
get new_user_session_path(format: 'json')
|
||||
assert_match '{"user":{', response.body
|
||||
@@ -489,30 +485,30 @@ class AuthenticationOthersTest < Devise::IntegrationTest
|
||||
test 'uses the mapping from router' do
|
||||
sign_in_as_user visit: "/as/sign_in"
|
||||
assert warden.authenticated?(:user)
|
||||
refute warden.authenticated?(:admin)
|
||||
assert_not warden.authenticated?(:admin)
|
||||
end
|
||||
|
||||
test 'sign in with xml format returns xml response' do
|
||||
test 'sign in with json format returns json response' do
|
||||
create_user
|
||||
post user_session_path(format: 'xml'), params: { user: {email: "user@test.com", password: '12345678'} }
|
||||
post user_session_path(format: 'json'), params: { user: {email: "user@test.com", password: '12345678'} }
|
||||
assert_response :success
|
||||
assert response.body.include? %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<user>)
|
||||
assert_includes response.body, '{"user":{'
|
||||
end
|
||||
|
||||
test 'sign in with xml format is idempotent' do
|
||||
get new_user_session_path(format: 'xml')
|
||||
test 'sign in with json format is idempotent' do
|
||||
get new_user_session_path(format: 'json')
|
||||
assert_response :success
|
||||
|
||||
create_user
|
||||
post user_session_path(format: 'xml'), params: { user: {email: "user@test.com", password: '12345678'} }
|
||||
post user_session_path(format: 'json'), params: { user: {email: "user@test.com", password: '12345678'} }
|
||||
assert_response :success
|
||||
|
||||
get new_user_session_path(format: 'xml')
|
||||
get new_user_session_path(format: 'json')
|
||||
assert_response :success
|
||||
|
||||
post user_session_path(format: 'xml'), params: { user: {email: "user@test.com", password: '12345678'} }
|
||||
post user_session_path(format: 'json'), params: { user: {email: "user@test.com", password: '12345678'} }
|
||||
assert_response :success
|
||||
assert response.body.include? %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<user>)
|
||||
assert_includes response.body, '{"user":{'
|
||||
end
|
||||
|
||||
test 'sign out with html redirects' do
|
||||
@@ -527,18 +523,11 @@ class AuthenticationOthersTest < Devise::IntegrationTest
|
||||
assert_current_url '/'
|
||||
end
|
||||
|
||||
test 'sign out with xml format returns no content' do
|
||||
sign_in_as_user
|
||||
delete destroy_user_session_path(format: 'xml')
|
||||
assert_response :no_content
|
||||
refute warden.authenticated?(:user)
|
||||
end
|
||||
|
||||
test 'sign out with json format returns no content' do
|
||||
sign_in_as_user
|
||||
delete destroy_user_session_path(format: 'json')
|
||||
assert_response :no_content
|
||||
refute warden.authenticated?(:user)
|
||||
assert_not warden.authenticated?(:user)
|
||||
end
|
||||
|
||||
test 'sign out with non-navigational format via XHR does not redirect' do
|
||||
@@ -546,7 +535,7 @@ class AuthenticationOthersTest < Devise::IntegrationTest
|
||||
sign_in_as_admin
|
||||
get destroy_sign_out_via_get_session_path, xhr: true, headers: { "HTTP_ACCEPT" => "application/json,text/javascript,*/*" } # NOTE: Bug is triggered by combination of XHR and */*.
|
||||
assert_response :no_content
|
||||
refute warden.authenticated?(:user)
|
||||
assert_not warden.authenticated?(:user)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -556,7 +545,7 @@ class AuthenticationOthersTest < Devise::IntegrationTest
|
||||
sign_in_as_user
|
||||
delete destroy_user_session_path, xhr: true, headers: { "HTTP_ACCEPT" => "text/html,*/*" }
|
||||
assert_response :redirect
|
||||
refute warden.authenticated?(:user)
|
||||
assert_not warden.authenticated?(:user)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -566,7 +555,7 @@ class AuthenticationKeysTest < Devise::IntegrationTest
|
||||
swap Devise, authentication_keys: [:subdomain] do
|
||||
sign_in_as_user
|
||||
assert_contain "Invalid Subdomain or password."
|
||||
refute warden.authenticated?(:user)
|
||||
assert_not warden.authenticated?(:user)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -595,7 +584,7 @@ class AuthenticationRequestKeysTest < Devise::IntegrationTest
|
||||
sign_in_as_user
|
||||
end
|
||||
|
||||
refute warden.authenticated?(:user)
|
||||
assert_not warden.authenticated?(:user)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -605,7 +594,7 @@ class AuthenticationRequestKeysTest < Devise::IntegrationTest
|
||||
swap Devise, request_keys: [:subdomain] do
|
||||
sign_in_as_user
|
||||
assert_contain "Invalid Email or password."
|
||||
refute warden.authenticated?(:user)
|
||||
assert_not warden.authenticated?(:user)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -628,7 +617,7 @@ class AuthenticationSignOutViaTest < Devise::IntegrationTest
|
||||
test 'allow sign out via delete when sign_out_via provides only delete' do
|
||||
sign_in!(:sign_out_via_delete)
|
||||
delete destroy_sign_out_via_delete_session_path
|
||||
refute warden.authenticated?(:sign_out_via_delete)
|
||||
assert_not warden.authenticated?(:sign_out_via_delete)
|
||||
end
|
||||
|
||||
test 'do not allow sign out via get when sign_out_via provides only delete' do
|
||||
@@ -642,7 +631,7 @@ class AuthenticationSignOutViaTest < Devise::IntegrationTest
|
||||
test 'allow sign out via post when sign_out_via provides only post' do
|
||||
sign_in!(:sign_out_via_post)
|
||||
post destroy_sign_out_via_post_session_path
|
||||
refute warden.authenticated?(:sign_out_via_post)
|
||||
assert_not warden.authenticated?(:sign_out_via_post)
|
||||
end
|
||||
|
||||
test 'do not allow sign out via get when sign_out_via provides only post' do
|
||||
@@ -656,13 +645,13 @@ class AuthenticationSignOutViaTest < Devise::IntegrationTest
|
||||
test 'allow sign out via delete when sign_out_via provides delete and post' do
|
||||
sign_in!(:sign_out_via_delete_or_post)
|
||||
delete destroy_sign_out_via_delete_or_post_session_path
|
||||
refute warden.authenticated?(:sign_out_via_delete_or_post)
|
||||
assert_not warden.authenticated?(:sign_out_via_delete_or_post)
|
||||
end
|
||||
|
||||
test 'allow sign out via post when sign_out_via provides delete and post' do
|
||||
sign_in!(:sign_out_via_delete_or_post)
|
||||
post destroy_sign_out_via_delete_or_post_session_path
|
||||
refute warden.authenticated?(:sign_out_via_delete_or_post)
|
||||
assert_not warden.authenticated?(:sign_out_via_delete_or_post)
|
||||
end
|
||||
|
||||
test 'do not allow sign out via get when sign_out_via provides delete and post' do
|
||||
|
||||
@@ -43,12 +43,12 @@ class ConfirmationTest < Devise::IntegrationTest
|
||||
test 'user with valid confirmation token should not be able to confirm an account after the token has expired' do
|
||||
swap Devise, confirm_within: 3.days do
|
||||
user = create_user(confirm: false, confirmation_sent_at: 4.days.ago)
|
||||
refute user.confirmed?
|
||||
assert_not user.confirmed?
|
||||
visit_user_confirmation_with_token(user.raw_confirmation_token)
|
||||
|
||||
assert_have_selector '#error_explanation'
|
||||
assert_contain %r{needs to be confirmed within 3 days}
|
||||
refute user.reload.confirmed?
|
||||
assert_not user.reload.confirmed?
|
||||
assert_current_url "/users/confirmation?confirmation_token=#{user.raw_confirmation_token}"
|
||||
end
|
||||
end
|
||||
@@ -86,7 +86,7 @@ class ConfirmationTest < Devise::IntegrationTest
|
||||
test 'user with valid confirmation token should be able to confirm an account before the token has expired' do
|
||||
swap Devise, confirm_within: 3.days do
|
||||
user = create_user(confirm: false, confirmation_sent_at: 2.days.ago)
|
||||
refute user.confirmed?
|
||||
assert_not user.confirmed?
|
||||
visit_user_confirmation_with_token(user.raw_confirmation_token)
|
||||
|
||||
assert_contain 'Your email address has been successfully confirmed.'
|
||||
@@ -132,7 +132,7 @@ class ConfirmationTest < Devise::IntegrationTest
|
||||
sign_in_as_user(confirm: false)
|
||||
|
||||
assert_contain 'You have to confirm your email address before continuing'
|
||||
refute warden.authenticated?(:user)
|
||||
assert_not warden.authenticated?(:user)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -143,7 +143,7 @@ class ConfirmationTest < Devise::IntegrationTest
|
||||
end
|
||||
|
||||
assert_contain 'Invalid Email or password'
|
||||
refute warden.authenticated?(:user)
|
||||
assert_not warden.authenticated?(:user)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -178,13 +178,13 @@ class ConfirmationTest < Devise::IntegrationTest
|
||||
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"
|
||||
assert_contain %r{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"
|
||||
assert_contain %r{Confirmation token can['’]t be blank}
|
||||
end
|
||||
|
||||
test "should not be able to confirm user with blank confirmation token" do
|
||||
@@ -193,7 +193,7 @@ class ConfirmationTest < Devise::IntegrationTest
|
||||
|
||||
visit_user_confirmation_with_token("")
|
||||
|
||||
assert_contain "Confirmation token can't be blank"
|
||||
assert_contain %r{Confirmation token can['’]t be blank}
|
||||
end
|
||||
|
||||
test "should not be able to confirm user with nil confirmation token" do
|
||||
@@ -202,7 +202,7 @@ class ConfirmationTest < Devise::IntegrationTest
|
||||
|
||||
visit_user_confirmation_with_token(nil)
|
||||
|
||||
assert_contain "Confirmation token can't be blank"
|
||||
assert_contain %r{Confirmation token can['’]t be blank}
|
||||
end
|
||||
|
||||
test 'error message is configurable by resource name' do
|
||||
@@ -214,40 +214,32 @@ class ConfirmationTest < Devise::IntegrationTest
|
||||
end
|
||||
end
|
||||
|
||||
test 'resent confirmation token with valid E-Mail in XML format should return valid response' do
|
||||
test 'resent confirmation token with valid e-mail in JSON format should return empty and valid response' do
|
||||
user = create_user(confirm: false)
|
||||
post user_confirmation_path(format: 'xml'), params: { user: { email: user.email } }
|
||||
post user_confirmation_path(format: 'json'), params: { user: { email: user.email } }
|
||||
assert_response :success
|
||||
assert_equal response.body, {}.to_xml
|
||||
assert_equal({}.to_json, response.body)
|
||||
end
|
||||
|
||||
test 'resent confirmation token with invalid E-Mail in XML format should return invalid response' do
|
||||
test 'resent confirmation token with invalid e-mail in JSON format should return invalid response' do
|
||||
create_user(confirm: false)
|
||||
post user_confirmation_path(format: 'xml'), params: { user: { email: 'invalid.test@test.com' } }
|
||||
post user_confirmation_path(format: 'json'), params: { user: { email: 'invalid.test@test.com' } }
|
||||
assert_response :unprocessable_entity
|
||||
assert response.body.include? %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<errors>)
|
||||
assert_includes response.body, '{"errors":{'
|
||||
end
|
||||
|
||||
test 'confirm account with valid confirmation token in XML format should return valid response' do
|
||||
test 'confirm account with valid confirmation token in JSON format should return valid response' do
|
||||
user = create_user(confirm: false)
|
||||
get user_confirmation_path(confirmation_token: user.raw_confirmation_token, format: 'xml')
|
||||
get user_confirmation_path(confirmation_token: user.raw_confirmation_token, format: 'json')
|
||||
assert_response :success
|
||||
assert response.body.include? %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<user>)
|
||||
assert_includes response.body, '{"user":{'
|
||||
end
|
||||
|
||||
test 'confirm account with invalid confirmation token in XML format should return invalid response' do
|
||||
test 'confirm account with invalid confirmation token in JSON format should return invalid response' do
|
||||
create_user(confirm: false)
|
||||
get user_confirmation_path(confirmation_token: 'invalid_confirmation', format: 'xml')
|
||||
get user_confirmation_path(confirmation_token: 'invalid_confirmation', format: 'json')
|
||||
assert_response :unprocessable_entity
|
||||
assert response.body.include? %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<errors>)
|
||||
end
|
||||
|
||||
test 'request an account confirmation account with JSON, should return an empty JSON' do
|
||||
user = create_user(confirm: false)
|
||||
|
||||
post user_confirmation_path, params: { user: { email: user.email }, format: :json }
|
||||
assert_response :success
|
||||
assert_equal response.body, {}.to_json
|
||||
assert_includes response.body, '{"confirmation_token":['
|
||||
end
|
||||
|
||||
test "when in paranoid mode and with a valid e-mail, should not say that the e-mail is valid" do
|
||||
@@ -282,7 +274,7 @@ class ConfirmationTest < Devise::IntegrationTest
|
||||
end
|
||||
|
||||
class ConfirmationOnChangeTest < Devise::IntegrationTest
|
||||
def create_second_admin(options={})
|
||||
def create_second_admin(options = {})
|
||||
@admin = nil
|
||||
create_admin(options)
|
||||
end
|
||||
@@ -316,7 +308,7 @@ class ConfirmationOnChangeTest < Devise::IntegrationTest
|
||||
assert_contain 'Your email address has been successfully confirmed.'
|
||||
assert_current_url '/admin_area/sign_in'
|
||||
assert admin.reload.confirmed?
|
||||
refute admin.reload.pending_reconfirmation?
|
||||
assert_not admin.reload.pending_reconfirmation?
|
||||
end
|
||||
|
||||
test 'admin with previously valid confirmation token should not be able to confirm email after email changed again' do
|
||||
@@ -338,7 +330,7 @@ class ConfirmationOnChangeTest < Devise::IntegrationTest
|
||||
assert_contain 'Your email address has been successfully confirmed.'
|
||||
assert_current_url '/admin_area/sign_in'
|
||||
assert admin.reload.confirmed?
|
||||
refute admin.reload.pending_reconfirmation?
|
||||
assert_not admin.reload.pending_reconfirmation?
|
||||
end
|
||||
|
||||
test 'admin email should be unique also within unconfirmed_email' do
|
||||
|
||||
@@ -21,7 +21,7 @@ class DatabaseAuthenticationTest < Devise::IntegrationTest
|
||||
fill_in 'email', with: 'foo@bar.com'
|
||||
end
|
||||
|
||||
refute warden.authenticated?(:user)
|
||||
assert_not warden.authenticated?(:user)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -43,14 +43,14 @@ class DatabaseAuthenticationTest < Devise::IntegrationTest
|
||||
fill_in 'email', with: ' foo@bar.com '
|
||||
end
|
||||
|
||||
refute warden.authenticated?(:user)
|
||||
assert_not warden.authenticated?(:user)
|
||||
end
|
||||
end
|
||||
|
||||
test 'sign in should not authenticate if not using proper authentication keys' do
|
||||
swap Devise, authentication_keys: [:username] do
|
||||
sign_in_as_user
|
||||
refute warden.authenticated?(:user)
|
||||
assert_not warden.authenticated?(:user)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -61,7 +61,7 @@ class DatabaseAuthenticationTest < Devise::IntegrationTest
|
||||
end
|
||||
|
||||
assert_contain 'Invalid email address'
|
||||
refute warden.authenticated?(:admin)
|
||||
assert_not warden.authenticated?(:admin)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -71,7 +71,7 @@ class DatabaseAuthenticationTest < Devise::IntegrationTest
|
||||
end
|
||||
|
||||
assert_contain 'Invalid Email or password'
|
||||
refute warden.authenticated?(:admin)
|
||||
assert_not warden.authenticated?(:admin)
|
||||
end
|
||||
|
||||
test 'when in paranoid mode and without a valid e-mail' do
|
||||
|
||||
@@ -6,7 +6,7 @@ class HttpAuthenticationTest < Devise::IntegrationTest
|
||||
test 'sign in with HTTP should not run model validations' do
|
||||
sign_in_as_new_user_with_http
|
||||
|
||||
refute User.validations_performed
|
||||
assert_not User.validations_performed
|
||||
end
|
||||
|
||||
test 'handles unverified requests gets rid of caches but continues signed in' do
|
||||
@@ -22,10 +22,10 @@ class HttpAuthenticationTest < Devise::IntegrationTest
|
||||
swap Devise, skip_session_storage: [] do
|
||||
sign_in_as_new_user_with_http
|
||||
assert_response 200
|
||||
assert_match '<email>user@test.com</email>', response.body
|
||||
assert_match '"email":"user@test.com"', response.body
|
||||
assert warden.authenticated?(:user)
|
||||
|
||||
get users_path(format: :xml)
|
||||
get users_path(format: :json)
|
||||
assert_response 200
|
||||
end
|
||||
end
|
||||
@@ -34,10 +34,10 @@ class HttpAuthenticationTest < Devise::IntegrationTest
|
||||
swap Devise, skip_session_storage: [:http_auth] do
|
||||
sign_in_as_new_user_with_http
|
||||
assert_response 200
|
||||
assert_match '<email>user@test.com</email>', response.body
|
||||
assert_match '"email":"user@test.com"', response.body
|
||||
assert warden.authenticated?(:user)
|
||||
|
||||
get users_path(format: :xml)
|
||||
get users_path(format: :json)
|
||||
assert_response 401
|
||||
end
|
||||
end
|
||||
@@ -51,8 +51,8 @@ class HttpAuthenticationTest < Devise::IntegrationTest
|
||||
test 'uses the request format as response content type' do
|
||||
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_equal "application/json; charset=utf-8", headers["Content-Type"]
|
||||
assert_match '"error":"Invalid Email or password."', response.body
|
||||
end
|
||||
|
||||
test 'returns a custom response with www-authenticate and chosen realm' do
|
||||
@@ -67,7 +67,7 @@ class HttpAuthenticationTest < Devise::IntegrationTest
|
||||
swap Devise, authentication_keys: [:username] do
|
||||
sign_in_as_new_user_with_http("usertest")
|
||||
assert_response :success
|
||||
assert_match '<email>user@test.com</email>', response.body
|
||||
assert_match '"email":"user@test.com"', response.body
|
||||
assert warden.authenticated?(:user)
|
||||
end
|
||||
end
|
||||
@@ -76,7 +76,7 @@ class HttpAuthenticationTest < Devise::IntegrationTest
|
||||
swap Devise, authentication_keys: { username: false, email: false } do
|
||||
sign_in_as_new_user_with_http("usertest")
|
||||
assert_response :success
|
||||
assert_match '<email>user@test.com</email>', response.body
|
||||
assert_match '"email":"user@test.com"', response.body
|
||||
assert warden.authenticated?(:user)
|
||||
end
|
||||
end
|
||||
@@ -85,7 +85,7 @@ class HttpAuthenticationTest < Devise::IntegrationTest
|
||||
swap Devise, authentication_keys: { email: false, username: false }, http_authentication_key: :username do
|
||||
sign_in_as_new_user_with_http("usertest")
|
||||
assert_response :success
|
||||
assert_match '<email>user@test.com</email>', response.body
|
||||
assert_match '"email":"user@test.com"', response.body
|
||||
assert warden.authenticated?(:user)
|
||||
end
|
||||
end
|
||||
@@ -99,16 +99,15 @@ class HttpAuthenticationTest < Devise::IntegrationTest
|
||||
end
|
||||
|
||||
private
|
||||
def sign_in_as_new_user_with_http(username="user@test.com", password="12345678")
|
||||
def sign_in_as_new_user_with_http(username = "user@test.com", password = "12345678")
|
||||
user = create_user
|
||||
get users_path(format: :xml), headers: { "HTTP_AUTHORIZATION" => "Basic #{Base64.encode64("#{username}:#{password}")}" }
|
||||
get users_path(format: :json), headers: { "HTTP_AUTHORIZATION" => "Basic #{Base64.encode64("#{username}:#{password}")}" }
|
||||
user
|
||||
end
|
||||
|
||||
# Sign in with oauth2 token. This is just to test that it isn't misinterpreted as basic authentication
|
||||
def add_oauth2_header
|
||||
user = create_user
|
||||
get users_path(format: :xml), headers: { "HTTP_AUTHORIZATION" => "OAuth #{Base64.encode64("#{user.email}:12345678")}" }
|
||||
get users_path(format: :json), headers: { "HTTP_AUTHORIZATION" => "OAuth #{Base64.encode64("#{user.email}:12345678")}" }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -87,7 +87,7 @@ class LockTest < Devise::IntegrationTest
|
||||
|
||||
assert_current_url "/users/sign_in"
|
||||
assert_contain 'Your account has been unlocked successfully. Please sign in to continue.'
|
||||
refute user.reload.access_locked?
|
||||
assert_not user.reload.access_locked?
|
||||
end
|
||||
|
||||
test "user should not send a new e-mail if already locked" do
|
||||
@@ -99,7 +99,7 @@ class LockTest < Devise::IntegrationTest
|
||||
|
||||
sign_in_as_user(password: "invalid")
|
||||
assert_contain 'Your account is locked.'
|
||||
assert ActionMailer::Base.deliveries.empty?
|
||||
assert_empty ActionMailer::Base.deliveries
|
||||
end
|
||||
|
||||
test 'error message is configurable by resource name' do
|
||||
@@ -130,48 +130,39 @@ class LockTest < Devise::IntegrationTest
|
||||
end
|
||||
end
|
||||
|
||||
test 'user should be able to request a new unlock token via XML request' do
|
||||
test 'user should be able to request a new unlock token via JSON request and should return empty and valid response' do
|
||||
user = create_user(locked: true)
|
||||
ActionMailer::Base.deliveries.clear
|
||||
|
||||
post user_unlock_path(format: 'xml'), params: { user: {email: user.email} }
|
||||
post user_unlock_path(format: 'json'), params: { user: {email: user.email} }
|
||||
assert_response :success
|
||||
assert_equal response.body, {}.to_xml
|
||||
|
||||
assert_equal({}.to_json, response.body)
|
||||
assert_equal 1, ActionMailer::Base.deliveries.size
|
||||
end
|
||||
|
||||
test 'unlocked user should not be able to request a unlock token via XML request' do
|
||||
test 'unlocked user should not be able to request a unlock token via JSON request' do
|
||||
user = create_user(locked: false)
|
||||
ActionMailer::Base.deliveries.clear
|
||||
|
||||
post user_unlock_path(format: 'xml'), params: { user: {email: user.email} }
|
||||
post user_unlock_path(format: 'json'), params: { user: {email: user.email} }
|
||||
assert_response :unprocessable_entity
|
||||
assert response.body.include? %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<errors>)
|
||||
assert_includes response.body, '{"errors":{'
|
||||
assert_equal 0, ActionMailer::Base.deliveries.size
|
||||
end
|
||||
|
||||
test 'user with valid unlock token should be able to unlock account via XML request' do
|
||||
test 'user with valid unlock token should be able to unlock account via JSON request' do
|
||||
user = create_user()
|
||||
raw = user.lock_access!
|
||||
assert user.access_locked?
|
||||
get user_unlock_path(format: 'xml', unlock_token: raw)
|
||||
get user_unlock_path(format: 'json', unlock_token: raw)
|
||||
assert_response :success
|
||||
assert response.body.include? %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<user>)
|
||||
assert_includes response.body, '{"user":{'
|
||||
end
|
||||
|
||||
|
||||
test 'user with invalid unlock token should not be able to unlock the account via XML request' do
|
||||
get user_unlock_path(format: 'xml', unlock_token: 'invalid_token')
|
||||
test 'user with invalid unlock token should not be able to unlock the account via JSON request' do
|
||||
get user_unlock_path(format: 'json', unlock_token: 'invalid_token')
|
||||
assert_response :unprocessable_entity
|
||||
assert response.body.include? %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<errors>)
|
||||
end
|
||||
|
||||
test "when using json to ask a unlock request, should not return the user" do
|
||||
user = create_user(locked: true)
|
||||
post user_unlock_path(format: "json", user: {email: user.email})
|
||||
assert_response :success
|
||||
assert_equal response.body, {}.to_json
|
||||
assert_includes response.body, '{"unlock_token":['
|
||||
end
|
||||
|
||||
test "in paranoid mode, when trying to unlock a user that exists it should not say that it exists if it is locked" do
|
||||
|
||||
@@ -23,6 +23,9 @@ class OmniauthableIntegrationTest < Devise::IntegrationTest
|
||||
"extra" => {"user_hash" => FACEBOOK_INFO}
|
||||
}
|
||||
OmniAuth.config.add_camelization 'facebook', 'FaceBook'
|
||||
if OmniAuth.config.respond_to?(:request_validation_phase)
|
||||
OmniAuth.config.request_validation_phase = ->(env) {}
|
||||
end
|
||||
end
|
||||
|
||||
teardown do
|
||||
@@ -45,17 +48,17 @@ class OmniauthableIntegrationTest < Devise::IntegrationTest
|
||||
test "omniauth sign in should not run model validations" do
|
||||
stub_action!(:sign_in_facebook) do
|
||||
create_user
|
||||
visit "/users/sign_in"
|
||||
click_link "Sign in with FaceBook"
|
||||
post "/users/auth/facebook"
|
||||
follow_redirect!
|
||||
assert warden.authenticated?(:user)
|
||||
|
||||
refute User.validations_performed
|
||||
assert_not User.validations_performed
|
||||
end
|
||||
end
|
||||
|
||||
test "can access omniauth.auth in the env hash" do
|
||||
visit "/users/sign_in"
|
||||
click_link "Sign in with FaceBook"
|
||||
post "/users/auth/facebook"
|
||||
follow_redirect!
|
||||
|
||||
json = ActiveSupport::JSON.decode(response.body)
|
||||
|
||||
@@ -68,8 +71,8 @@ class OmniauthableIntegrationTest < Devise::IntegrationTest
|
||||
|
||||
test "cleans up session on sign up" do
|
||||
assert_no_difference "User.count" do
|
||||
visit "/users/sign_in"
|
||||
click_link "Sign in with FaceBook"
|
||||
post "/users/auth/facebook"
|
||||
follow_redirect!
|
||||
end
|
||||
|
||||
assert session["devise.facebook_data"]
|
||||
@@ -84,49 +87,58 @@ class OmniauthableIntegrationTest < Devise::IntegrationTest
|
||||
assert_current_url "/"
|
||||
assert_contain "You have signed up successfully."
|
||||
assert_contain "Hello User user@example.com"
|
||||
refute session["devise.facebook_data"]
|
||||
assert_not session["devise.facebook_data"]
|
||||
end
|
||||
|
||||
test "cleans up session on cancel" do
|
||||
assert_no_difference "User.count" do
|
||||
visit "/users/sign_in"
|
||||
click_link "Sign in with FaceBook"
|
||||
post "/users/auth/facebook"
|
||||
follow_redirect!
|
||||
end
|
||||
|
||||
assert session["devise.facebook_data"]
|
||||
visit "/users/cancel"
|
||||
assert !session["devise.facebook_data"]
|
||||
assert_not session["devise.facebook_data"]
|
||||
end
|
||||
|
||||
test "cleans up session on sign in" do
|
||||
assert_no_difference "User.count" do
|
||||
visit "/users/sign_in"
|
||||
click_link "Sign in with FaceBook"
|
||||
post "/users/auth/facebook"
|
||||
follow_redirect!
|
||||
end
|
||||
|
||||
assert session["devise.facebook_data"]
|
||||
sign_in_as_user
|
||||
assert !session["devise.facebook_data"]
|
||||
assert_not session["devise.facebook_data"]
|
||||
end
|
||||
|
||||
test "sign in and send remember token if configured" do
|
||||
visit "/users/sign_in"
|
||||
click_link "Sign in with FaceBook"
|
||||
post "/users/auth/facebook"
|
||||
follow_redirect!
|
||||
assert_nil warden.cookies["remember_user_token"]
|
||||
|
||||
stub_action!(:sign_in_facebook) do
|
||||
create_user
|
||||
visit "/users/sign_in"
|
||||
click_link "Sign in with FaceBook"
|
||||
post "/users/auth/facebook"
|
||||
follow_redirect!
|
||||
assert warden.authenticated?(:user)
|
||||
assert warden.cookies["remember_user_token"]
|
||||
end
|
||||
end
|
||||
|
||||
test "generates a link to authenticate with provider" do
|
||||
visit "/users/sign_in"
|
||||
assert_select "form[action=?][method=post]", "/users/auth/facebook" do
|
||||
assert_select "input[type=submit][value=?]", "Sign in with FaceBook"
|
||||
end
|
||||
end
|
||||
|
||||
test "generates a proper link when SCRIPT_NAME is set" do
|
||||
header 'SCRIPT_NAME', '/q'
|
||||
visit "/users/sign_in"
|
||||
assert_select "a", href: "/q/users/auth/facebook"
|
||||
assert_select "form[action=?][method=post]", "/q/users/auth/facebook" do
|
||||
assert_select "input[type=submit][value=?]", "Sign in with FaceBook"
|
||||
end
|
||||
end
|
||||
|
||||
test "handles callback error parameter according to the specification" do
|
||||
@@ -139,10 +151,10 @@ class OmniauthableIntegrationTest < Devise::IntegrationTest
|
||||
test "handles other exceptions from OmniAuth" do
|
||||
OmniAuth.config.mock_auth[:facebook] = :invalid_credentials
|
||||
|
||||
visit "/users/sign_in"
|
||||
click_link "Sign in with FaceBook"
|
||||
post "/users/auth/facebook"
|
||||
follow_redirect!
|
||||
follow_redirect!
|
||||
|
||||
assert_current_url "/users/sign_in"
|
||||
assert_contain 'Could not authenticate you from FaceBook because "Invalid credentials".'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -12,7 +12,7 @@ class PasswordTest < Devise::IntegrationTest
|
||||
def request_forgot_password(&block)
|
||||
visit_new_password_path
|
||||
assert_response :success
|
||||
refute warden.authenticated?(:user)
|
||||
assert_not warden.authenticated?(:user)
|
||||
|
||||
fill_in 'email', with: 'user@test.com'
|
||||
yield if block_given?
|
||||
@@ -21,7 +21,7 @@ class PasswordTest < Devise::IntegrationTest
|
||||
click_button 'Send me reset password instructions'
|
||||
end
|
||||
|
||||
def reset_password(options={}, &block)
|
||||
def reset_password(options = {}, &block)
|
||||
unless options[:visit] == false
|
||||
visit edit_user_password_path(reset_password_token: options[:reset_password_token] || "abcdef")
|
||||
assert_response :success
|
||||
@@ -160,7 +160,7 @@ class PasswordTest < Devise::IntegrationTest
|
||||
assert_current_url '/users/password'
|
||||
assert_have_selector '#error_explanation'
|
||||
assert_contain %r{Reset password token(.*)invalid}
|
||||
refute user.reload.valid_password?('987654321')
|
||||
assert_not user.reload.valid_password?('987654321')
|
||||
end
|
||||
|
||||
test 'not authenticated user with valid reset password token but invalid password should not be able to change their password' do
|
||||
@@ -173,8 +173,8 @@ class PasswordTest < Devise::IntegrationTest
|
||||
assert_response :success
|
||||
assert_current_url '/users/password'
|
||||
assert_have_selector '#error_explanation'
|
||||
assert_contain "Password confirmation doesn't match Password"
|
||||
refute user.reload.valid_password?('987654321')
|
||||
assert_contain %r{Password confirmation doesn['’]t match Password}
|
||||
assert_not user.reload.valid_password?('987654321')
|
||||
end
|
||||
|
||||
test 'not authenticated user with valid data should be able to change their password' do
|
||||
@@ -194,7 +194,7 @@ class PasswordTest < Devise::IntegrationTest
|
||||
reset_password { fill_in 'Confirm new password', with: 'other_password' }
|
||||
assert_response :success
|
||||
assert_have_selector '#error_explanation'
|
||||
refute user.reload.valid_password?('987654321')
|
||||
assert_not user.reload.valid_password?('987654321')
|
||||
|
||||
reset_password visit: false
|
||||
assert_contain 'Your password has been changed successfully.'
|
||||
@@ -218,7 +218,32 @@ class PasswordTest < Devise::IntegrationTest
|
||||
assert_contain 'Your password has been changed successfully.'
|
||||
assert_not_contain 'You are now signed in.'
|
||||
assert_equal new_user_session_path, @request.path
|
||||
assert !warden.authenticated?(:user)
|
||||
assert_not warden.authenticated?(:user)
|
||||
end
|
||||
end
|
||||
|
||||
test 'does not sign in user automatically after changing its password if resource_class.sign_in_after_reset_password is false' do
|
||||
swap_model_config User, sign_in_after_reset_password: false do
|
||||
create_user
|
||||
request_forgot_password
|
||||
reset_password
|
||||
|
||||
assert_contain 'Your password has been changed successfully'
|
||||
assert_not_contain 'You are now signed in.'
|
||||
assert_equal new_user_session_path, @request.path
|
||||
assert_not warden.authenticated?(:user)
|
||||
end
|
||||
end
|
||||
|
||||
test 'sign in user automatically after changing its password if resource_class.sign_in_after_reset_password is true' do
|
||||
swap Devise, sign_in_after_reset_password: false do
|
||||
swap_model_config User, sign_in_after_reset_password: true do
|
||||
create_user
|
||||
request_forgot_password
|
||||
reset_password
|
||||
|
||||
assert warden.authenticated?(:user)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -232,7 +257,7 @@ class PasswordTest < Devise::IntegrationTest
|
||||
assert_contain 'Your password has been changed successfully.'
|
||||
assert_not_contain 'You are now signed in.'
|
||||
assert_equal new_user_session_path, @request.path
|
||||
assert !warden.authenticated?(:user)
|
||||
assert_not warden.authenticated?(:user)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -244,7 +269,7 @@ class PasswordTest < Devise::IntegrationTest
|
||||
reset_password
|
||||
|
||||
assert_contain 'Your password has been changed successfully.'
|
||||
assert !user.reload.access_locked?
|
||||
assert_not user.reload.access_locked?
|
||||
assert warden.authenticated?(:user)
|
||||
end
|
||||
end
|
||||
@@ -256,68 +281,58 @@ class PasswordTest < Devise::IntegrationTest
|
||||
reset_password
|
||||
|
||||
assert_contain 'Your password has been changed successfully.'
|
||||
assert !user.reload.access_locked?
|
||||
assert_not user.reload.access_locked?
|
||||
assert warden.authenticated?(:user)
|
||||
end
|
||||
end
|
||||
|
||||
test 'reset password request with valid E-Mail in XML format should return valid response' do
|
||||
test 'reset password request with valid e-mail in JSON format should return empty and valid response' do
|
||||
create_user
|
||||
post user_password_path(format: 'xml'), params: { user: {email: "user@test.com"} }
|
||||
post user_password_path(format: 'json'), params: { user: {email: "user@test.com"} }
|
||||
assert_response :success
|
||||
assert_equal response.body, { }.to_xml
|
||||
assert_equal({}.to_json, response.body)
|
||||
end
|
||||
|
||||
test 'reset password request with invalid E-Mail in XML format should return valid response' do
|
||||
test 'reset password request with invalid e-mail in JSON format should return valid response' do
|
||||
create_user
|
||||
post user_password_path(format: 'xml'), params: { user: {email: "invalid.test@test.com"} }
|
||||
post user_password_path(format: 'json'), params: { user: {email: "invalid.test@test.com"} }
|
||||
assert_response :unprocessable_entity
|
||||
assert response.body.include? %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<errors>)
|
||||
assert_includes response.body, '{"errors":{'
|
||||
end
|
||||
|
||||
test 'reset password request with invalid E-Mail in XML format should return empty and valid response' do
|
||||
test 'reset password request with invalid e-mail in JSON format should return empty and valid response in paranoid mode' do
|
||||
swap Devise, paranoid: true do
|
||||
create_user
|
||||
post user_password_path(format: 'xml'), params: { user: {email: "invalid@test.com"} }
|
||||
post user_password_path(format: 'json'), params: { user: {email: "invalid@test.com"} }
|
||||
assert_response :success
|
||||
assert_equal response.body, { }.to_xml
|
||||
assert_equal({}.to_json, response.body)
|
||||
end
|
||||
end
|
||||
|
||||
test 'change password with valid parameters in XML format should return valid response' do
|
||||
test 'change password with valid parameters in JSON format should return valid response' do
|
||||
create_user
|
||||
request_forgot_password
|
||||
put user_password_path(format: 'xml'), params: { user: {
|
||||
put user_password_path(format: 'json'), params: { user: {
|
||||
reset_password_token: 'abcdef', password: '987654321', password_confirmation: '987654321'
|
||||
}
|
||||
}
|
||||
} }
|
||||
assert_response :success
|
||||
assert warden.authenticated?(:user)
|
||||
end
|
||||
|
||||
test 'change password with invalid token in XML format should return invalid response' do
|
||||
test 'change password with invalid token in JSON format should return invalid response' do
|
||||
create_user
|
||||
request_forgot_password
|
||||
put user_password_path(format: 'xml'), params: { user: {reset_password_token: 'invalid.token', password: '987654321', password_confirmation: '987654321'} }
|
||||
put user_password_path(format: 'json'), params: { user: {reset_password_token: 'invalid.token', password: '987654321', password_confirmation: '987654321'} }
|
||||
assert_response :unprocessable_entity
|
||||
assert response.body.include? %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<errors>)
|
||||
assert_includes response.body, '{"errors":{'
|
||||
end
|
||||
|
||||
test 'change password with invalid new password in XML format should return invalid response' do
|
||||
test 'change password with invalid new password in JSON format should return invalid response' do
|
||||
user = create_user
|
||||
request_forgot_password
|
||||
put user_password_path(format: 'xml'), params: { user: {reset_password_token: user.reload.reset_password_token, password: '', password_confirmation: '987654321'} }
|
||||
put user_password_path(format: 'json'), params: { user: {reset_password_token: user.reload.reset_password_token, password: '', password_confirmation: '987654321'} }
|
||||
assert_response :unprocessable_entity
|
||||
assert response.body.include? %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<errors>)
|
||||
end
|
||||
|
||||
test "when using json requests to ask a confirmable request, should not return the object" do
|
||||
user = create_user(confirm: false)
|
||||
|
||||
post user_password_path(format: :json), params: { user: { email: user.email } }
|
||||
|
||||
assert_response :success
|
||||
assert_equal response.body, "{}"
|
||||
assert_includes response.body, '{"errors":{'
|
||||
end
|
||||
|
||||
test "when in paranoid mode and with an invalid e-mail, asking to reset a password should display a message that does not indicates that the e-mail does not exists in the database" do
|
||||
|
||||
@@ -20,7 +20,7 @@ class RegistrationTest < Devise::IntegrationTest
|
||||
assert_current_url "/admin_area/home"
|
||||
|
||||
admin = Admin.to_adapter.find_first(order: [:id, :desc])
|
||||
assert_equal admin.email, 'new_user@test.com'
|
||||
assert_equal 'new_user@test.com', admin.email
|
||||
end
|
||||
|
||||
test 'a guest admin should be able to sign in and be redirected to a custom location' do
|
||||
@@ -66,11 +66,11 @@ class RegistrationTest < Devise::IntegrationTest
|
||||
assert_not_contain 'You have to confirm your account before continuing'
|
||||
assert_current_url "/"
|
||||
|
||||
refute warden.authenticated?(:user)
|
||||
assert_not warden.authenticated?(:user)
|
||||
|
||||
user = User.to_adapter.find_first(order: [:id, :desc])
|
||||
assert_equal user.email, 'new_user@test.com'
|
||||
refute user.confirmed?
|
||||
assert_equal 'new_user@test.com', user.email
|
||||
assert_not user.confirmed?
|
||||
end
|
||||
|
||||
test 'a guest user should receive the confirmation instructions from the default mailer' do
|
||||
@@ -94,7 +94,7 @@ class RegistrationTest < Devise::IntegrationTest
|
||||
click_button 'Sign up'
|
||||
|
||||
assert_current_url "/?custom=1"
|
||||
refute warden.authenticated?(:user)
|
||||
assert_not warden.authenticated?(:user)
|
||||
end
|
||||
|
||||
test 'a guest user cannot sign up with invalid information' do
|
||||
@@ -112,11 +112,11 @@ class RegistrationTest < Devise::IntegrationTest
|
||||
assert_template 'registrations/new'
|
||||
assert_have_selector '#error_explanation'
|
||||
assert_contain "Email is invalid"
|
||||
assert_contain "Password confirmation doesn't match Password"
|
||||
assert_contain %r{Password confirmation doesn['’]t match Password}
|
||||
assert_contain "2 errors prohibited"
|
||||
assert_nil User.to_adapter.find_first
|
||||
|
||||
refute warden.authenticated?(:user)
|
||||
assert_not warden.authenticated?(:user)
|
||||
end
|
||||
|
||||
test 'a guest should not sign up with email/password that already exists' do
|
||||
@@ -135,7 +135,7 @@ class RegistrationTest < Devise::IntegrationTest
|
||||
assert_current_url '/users'
|
||||
assert_contain(/Email.*already.*taken/)
|
||||
|
||||
refute warden.authenticated?(:user)
|
||||
assert_not warden.authenticated?(:user)
|
||||
end
|
||||
|
||||
test 'a guest should not be able to change account' do
|
||||
@@ -189,9 +189,9 @@ class RegistrationTest < Devise::IntegrationTest
|
||||
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_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)
|
||||
assert_not warden.authenticated?(:user)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -251,10 +251,10 @@ class RegistrationTest < Devise::IntegrationTest
|
||||
fill_in 'current password', with: '12345678'
|
||||
click_button 'Update'
|
||||
|
||||
assert_contain "Password confirmation doesn't match Password"
|
||||
refute User.to_adapter.find_first.valid_password?('pas123')
|
||||
assert_contain %r{Password confirmation doesn['’]t match Password}
|
||||
assert_not User.to_adapter.find_first.valid_password?('pas123')
|
||||
end
|
||||
|
||||
|
||||
test 'a signed in user should see a warning about minimum password length' do
|
||||
sign_in_as_user
|
||||
get edit_user_registration_path
|
||||
@@ -268,7 +268,7 @@ class RegistrationTest < Devise::IntegrationTest
|
||||
click_button "Cancel my account"
|
||||
assert_contain "Bye! Your account has been successfully cancelled. We hope to see you again soon."
|
||||
|
||||
assert User.to_adapter.find_all.empty?
|
||||
assert_empty User.to_adapter.find_all
|
||||
end
|
||||
|
||||
test 'a user should be able to cancel sign up by deleting data in the session' do
|
||||
@@ -283,13 +283,6 @@ class RegistrationTest < Devise::IntegrationTest
|
||||
assert_redirected_to new_user_registration_path
|
||||
end
|
||||
|
||||
test 'a user with XML sign up stub' do
|
||||
get new_user_registration_path(format: 'xml')
|
||||
assert_response :success
|
||||
assert_match %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<user>), response.body
|
||||
assert_no_match(/<confirmation-token/, response.body)
|
||||
end
|
||||
|
||||
test 'a user with JSON sign up stub' do
|
||||
get new_user_registration_path(format: 'json')
|
||||
assert_response :success
|
||||
@@ -297,49 +290,49 @@ class RegistrationTest < Devise::IntegrationTest
|
||||
assert_no_match(/"confirmation_token"/, response.body)
|
||||
end
|
||||
|
||||
test 'an admin sign up with valid information in XML format should return valid response' do
|
||||
post admin_registration_path(format: 'xml'), params: { admin: { email: 'new_user@test.com', password: 'new_user123', password_confirmation: 'new_user123' } }
|
||||
test 'an admin sign up with valid information in JSON format should return valid response' do
|
||||
post admin_registration_path(format: 'json'), params: { admin: { email: 'new_user@test.com', password: 'new_user123', password_confirmation: 'new_user123' } }
|
||||
assert_response :success
|
||||
assert response.body.include? %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<admin>)
|
||||
assert_includes response.body, '{"admin":{'
|
||||
|
||||
admin = Admin.to_adapter.find_first(order: [:id, :desc])
|
||||
assert_equal admin.email, 'new_user@test.com'
|
||||
assert_equal 'new_user@test.com', admin.email
|
||||
end
|
||||
|
||||
test 'a user sign up with valid information in XML format should return valid response' do
|
||||
post user_registration_path(format: 'xml'), params: { user: { email: 'new_user@test.com', password: 'new_user123', password_confirmation: 'new_user123' } }
|
||||
test 'a user sign up with valid information in JSON format should return valid response' do
|
||||
post user_registration_path(format: 'json'), params: { user: { email: 'new_user@test.com', password: 'new_user123', password_confirmation: 'new_user123' } }
|
||||
assert_response :success
|
||||
assert response.body.include? %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<user>)
|
||||
assert_includes response.body, '{"user":{'
|
||||
|
||||
user = User.to_adapter.find_first(order: [:id, :desc])
|
||||
assert_equal user.email, 'new_user@test.com'
|
||||
assert_equal 'new_user@test.com', user.email
|
||||
end
|
||||
|
||||
test 'a user sign up with invalid information in XML format should return invalid response' do
|
||||
post user_registration_path(format: 'xml'), params: { user: { email: 'new_user@test.com', password: 'new_user123', password_confirmation: 'invalid' } }
|
||||
test 'a user sign up with invalid information in JSON format should return invalid response' do
|
||||
post user_registration_path(format: 'json'), params: { user: { email: 'new_user@test.com', password: 'new_user123', password_confirmation: 'invalid' } }
|
||||
assert_response :unprocessable_entity
|
||||
assert response.body.include? %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<errors>)
|
||||
assert_includes response.body, '{"errors":{'
|
||||
end
|
||||
|
||||
test 'a user update information with valid data in XML format should return valid response' do
|
||||
test 'a user update information with valid data in JSON format should return valid response' do
|
||||
user = sign_in_as_user
|
||||
put user_registration_path(format: 'xml'), params: { user: { current_password: '12345678', email: 'user.new@test.com' } }
|
||||
put user_registration_path(format: 'json'), params: { user: { current_password: '12345678', email: 'user.new@test.com' } }
|
||||
assert_response :success
|
||||
assert_equal user.reload.email, 'user.new@test.com'
|
||||
assert_equal 'user.new@test.com', user.reload.email
|
||||
end
|
||||
|
||||
test 'a user update information with invalid data in XML format should return invalid response' do
|
||||
test 'a user update information with invalid data in JSON format should return invalid response' do
|
||||
user = sign_in_as_user
|
||||
put user_registration_path(format: 'xml'), params: { user: { current_password: 'invalid', email: 'user.new@test.com' } }
|
||||
put user_registration_path(format: 'json'), params: { user: { current_password: 'invalid', email: 'user.new@test.com' } }
|
||||
assert_response :unprocessable_entity
|
||||
assert_equal user.reload.email, 'user@test.com'
|
||||
assert_equal 'user@test.com', user.reload.email
|
||||
end
|
||||
|
||||
test 'a user cancel their account in XML format should return valid response' do
|
||||
test 'a user cancel their account in JSON format should return valid response' do
|
||||
sign_in_as_user
|
||||
delete user_registration_path(format: 'xml')
|
||||
delete user_registration_path(format: 'json')
|
||||
assert_response :success
|
||||
assert_equal User.to_adapter.find_all.size, 0
|
||||
assert_equal 0, User.to_adapter.find_all.size
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class RememberMeTest < Devise::IntegrationTest
|
||||
def create_user_and_remember(add_to_token='')
|
||||
def create_user_and_remember(add_to_token = '')
|
||||
user = create_user
|
||||
user.remember_me!
|
||||
raw_cookie = User.serialize_into_cookie(user).tap { |a| a[1] << add_to_token }
|
||||
@@ -41,12 +41,12 @@ class RememberMeTest < Devise::IntegrationTest
|
||||
test 'handle unverified requests gets rid of caches' do
|
||||
swap ApplicationController, allow_forgery_protection: true do
|
||||
post exhibit_user_url(1)
|
||||
refute warden.authenticated?(:user)
|
||||
assert_not warden.authenticated?(:user)
|
||||
|
||||
create_user_and_remember
|
||||
post exhibit_user_url(1)
|
||||
assert_equal "User is not authenticated", response.body
|
||||
refute warden.authenticated?(:user)
|
||||
assert_not warden.authenticated?(:user)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -59,8 +59,8 @@ class RememberMeTest < Devise::IntegrationTest
|
||||
authenticity_token: "oops",
|
||||
user: { email: "jose.valim@gmail.com", password: "123456", remember_me: "1" }
|
||||
}
|
||||
refute warden.authenticated?(:user)
|
||||
refute request.cookies['remember_user_token']
|
||||
assert_not warden.authenticated?(:user)
|
||||
assert_not request.cookies['remember_user_token']
|
||||
end
|
||||
end
|
||||
|
||||
@@ -140,7 +140,7 @@ class RememberMeTest < Devise::IntegrationTest
|
||||
get root_path
|
||||
current_remember_token = request.cookies['remember_user_token']
|
||||
|
||||
refute_equal old_remember_token, current_remember_token
|
||||
assert_not_equal old_remember_token, current_remember_token
|
||||
end
|
||||
end
|
||||
|
||||
@@ -166,13 +166,13 @@ class RememberMeTest < Devise::IntegrationTest
|
||||
get root_path
|
||||
assert_response :success
|
||||
assert warden.authenticated?(:user)
|
||||
refute warden.authenticated?(:admin)
|
||||
assert_not warden.authenticated?(:admin)
|
||||
end
|
||||
|
||||
test 'do not remember with invalid token' do
|
||||
create_user_and_remember('add')
|
||||
get users_path
|
||||
refute warden.authenticated?(:user)
|
||||
assert_not warden.authenticated?(:user)
|
||||
assert_redirected_to new_user_session_path
|
||||
end
|
||||
|
||||
@@ -180,7 +180,7 @@ class RememberMeTest < Devise::IntegrationTest
|
||||
create_user_and_remember
|
||||
swap Devise, remember_for: 0.days do
|
||||
get users_path
|
||||
refute warden.authenticated?(:user)
|
||||
assert_not warden.authenticated?(:user)
|
||||
assert_redirected_to new_user_session_path
|
||||
end
|
||||
end
|
||||
@@ -191,11 +191,11 @@ class RememberMeTest < Devise::IntegrationTest
|
||||
assert warden.authenticated?(:user)
|
||||
|
||||
delete destroy_user_session_path
|
||||
refute warden.authenticated?(:user)
|
||||
assert_not warden.authenticated?(:user)
|
||||
assert_nil warden.cookies['remember_user_token']
|
||||
|
||||
get users_path
|
||||
refute warden.authenticated?(:user)
|
||||
assert_not warden.authenticated?(:user)
|
||||
end
|
||||
|
||||
test 'changing user password expires remember me token' do
|
||||
@@ -205,7 +205,7 @@ class RememberMeTest < Devise::IntegrationTest
|
||||
user.save!
|
||||
|
||||
get users_path
|
||||
refute warden.authenticated?(:user)
|
||||
assert_not warden.authenticated?(:user)
|
||||
end
|
||||
|
||||
test 'valid sign in calls after_remembered callback' do
|
||||
|
||||
@@ -58,7 +58,7 @@ class SessionTimeoutTest < Devise::IntegrationTest
|
||||
|
||||
get users_path
|
||||
assert_redirected_to users_path
|
||||
refute warden.authenticated?(:user)
|
||||
assert_not warden.authenticated?(:user)
|
||||
assert warden.authenticated?(:admin)
|
||||
end
|
||||
end
|
||||
@@ -72,8 +72,8 @@ class SessionTimeoutTest < Devise::IntegrationTest
|
||||
assert_not_nil last_request_at
|
||||
|
||||
get root_path
|
||||
refute warden.authenticated?(:user)
|
||||
refute warden.authenticated?(:admin)
|
||||
assert_not warden.authenticated?(:user)
|
||||
assert_not warden.authenticated?(:admin)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -109,8 +109,8 @@ class SessionTimeoutTest < Devise::IntegrationTest
|
||||
follow_redirect!
|
||||
|
||||
assert_response :success
|
||||
assert_contain 'Sign in'
|
||||
refute warden.authenticated?(:user)
|
||||
assert_contain 'Log in'
|
||||
assert_not warden.authenticated?(:user)
|
||||
end
|
||||
|
||||
test 'time out is not triggered on sign in' do
|
||||
@@ -136,7 +136,7 @@ class SessionTimeoutTest < Devise::IntegrationTest
|
||||
get expire_user_path(user)
|
||||
get users_path
|
||||
assert_redirected_to users_path
|
||||
refute warden.authenticated?(:user)
|
||||
assert_not warden.authenticated?(:user)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ class TrackableHooksTest < Devise::IntegrationTest
|
||||
test "trackable should not run model validations" do
|
||||
sign_in_as_user
|
||||
|
||||
refute User.validations_performed
|
||||
assert_not User.validations_performed
|
||||
end
|
||||
|
||||
test "current and last sign in timestamps are updated on each sign in" do
|
||||
|
||||
@@ -31,7 +31,7 @@ class ConfirmationInstructionsTest < ActionMailer::TestCase
|
||||
end
|
||||
|
||||
test 'content type should be set to html' do
|
||||
assert mail.content_type.include?('text/html')
|
||||
assert_includes mail.content_type, 'text/html'
|
||||
end
|
||||
|
||||
test 'send confirmation instructions to the user email' do
|
||||
@@ -88,7 +88,7 @@ class ConfirmationInstructionsTest < ActionMailer::TestCase
|
||||
host, port = ActionMailer::Base.default_url_options.values_at :host, :port
|
||||
|
||||
if mail.body.encoded =~ %r{<a href=\"http://#{host}:#{port}/users/confirmation\?confirmation_token=([^"]+)">}
|
||||
assert_equal $1, user.confirmation_token
|
||||
assert_equal user.confirmation_token, $1
|
||||
else
|
||||
flunk "expected confirmation url regex to match"
|
||||
end
|
||||
|
||||
@@ -35,7 +35,7 @@ class EmailChangedTest < ActionMailer::TestCase
|
||||
end
|
||||
|
||||
test 'content type should be set to html' do
|
||||
assert mail.content_type.include?('text/html')
|
||||
assert_includes mail.content_type, 'text/html'
|
||||
end
|
||||
|
||||
test 'send email changed to the original user email' do
|
||||
|
||||
@@ -34,7 +34,7 @@ class ResetPasswordInstructionsTest < ActionMailer::TestCase
|
||||
end
|
||||
|
||||
test 'content type should be set to html' do
|
||||
assert mail.content_type.include?('text/html')
|
||||
assert_includes mail.content_type, 'text/html'
|
||||
end
|
||||
|
||||
test 'send confirmation instructions to the user email' do
|
||||
@@ -84,7 +84,7 @@ class ResetPasswordInstructionsTest < ActionMailer::TestCase
|
||||
host, port = ActionMailer::Base.default_url_options.values_at :host, :port
|
||||
|
||||
if mail.body.encoded =~ %r{<a href=\"http://#{host}:#{port}/users/password/edit\?reset_password_token=([^"]+)">}
|
||||
assert_equal Devise.token_generator.digest(user.class, :reset_password_token, $1), user.reset_password_token
|
||||
assert_equal user.reset_password_token, Devise.token_generator.digest(user.class, :reset_password_token, $1)
|
||||
else
|
||||
flunk "expected reset password url regex to match"
|
||||
end
|
||||
|
||||
@@ -35,7 +35,7 @@ class UnlockInstructionsTest < ActionMailer::TestCase
|
||||
end
|
||||
|
||||
test 'content type should be set to html' do
|
||||
assert mail.content_type.include?('text/html')
|
||||
assert_includes mail.content_type, 'text/html'
|
||||
end
|
||||
|
||||
test 'send unlock instructions to the user email' do
|
||||
@@ -85,7 +85,7 @@ class UnlockInstructionsTest < ActionMailer::TestCase
|
||||
host, port = ActionMailer::Base.default_url_options.values_at :host, :port
|
||||
|
||||
if mail.body.encoded =~ %r{<a href=\"http://#{host}:#{port}/users/unlock\?unlock_token=([^"]+)">}
|
||||
assert_equal Devise.token_generator.digest(user.class, :unlock_token, $1), user.unlock_token
|
||||
assert_equal user.unlock_token, Devise.token_generator.digest(user.class, :unlock_token, $1)
|
||||
else
|
||||
flunk "expected unlock url regex to match"
|
||||
end
|
||||
|
||||
@@ -6,7 +6,7 @@ class FakeRequest < Struct.new(:path_info, :params)
|
||||
end
|
||||
|
||||
class MappingTest < ActiveSupport::TestCase
|
||||
def fake_request(path, params={})
|
||||
def fake_request(path, params = {})
|
||||
FakeRequest.new(path, params)
|
||||
end
|
||||
|
||||
@@ -117,7 +117,7 @@ class MappingTest < ActiveSupport::TestCase
|
||||
assert mapping.authenticatable?
|
||||
assert mapping.recoverable?
|
||||
assert mapping.lockable?
|
||||
refute mapping.omniauthable?
|
||||
assert_not mapping.omniauthable?
|
||||
end
|
||||
|
||||
test 'find mapping by path' do
|
||||
|
||||
@@ -4,12 +4,12 @@ require 'test_helper'
|
||||
|
||||
class AuthenticatableTest < ActiveSupport::TestCase
|
||||
test 'required_fields should be an empty array' do
|
||||
assert_equal Devise::Models::Validatable.required_fields(User), []
|
||||
assert_equal [], Devise::Models::Validatable.required_fields(User)
|
||||
end
|
||||
|
||||
test 'find_first_by_auth_conditions allows custom filtering parameters' do
|
||||
user = User.create!(email: "example@example.com", password: "1234567")
|
||||
assert_equal User.find_first_by_auth_conditions({ email: "example@example.com" }), user
|
||||
assert_equal user, User.find_first_by_auth_conditions({ email: "example@example.com" })
|
||||
assert_nil User.find_first_by_auth_conditions({ email: "example@example.com" }, id: user.id.to_s.next)
|
||||
end
|
||||
|
||||
@@ -18,24 +18,24 @@ class AuthenticatableTest < ActiveSupport::TestCase
|
||||
# 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
|
||||
assert_equal user, User.find_or_initialize_with_errors([:email], { email: " EXAMPLE@example.com " })
|
||||
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"
|
||||
assert_equal "example@example.com", User.find_or_initialize_with_errors([:email], { email: " EXAMPLE@example.com " }).email
|
||||
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
|
||||
assert user_with_error.errors.added?(:email, :blank)
|
||||
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
|
||||
assert user_with_error.errors.added?(:email, :invalid)
|
||||
end
|
||||
|
||||
if defined?(ActionController::Parameters)
|
||||
|
||||
@@ -28,7 +28,7 @@ class ConfirmableTest < ActiveSupport::TestCase
|
||||
confirmation_tokens = []
|
||||
3.times do
|
||||
token = create_user.confirmation_token
|
||||
assert !confirmation_tokens.include?(token)
|
||||
assert_not_includes confirmation_tokens, token
|
||||
confirmation_tokens << token
|
||||
end
|
||||
end
|
||||
@@ -41,9 +41,9 @@ class ConfirmableTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
test 'should verify whether a user is confirmed or not' do
|
||||
refute new_user.confirmed?
|
||||
assert_not new_user.confirmed?
|
||||
user = create_user
|
||||
refute user.confirmed?
|
||||
assert_not user.confirmed?
|
||||
user.confirm
|
||||
assert user.confirmed?
|
||||
end
|
||||
@@ -53,7 +53,7 @@ class ConfirmableTest < ActiveSupport::TestCase
|
||||
assert user.confirm
|
||||
assert_blank user.errors[:email]
|
||||
|
||||
refute user.confirm
|
||||
assert_not user.confirm
|
||||
assert_equal "was already confirmed, please try signing in", user.errors[:email].join
|
||||
end
|
||||
|
||||
@@ -61,20 +61,20 @@ class ConfirmableTest < ActiveSupport::TestCase
|
||||
user = create_user
|
||||
raw = user.raw_confirmation_token
|
||||
confirmed_user = User.confirm_by_token(raw)
|
||||
assert_equal confirmed_user, user
|
||||
assert_equal user, confirmed_user
|
||||
assert user.reload.confirmed?
|
||||
end
|
||||
|
||||
test 'should return a new record with errors when a invalid token is given' do
|
||||
confirmed_user = User.confirm_by_token('invalid_confirmation_token')
|
||||
refute confirmed_user.persisted?
|
||||
assert_not confirmed_user.persisted?
|
||||
assert_equal "is invalid", confirmed_user.errors[:confirmation_token].join
|
||||
end
|
||||
|
||||
test 'should return a new record with errors when a blank token is given' do
|
||||
confirmed_user = User.confirm_by_token('')
|
||||
refute confirmed_user.persisted?
|
||||
assert_equal "can't be blank", confirmed_user.errors[:confirmation_token].join
|
||||
assert_not confirmed_user.persisted?
|
||||
assert confirmed_user.errors.added?(:confirmation_token, :blank)
|
||||
end
|
||||
|
||||
test 'should return a new record with errors when a blank token is given and a record exists on the database' do
|
||||
@@ -82,8 +82,8 @@ class ConfirmableTest < ActiveSupport::TestCase
|
||||
|
||||
confirmed_user = User.confirm_by_token('')
|
||||
|
||||
refute user.reload.confirmed?
|
||||
assert_equal "can't be blank", confirmed_user.errors[:confirmation_token].join
|
||||
assert_not user.reload.confirmed?
|
||||
assert confirmed_user.errors.added?(:confirmation_token, :blank)
|
||||
end
|
||||
|
||||
test 'should return a new record with errors when a nil token is given and a record exists on the database' do
|
||||
@@ -91,8 +91,8 @@ class ConfirmableTest < ActiveSupport::TestCase
|
||||
|
||||
confirmed_user = User.confirm_by_token(nil)
|
||||
|
||||
refute user.reload.confirmed?
|
||||
assert_equal "can't be blank", confirmed_user.errors[:confirmation_token].join
|
||||
assert_not user.reload.confirmed?
|
||||
assert confirmed_user.errors.added?(:confirmation_token, :blank)
|
||||
end
|
||||
|
||||
test 'should generate errors for a user email if user is already confirmed' do
|
||||
@@ -145,7 +145,7 @@ class ConfirmableTest < ActiveSupport::TestCase
|
||||
|
||||
assert_email_not_sent do
|
||||
user.save!
|
||||
refute user.confirmed?
|
||||
assert_not user.confirmed?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -160,12 +160,12 @@ class ConfirmableTest < ActiveSupport::TestCase
|
||||
test 'should find a user to send confirmation instructions' do
|
||||
user = create_user
|
||||
confirmation_user = User.send_confirmation_instructions(email: user.email)
|
||||
assert_equal confirmation_user, user
|
||||
assert_equal user, confirmation_user
|
||||
end
|
||||
|
||||
test 'should return a new user if no email was found' do
|
||||
confirmation_user = User.send_confirmation_instructions(email: "invalid@example.com")
|
||||
refute confirmation_user.persisted?
|
||||
assert_not confirmation_user.persisted?
|
||||
end
|
||||
|
||||
test 'should add error to new user email if no email was found' do
|
||||
@@ -212,7 +212,7 @@ class ConfirmableTest < ActiveSupport::TestCase
|
||||
test 'should not be able to send instructions if the user is already confirmed' do
|
||||
user = create_user
|
||||
user.confirm
|
||||
refute user.resend_confirmation_instructions
|
||||
assert_not user.resend_confirmation_instructions
|
||||
assert user.confirmed?
|
||||
assert_equal 'was already confirmed, please try signing in', user.errors[:email].join
|
||||
end
|
||||
@@ -221,7 +221,7 @@ class ConfirmableTest < ActiveSupport::TestCase
|
||||
swap Devise, allow_unconfirmed_access_for: 1.day do
|
||||
user = create_user
|
||||
user.confirmation_sent_at = 2.days.ago
|
||||
refute user.active_for_authentication?
|
||||
assert_not user.active_for_authentication?
|
||||
|
||||
Devise.allow_unconfirmed_access_for = 3.days
|
||||
assert user.active_for_authentication?
|
||||
@@ -237,14 +237,14 @@ class ConfirmableTest < ActiveSupport::TestCase
|
||||
assert user.active_for_authentication?
|
||||
|
||||
user.confirmation_sent_at = 5.days.ago
|
||||
refute user.active_for_authentication?
|
||||
assert_not user.active_for_authentication?
|
||||
end
|
||||
end
|
||||
|
||||
test 'should be active when already confirmed' do
|
||||
user = create_user
|
||||
refute user.confirmed?
|
||||
refute user.active_for_authentication?
|
||||
assert_not user.confirmed?
|
||||
assert_not user.active_for_authentication?
|
||||
|
||||
user.confirm
|
||||
assert user.confirmed?
|
||||
@@ -255,7 +255,7 @@ class ConfirmableTest < ActiveSupport::TestCase
|
||||
Devise.allow_unconfirmed_access_for = 0.days
|
||||
user = create_user
|
||||
user.confirmation_sent_at = Time.zone.today
|
||||
refute user.active_for_authentication?
|
||||
assert_not user.active_for_authentication?
|
||||
end
|
||||
|
||||
test 'should not be active when confirm period is set to 0 days' do
|
||||
@@ -264,7 +264,7 @@ class ConfirmableTest < ActiveSupport::TestCase
|
||||
|
||||
Timecop.freeze(Time.zone.today) do
|
||||
user.confirmation_sent_at = Time.zone.today
|
||||
refute user.active_for_authentication?
|
||||
assert_not user.active_for_authentication?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -280,7 +280,7 @@ class ConfirmableTest < ActiveSupport::TestCase
|
||||
user = create_user
|
||||
user.confirmation_sent_at = nil
|
||||
user.save
|
||||
refute user.reload.active_for_authentication?
|
||||
assert_not user.reload.active_for_authentication?
|
||||
end
|
||||
|
||||
test 'should be active without confirmation when confirmation is not required' do
|
||||
@@ -305,7 +305,7 @@ class ConfirmableTest < ActiveSupport::TestCase
|
||||
swap Devise, authentication_keys: [:username, :email] do
|
||||
user = create_user
|
||||
confirm_user = User.send_confirmation_instructions(email: user.email, username: user.username)
|
||||
assert_equal confirm_user, user
|
||||
assert_equal user, confirm_user
|
||||
end
|
||||
end
|
||||
|
||||
@@ -313,8 +313,8 @@ class ConfirmableTest < ActiveSupport::TestCase
|
||||
swap Devise, confirmation_keys: [:username, :email] do
|
||||
user = create_user
|
||||
confirm_user = User.send_confirmation_instructions(email: user.email)
|
||||
refute confirm_user.persisted?
|
||||
assert_equal "can't be blank", confirm_user.errors[:username].join
|
||||
assert_not confirm_user.persisted?
|
||||
assert confirm_user.errors.added?(:username, :blank)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -322,7 +322,7 @@ class ConfirmableTest < ActiveSupport::TestCase
|
||||
user = create_user
|
||||
user.update_attribute(:confirmation_sent_at, confirmation_sent_at)
|
||||
confirmed_user = User.confirm_by_token(user.raw_confirmation_token)
|
||||
assert_equal confirmed_user, user
|
||||
assert_equal user, confirmed_user
|
||||
user.reload.confirmed?
|
||||
end
|
||||
|
||||
@@ -338,7 +338,7 @@ class ConfirmableTest < ActiveSupport::TestCase
|
||||
|
||||
test 'should not accept confirmation email token after 4 days when expiration is set to 3 days' do
|
||||
swap Devise, confirm_within: 3.days do
|
||||
refute confirm_user_by_token_with_confirmation_sent_at(4.days.ago)
|
||||
assert_not confirm_user_by_token_with_confirmation_sent_at(4.days.ago)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -378,14 +378,14 @@ class ConfirmableTest < ActiveSupport::TestCase
|
||||
self.username = self.username.to_s + 'updated'
|
||||
end
|
||||
old = user.username
|
||||
refute user.confirm
|
||||
assert_not user.confirm
|
||||
assert_equal user.username, old
|
||||
end
|
||||
|
||||
test 'should always perform validations upon confirm when ensure valid true' do
|
||||
admin = create_admin
|
||||
admin.stubs(:valid?).returns(false)
|
||||
refute admin.confirm(ensure_valid: true)
|
||||
assert_not admin.confirm(ensure_valid: true)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -411,7 +411,7 @@ class ReconfirmableTest < ActiveSupport::TestCase
|
||||
admin.skip_reconfirmation!
|
||||
assert admin.update(email: 'new_test@example.com')
|
||||
assert admin.confirmed?
|
||||
refute admin.pending_reconfirmation?
|
||||
assert_not admin.pending_reconfirmation?
|
||||
assert_equal original_token, admin.confirmation_token
|
||||
end
|
||||
|
||||
@@ -497,12 +497,12 @@ class ReconfirmableTest < ActiveSupport::TestCase
|
||||
assert admin.confirm
|
||||
assert admin.update(email: 'new_test@example.com')
|
||||
confirmation_admin = Admin.send_confirmation_instructions(email: admin.unconfirmed_email)
|
||||
assert_equal confirmation_admin, admin
|
||||
assert_equal admin, confirmation_admin
|
||||
end
|
||||
|
||||
test 'should return a new admin if no email or unconfirmed_email was found' do
|
||||
confirmation_admin = Admin.send_confirmation_instructions(email: "invalid@email.com")
|
||||
refute confirmation_admin.persisted?
|
||||
assert_not confirmation_admin.persisted?
|
||||
end
|
||||
|
||||
test 'should add error to new admin email if no email or unconfirmed_email was found' do
|
||||
@@ -520,25 +520,25 @@ class ReconfirmableTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
test 'required_fields should contain the fields that Devise uses' do
|
||||
assert_equal Devise::Models::Confirmable.required_fields(User), [
|
||||
assert_equal [
|
||||
:confirmation_token,
|
||||
:confirmed_at,
|
||||
:confirmation_sent_at
|
||||
]
|
||||
], Devise::Models::Confirmable.required_fields(User)
|
||||
end
|
||||
|
||||
test 'required_fields should also contain unconfirmable when reconfirmable_email is true' do
|
||||
assert_equal Devise::Models::Confirmable.required_fields(Admin), [
|
||||
assert_equal [
|
||||
:confirmation_token,
|
||||
:confirmed_at,
|
||||
:confirmation_sent_at,
|
||||
:unconfirmed_email
|
||||
]
|
||||
], Devise::Models::Confirmable.required_fields(Admin)
|
||||
end
|
||||
|
||||
test 'should not require reconfirmation after creating a record' do
|
||||
admin = create_admin
|
||||
assert !admin.pending_reconfirmation?
|
||||
assert_not admin.pending_reconfirmation?
|
||||
end
|
||||
|
||||
test 'should not require reconfirmation after creating a record with #save called in callback' do
|
||||
@@ -547,12 +547,12 @@ class ReconfirmableTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
admin = Admin::WithSaveInCallback.create(valid_attributes.except(:username))
|
||||
assert !admin.pending_reconfirmation?
|
||||
assert_not admin.pending_reconfirmation?
|
||||
end
|
||||
|
||||
test 'should require reconfirmation after creating a record and updating the email' do
|
||||
admin = create_admin
|
||||
assert !admin.instance_variable_get(:@bypass_confirmation_postpone)
|
||||
assert_not admin.instance_variable_get(:@bypass_confirmation_postpone)
|
||||
admin.email = "new_test@email.com"
|
||||
admin.save
|
||||
assert admin.pending_reconfirmation?
|
||||
|
||||
@@ -97,8 +97,8 @@ class DatabaseAuthenticatableTest < ActiveSupport::TestCase
|
||||
|
||||
test 'should respond to password and password confirmation' do
|
||||
user = new_user
|
||||
assert user.respond_to?(:password)
|
||||
assert user.respond_to?(:password_confirmation)
|
||||
assert_respond_to user, :password
|
||||
assert_respond_to user, :password_confirmation
|
||||
end
|
||||
|
||||
test 'should generate a hashed password while setting password' do
|
||||
@@ -108,7 +108,7 @@ class DatabaseAuthenticatableTest < ActiveSupport::TestCase
|
||||
|
||||
test 'should support custom hashing methods' do
|
||||
user = UserWithCustomHashing.new(password: '654321')
|
||||
assert_equal user.encrypted_password, '123456'
|
||||
assert_equal '123456', user.encrypted_password
|
||||
end
|
||||
|
||||
test 'allow authenticatable_salt to work even with nil hashed password' do
|
||||
@@ -133,7 +133,7 @@ class DatabaseAuthenticatableTest < ActiveSupport::TestCase
|
||||
test 'should test for a valid password' do
|
||||
user = create_user
|
||||
assert user.valid_password?('12345678')
|
||||
refute user.valid_password?('654321')
|
||||
assert_not user.valid_password?('654321')
|
||||
end
|
||||
|
||||
test 'should not raise error with an empty password' do
|
||||
@@ -145,11 +145,11 @@ class DatabaseAuthenticatableTest < ActiveSupport::TestCase
|
||||
test 'should be an invalid password if the user has an empty password' do
|
||||
user = create_user
|
||||
user.encrypted_password = ''
|
||||
refute user.valid_password?('654321')
|
||||
assert_not user.valid_password?('654321')
|
||||
end
|
||||
|
||||
test 'should respond to current password' do
|
||||
assert new_user.respond_to?(:current_password)
|
||||
assert_respond_to new_user, :current_password
|
||||
end
|
||||
|
||||
test 'should update password with valid current password' do
|
||||
@@ -161,7 +161,7 @@ class DatabaseAuthenticatableTest < ActiveSupport::TestCase
|
||||
|
||||
test 'should add an error to current password when it is invalid' do
|
||||
user = create_user
|
||||
refute user.update_with_password(current_password: 'other',
|
||||
assert_not user.update_with_password(current_password: 'other',
|
||||
password: 'pass4321', password_confirmation: 'pass4321')
|
||||
assert user.reload.valid_password?('12345678')
|
||||
assert_match "is invalid", user.errors[:current_password].join
|
||||
@@ -169,19 +169,19 @@ class DatabaseAuthenticatableTest < ActiveSupport::TestCase
|
||||
|
||||
test 'should add an error to current password when it is blank' do
|
||||
user = create_user
|
||||
refute user.update_with_password(password: 'pass4321',
|
||||
assert_not user.update_with_password(password: 'pass4321',
|
||||
password_confirmation: 'pass4321')
|
||||
assert user.reload.valid_password?('12345678')
|
||||
assert_match "can't be blank", user.errors[:current_password].join
|
||||
assert user.errors.added?(:current_password, :blank)
|
||||
end
|
||||
|
||||
test 'should run validations even when current password is invalid or blank' do
|
||||
user = UserWithValidation.create!(valid_attributes)
|
||||
user.save
|
||||
assert user.persisted?
|
||||
refute user.update_with_password(username: "")
|
||||
assert_not user.update_with_password(username: "")
|
||||
assert_match "usertest", user.reload.username
|
||||
assert_match "can't be blank", user.errors[:username].join
|
||||
assert user.errors.added?(:username, :blank)
|
||||
end
|
||||
|
||||
test 'should ignore password and its confirmation if they are blank' do
|
||||
@@ -192,14 +192,14 @@ class DatabaseAuthenticatableTest < ActiveSupport::TestCase
|
||||
|
||||
test 'should not update password with invalid confirmation' do
|
||||
user = create_user
|
||||
refute user.update_with_password(current_password: '12345678',
|
||||
assert_not user.update_with_password(current_password: '12345678',
|
||||
password: 'pass4321', password_confirmation: 'other')
|
||||
assert user.reload.valid_password?('12345678')
|
||||
end
|
||||
|
||||
test 'should clean up password fields on failure' do
|
||||
user = create_user
|
||||
refute user.update_with_password(current_password: '12345678',
|
||||
assert_not user.update_with_password(current_password: '12345678',
|
||||
password: 'pass4321', password_confirmation: 'other')
|
||||
assert user.password.blank?
|
||||
assert user.password_confirmation.blank?
|
||||
@@ -214,28 +214,28 @@ class DatabaseAuthenticatableTest < ActiveSupport::TestCase
|
||||
test 'should not update password without password' do
|
||||
user = create_user
|
||||
user.update_without_password(password: 'pass4321', password_confirmation: 'pass4321')
|
||||
assert !user.reload.valid_password?('pass4321')
|
||||
assert_not user.reload.valid_password?('pass4321')
|
||||
assert user.valid_password?('12345678')
|
||||
end
|
||||
|
||||
test 'should destroy user if current password is valid' do
|
||||
user = create_user
|
||||
assert user.destroy_with_password('12345678')
|
||||
assert !user.persisted?
|
||||
assert_not user.persisted?
|
||||
end
|
||||
|
||||
test 'should not destroy user with invalid password' do
|
||||
user = create_user
|
||||
refute user.destroy_with_password('other')
|
||||
assert_not user.destroy_with_password('other')
|
||||
assert user.persisted?
|
||||
assert_match "is invalid", user.errors[:current_password].join
|
||||
end
|
||||
|
||||
test 'should not destroy user with blank password' do
|
||||
user = create_user
|
||||
refute user.destroy_with_password(nil)
|
||||
assert_not user.destroy_with_password(nil)
|
||||
assert user.persisted?
|
||||
assert_match "can't be blank", user.errors[:current_password].join
|
||||
assert user.errors.added?(:current_password, :blank)
|
||||
end
|
||||
|
||||
test 'should not email on password change' do
|
||||
@@ -289,22 +289,22 @@ class DatabaseAuthenticatableTest < ActiveSupport::TestCase
|
||||
test 'downcase_keys with validation' do
|
||||
User.create(email: "HEllO@example.com", password: "123456")
|
||||
user = User.create(email: "HEllO@example.com", password: "123456")
|
||||
assert !user.valid?
|
||||
assert_not user.valid?
|
||||
end
|
||||
|
||||
test 'required_fields should be encryptable_password and the email field by default' do
|
||||
assert_equal Devise::Models::DatabaseAuthenticatable.required_fields(User), [
|
||||
assert_equal [
|
||||
:encrypted_password,
|
||||
:email
|
||||
]
|
||||
], Devise::Models::DatabaseAuthenticatable.required_fields(User)
|
||||
end
|
||||
|
||||
test 'required_fields should be encryptable_password and the login when the login is on authentication_keys' do
|
||||
swap Devise, authentication_keys: [:login] do
|
||||
assert_equal Devise::Models::DatabaseAuthenticatable.required_fields(User), [
|
||||
assert_equal [
|
||||
:encrypted_password,
|
||||
:login
|
||||
]
|
||||
], Devise::Models::DatabaseAuthenticatable.required_fields(User)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -34,7 +34,7 @@ class LockableTest < ActiveSupport::TestCase
|
||||
user.confirm
|
||||
swap Devise, lock_strategy: :none, maximum_attempts: 2 do
|
||||
3.times { user.valid_for_authentication?{ false } }
|
||||
assert !user.access_locked?
|
||||
assert_not user.access_locked?
|
||||
assert_equal 0, user.failed_attempts
|
||||
end
|
||||
end
|
||||
@@ -50,6 +50,32 @@ class LockableTest < ActiveSupport::TestCase
|
||||
assert_equal initial_failed_attempts + 2, user.reload.failed_attempts
|
||||
end
|
||||
|
||||
test "reset_failed_attempts! updates the failed attempts counter back to 0" do
|
||||
user = create_user(failed_attempts: 3)
|
||||
assert_equal 3, user.failed_attempts
|
||||
|
||||
user.reset_failed_attempts!
|
||||
assert_equal 0, user.failed_attempts
|
||||
|
||||
user.reset_failed_attempts!
|
||||
assert_equal 0, user.failed_attempts
|
||||
end
|
||||
|
||||
test "reset_failed_attempts! does not run model validations" do
|
||||
user = create_user(failed_attempts: 1)
|
||||
user.expects(:after_validation_callback).never
|
||||
|
||||
assert user.reset_failed_attempts!
|
||||
assert_equal 0, user.failed_attempts
|
||||
end
|
||||
|
||||
test "reset_failed_attempts! does not try to reset if not using failed attempts strategy" do
|
||||
admin = create_admin
|
||||
|
||||
assert_not_respond_to admin, :failed_attempts
|
||||
assert_not admin.reset_failed_attempts!
|
||||
end
|
||||
|
||||
test 'should be valid for authentication with a unlocked user' do
|
||||
user = create_user
|
||||
user.lock_access!
|
||||
@@ -59,7 +85,7 @@ class LockableTest < ActiveSupport::TestCase
|
||||
|
||||
test "should verify whether a user is locked or not" do
|
||||
user = create_user
|
||||
refute user.access_locked?
|
||||
assert_not user.access_locked?
|
||||
user.lock_access!
|
||||
assert user.access_locked?
|
||||
end
|
||||
@@ -69,7 +95,7 @@ class LockableTest < ActiveSupport::TestCase
|
||||
user.confirm
|
||||
assert user.active_for_authentication?
|
||||
user.lock_access!
|
||||
refute user.active_for_authentication?
|
||||
assert_not user.active_for_authentication?
|
||||
end
|
||||
|
||||
test "should unlock a user by cleaning locked_at, failed_attempts and unlock_token" do
|
||||
@@ -85,7 +111,7 @@ class LockableTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
test "new user should not be locked and should have zero failed_attempts" do
|
||||
refute new_user.access_locked?
|
||||
assert_not new_user.access_locked?
|
||||
assert_equal 0, create_user.failed_attempts
|
||||
end
|
||||
|
||||
@@ -96,7 +122,7 @@ class LockableTest < ActiveSupport::TestCase
|
||||
assert user.access_locked?
|
||||
|
||||
Devise.unlock_in = 1.hour
|
||||
refute user.access_locked?
|
||||
assert_not user.access_locked?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -121,7 +147,7 @@ class LockableTest < ActiveSupport::TestCase
|
||||
user = create_user
|
||||
user.lock_access!
|
||||
token = user.unlock_token
|
||||
assert !unlock_tokens.include?(token)
|
||||
assert_not_includes unlock_tokens, token
|
||||
unlock_tokens << token
|
||||
end
|
||||
end
|
||||
@@ -174,32 +200,32 @@ class LockableTest < ActiveSupport::TestCase
|
||||
user = create_user
|
||||
raw = user.send_unlock_instructions
|
||||
locked_user = User.unlock_access_by_token(raw)
|
||||
assert_equal locked_user, user
|
||||
refute user.reload.access_locked?
|
||||
assert_equal user, locked_user
|
||||
assert_not user.reload.access_locked?
|
||||
end
|
||||
|
||||
test 'should return a new record with errors when a invalid token is given' do
|
||||
locked_user = User.unlock_access_by_token('invalid_token')
|
||||
refute locked_user.persisted?
|
||||
assert_not locked_user.persisted?
|
||||
assert_equal "is invalid", locked_user.errors[:unlock_token].join
|
||||
end
|
||||
|
||||
test 'should return a new record with errors when a blank token is given' do
|
||||
locked_user = User.unlock_access_by_token('')
|
||||
refute locked_user.persisted?
|
||||
assert_equal "can't be blank", locked_user.errors[:unlock_token].join
|
||||
assert_not locked_user.persisted?
|
||||
assert locked_user.errors.added?(:unlock_token, :blank)
|
||||
end
|
||||
|
||||
test 'should find a user to send unlock instructions' do
|
||||
user = create_user
|
||||
user.lock_access!
|
||||
unlock_user = User.send_unlock_instructions(email: user.email)
|
||||
assert_equal unlock_user, user
|
||||
assert_equal user, unlock_user
|
||||
end
|
||||
|
||||
test 'should return a new user if no email was found' do
|
||||
unlock_user = User.send_unlock_instructions(email: "invalid@example.com")
|
||||
refute unlock_user.persisted?
|
||||
assert_not unlock_user.persisted?
|
||||
end
|
||||
|
||||
test 'should add error to new user email if no email was found' do
|
||||
@@ -211,7 +237,7 @@ class LockableTest < ActiveSupport::TestCase
|
||||
swap Devise, authentication_keys: [:username, :email] do
|
||||
user = create_user
|
||||
unlock_user = User.send_unlock_instructions(email: user.email, username: user.username)
|
||||
assert_equal unlock_user, user
|
||||
assert_equal user, unlock_user
|
||||
end
|
||||
end
|
||||
|
||||
@@ -219,23 +245,23 @@ class LockableTest < ActiveSupport::TestCase
|
||||
swap Devise, unlock_keys: [:username, :email] do
|
||||
user = create_user
|
||||
unlock_user = User.send_unlock_instructions(email: user.email)
|
||||
refute unlock_user.persisted?
|
||||
assert_equal "can't be blank", unlock_user.errors[:username].join
|
||||
assert_not unlock_user.persisted?
|
||||
assert unlock_user.errors.added?(:username, :blank)
|
||||
end
|
||||
end
|
||||
|
||||
test 'should not be able to send instructions if the user is not locked' do
|
||||
user = create_user
|
||||
refute user.resend_unlock_instructions
|
||||
refute user.access_locked?
|
||||
assert_not user.resend_unlock_instructions
|
||||
assert_not user.access_locked?
|
||||
assert_equal 'was not locked', user.errors[:email].join
|
||||
end
|
||||
|
||||
test 'should not be able to send instructions if the user if not locked and have username as unlock key' do
|
||||
swap Devise, unlock_keys: [:username] do
|
||||
user = create_user
|
||||
refute user.resend_unlock_instructions
|
||||
refute user.access_locked?
|
||||
assert_not user.resend_unlock_instructions
|
||||
assert_not user.access_locked?
|
||||
assert_equal 'was not locked', user.errors[:username].join
|
||||
end
|
||||
end
|
||||
@@ -270,11 +296,11 @@ class LockableTest < ActiveSupport::TestCase
|
||||
test 'required_fields should contain the all the fields when all the strategies are enabled' do
|
||||
swap Devise, unlock_strategy: :both do
|
||||
swap Devise, lock_strategy: :failed_attempts do
|
||||
assert_equal Devise::Models::Lockable.required_fields(User), [
|
||||
:failed_attempts,
|
||||
:locked_at,
|
||||
:unlock_token
|
||||
]
|
||||
assert_equal [
|
||||
:failed_attempts,
|
||||
:locked_at,
|
||||
:unlock_token
|
||||
], Devise::Models::Lockable.required_fields(User)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -282,10 +308,10 @@ class LockableTest < ActiveSupport::TestCase
|
||||
test 'required_fields should contain only failed_attempts and locked_at when the strategies are time and failed_attempts are enabled' do
|
||||
swap Devise, unlock_strategy: :time do
|
||||
swap Devise, lock_strategy: :failed_attempts do
|
||||
assert_equal Devise::Models::Lockable.required_fields(User), [
|
||||
:failed_attempts,
|
||||
:locked_at
|
||||
]
|
||||
assert_equal [
|
||||
:failed_attempts,
|
||||
:locked_at
|
||||
], Devise::Models::Lockable.required_fields(User)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -293,10 +319,10 @@ class LockableTest < ActiveSupport::TestCase
|
||||
test 'required_fields should contain only failed_attempts and unlock_token when the strategies are token and failed_attempts are enabled' do
|
||||
swap Devise, unlock_strategy: :email do
|
||||
swap Devise, lock_strategy: :failed_attempts do
|
||||
assert_equal Devise::Models::Lockable.required_fields(User), [
|
||||
:failed_attempts,
|
||||
:unlock_token
|
||||
]
|
||||
assert_equal [
|
||||
:failed_attempts,
|
||||
:unlock_token
|
||||
], Devise::Models::Lockable.required_fields(User)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,6 +4,6 @@ require 'test_helper'
|
||||
|
||||
class OmniauthableTest < ActiveSupport::TestCase
|
||||
test 'required_fields should contain the fields that Devise uses' do
|
||||
assert_equal Devise::Models::Omniauthable.required_fields(User), []
|
||||
assert_equal [], Devise::Models::Omniauthable.required_fields(User)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -18,7 +18,7 @@ class RecoverableTest < ActiveSupport::TestCase
|
||||
user = create_user
|
||||
user.send_reset_password_instructions
|
||||
token = user.reset_password_token
|
||||
assert !reset_password_tokens.include?(token)
|
||||
assert_not_includes reset_password_tokens, token
|
||||
reset_password_tokens << token
|
||||
end
|
||||
end
|
||||
@@ -94,14 +94,14 @@ class RecoverableTest < ActiveSupport::TestCase
|
||||
user = create_user
|
||||
user.send_reset_password_instructions
|
||||
assert_present user.reset_password_token
|
||||
refute user.reset_password('123456789', '987654321')
|
||||
assert_not user.reset_password('123456789', '987654321')
|
||||
assert_present user.reset_password_token
|
||||
end
|
||||
|
||||
test 'should not reset password with invalid data' do
|
||||
user = create_user
|
||||
user.stubs(:valid?).returns(false)
|
||||
refute user.reset_password('123456789', '987654321')
|
||||
assert_not user.reset_password('123456789', '987654321')
|
||||
end
|
||||
|
||||
test 'should reset reset password token and send instructions by email' do
|
||||
@@ -116,12 +116,12 @@ class RecoverableTest < ActiveSupport::TestCase
|
||||
test 'should find a user to send instructions by email' do
|
||||
user = create_user
|
||||
reset_password_user = User.send_reset_password_instructions(email: user.email)
|
||||
assert_equal reset_password_user, user
|
||||
assert_equal user, reset_password_user
|
||||
end
|
||||
|
||||
test 'should return a new record with errors if user was not found by e-mail' do
|
||||
reset_password_user = User.send_reset_password_instructions(email: "invalid@example.com")
|
||||
refute reset_password_user.persisted?
|
||||
assert_not reset_password_user.persisted?
|
||||
assert_equal "not found", reset_password_user.errors[:email].join
|
||||
end
|
||||
|
||||
@@ -129,17 +129,17 @@ class RecoverableTest < ActiveSupport::TestCase
|
||||
swap Devise, authentication_keys: [:username, :email] do
|
||||
user = create_user
|
||||
reset_password_user = User.send_reset_password_instructions(email: user.email, username: user.username)
|
||||
assert_equal reset_password_user, user
|
||||
assert_equal user, reset_password_user
|
||||
end
|
||||
end
|
||||
|
||||
test 'should require all reset_password_keys' do
|
||||
swap Devise, reset_password_keys: [:username, :email] do
|
||||
user = create_user
|
||||
reset_password_user = User.send_reset_password_instructions(email: user.email)
|
||||
refute reset_password_user.persisted?
|
||||
assert_equal "can't be blank", reset_password_user.errors[:username].join
|
||||
end
|
||||
swap Devise, reset_password_keys: [:username, :email] do
|
||||
user = create_user
|
||||
reset_password_user = User.send_reset_password_instructions(email: user.email)
|
||||
assert_not reset_password_user.persisted?
|
||||
assert reset_password_user.errors.added?(:username, :blank)
|
||||
end
|
||||
end
|
||||
|
||||
test 'should reset reset_password_token before send the reset instructions email' do
|
||||
@@ -161,19 +161,19 @@ class RecoverableTest < ActiveSupport::TestCase
|
||||
raw = user.send_reset_password_instructions
|
||||
|
||||
reset_password_user = User.reset_password_by_token(reset_password_token: raw)
|
||||
assert_equal reset_password_user, user
|
||||
assert_equal user, reset_password_user
|
||||
end
|
||||
|
||||
test 'should return a new record with errors if no reset_password_token is found' do
|
||||
reset_password_user = User.reset_password_by_token(reset_password_token: 'invalid_token')
|
||||
refute reset_password_user.persisted?
|
||||
assert_not reset_password_user.persisted?
|
||||
assert_equal "is invalid", reset_password_user.errors[:reset_password_token].join
|
||||
end
|
||||
|
||||
test 'should return a new record with errors if reset_password_token is blank' do
|
||||
reset_password_user = User.reset_password_by_token(reset_password_token: '')
|
||||
refute reset_password_user.persisted?
|
||||
assert_match "can't be blank", reset_password_user.errors[:reset_password_token].join
|
||||
assert_not reset_password_user.persisted?
|
||||
assert reset_password_user.errors.added?(:reset_password_token, :blank)
|
||||
end
|
||||
|
||||
test 'should return a new record with errors if password is blank' do
|
||||
@@ -181,8 +181,8 @@ class RecoverableTest < ActiveSupport::TestCase
|
||||
raw = user.send_reset_password_instructions
|
||||
|
||||
reset_password_user = User.reset_password_by_token(reset_password_token: raw, password: '')
|
||||
refute reset_password_user.errors.empty?
|
||||
assert_match "can't be blank", reset_password_user.errors[:password].join
|
||||
assert_not reset_password_user.errors.empty?
|
||||
assert reset_password_user.errors.added?(:password, :blank)
|
||||
assert_equal raw, reset_password_user.reset_password_token
|
||||
end
|
||||
|
||||
@@ -191,8 +191,8 @@ class RecoverableTest < ActiveSupport::TestCase
|
||||
raw = user.send_reset_password_instructions
|
||||
|
||||
reset_password_user = User.reset_password_by_token(reset_password_token: raw)
|
||||
refute reset_password_user.errors.empty?
|
||||
assert_match "can't be blank", reset_password_user.errors[:password].join
|
||||
assert_not reset_password_user.errors.empty?
|
||||
assert reset_password_user.errors.added?(:password, :blank)
|
||||
assert_equal raw, reset_password_user.reset_password_token
|
||||
end
|
||||
|
||||
@@ -209,7 +209,7 @@ class RecoverableTest < ActiveSupport::TestCase
|
||||
assert_nil reset_password_user.reset_password_token
|
||||
|
||||
user.reload
|
||||
refute user.valid_password?(old_password)
|
||||
assert_not user.valid_password?(old_password)
|
||||
assert user.valid_password?('new_password')
|
||||
assert_nil user.reset_password_token
|
||||
end
|
||||
@@ -231,29 +231,29 @@ class RecoverableTest < ActiveSupport::TestCase
|
||||
user.reload
|
||||
|
||||
assert user.valid_password?(old_password)
|
||||
refute user.valid_password?('new_password')
|
||||
assert_not user.valid_password?('new_password')
|
||||
assert_equal "has expired, please request a new one", reset_password_user.errors[:reset_password_token].join
|
||||
end
|
||||
end
|
||||
|
||||
test 'required_fields should contain the fields that Devise uses' do
|
||||
assert_equal Devise::Models::Recoverable.required_fields(User), [
|
||||
assert_equal [
|
||||
:reset_password_sent_at,
|
||||
:reset_password_token
|
||||
]
|
||||
], Devise::Models::Recoverable.required_fields(User)
|
||||
end
|
||||
|
||||
test 'should return a user based on the raw token' do
|
||||
user = create_user
|
||||
raw = user.send_reset_password_instructions
|
||||
|
||||
assert_equal User.with_reset_password_token(raw), user
|
||||
assert_equal user, User.with_reset_password_token(raw)
|
||||
end
|
||||
|
||||
test 'should return the same reset password token as generated' do
|
||||
user = create_user
|
||||
raw = user.send_reset_password_instructions
|
||||
assert_equal Devise.token_generator.digest(self.class, :reset_password_token, raw), user.reset_password_token
|
||||
assert_equal user.reset_password_token, Devise.token_generator.digest(self.class, :reset_password_token, raw)
|
||||
end
|
||||
|
||||
test 'should return nil if a user based on the raw token is not found' do
|
||||
|
||||
@@ -4,6 +4,6 @@ require 'test_helper'
|
||||
|
||||
class RegisterableTest < ActiveSupport::TestCase
|
||||
test 'required_fields should contain the fields that Devise uses' do
|
||||
assert_equal Devise::Models::Registerable.required_fields(User), []
|
||||
assert_equal [], Devise::Models::Registerable.required_fields(User)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -129,8 +129,8 @@ class RememberableTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
test 'should respond to remember_me attribute' do
|
||||
assert resource_class.new.respond_to?(:remember_me)
|
||||
assert resource_class.new.respond_to?(:remember_me=)
|
||||
assert_respond_to resource_class.new, :remember_me
|
||||
assert_respond_to resource_class.new, :remember_me=
|
||||
end
|
||||
|
||||
test 'forget_me should clear remember_created_at if expire_all_remember_me_on_sign_out is true' do
|
||||
@@ -177,8 +177,8 @@ class RememberableTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
test 'should have the required_fields array' do
|
||||
assert_equal Devise::Models::Rememberable.required_fields(User), [
|
||||
assert_equal [
|
||||
:remember_created_at
|
||||
]
|
||||
], Devise::Models::Rememberable.required_fields(User)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -7,21 +7,6 @@ class SerializableTest < ActiveSupport::TestCase
|
||||
@user = create_user
|
||||
end
|
||||
|
||||
test 'should not include unsafe keys on XML' do
|
||||
assert_match(/email/, @user.to_xml)
|
||||
assert_no_match(/confirmation-token/, @user.to_xml)
|
||||
end
|
||||
|
||||
test 'should not include unsafe keys on XML even if a new except is provided' do
|
||||
assert_no_match(/email/, @user.to_xml(except: :email))
|
||||
assert_no_match(/confirmation-token/, @user.to_xml(except: :email))
|
||||
end
|
||||
|
||||
test 'should include unsafe keys on XML if a force_except is provided' do
|
||||
assert_no_match(/<email/, @user.to_xml(force_except: :email))
|
||||
assert_match(/confirmation-token/, @user.to_xml(force_except: :email))
|
||||
end
|
||||
|
||||
test 'should not include unsafe keys on JSON' do
|
||||
keys = from_json().keys.select{ |key| !key.include?("id") }
|
||||
assert_equal %w(created_at email facebook_token updated_at username), keys.sort
|
||||
@@ -43,7 +28,11 @@ class SerializableTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
test 'should accept frozen options' do
|
||||
assert_key "username", @user.as_json({only: :username}.freeze)["user"]
|
||||
assert_key "username", @user.as_json({ only: :username, except: [:email].freeze }.freeze)["user"]
|
||||
end
|
||||
|
||||
test 'constant `BLACKLIST_FOR_SERIALIZATION` is deprecated' do
|
||||
assert_deprecated { Devise::Models::Authenticatable::BLACKLIST_FOR_SERIALIZATION }
|
||||
end
|
||||
|
||||
def assert_key(key, subject)
|
||||
@@ -51,10 +40,10 @@ class SerializableTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
def assert_no_key(key, subject)
|
||||
assert !subject.key?(key), "Expected #{subject.inspect} to not have key #{key.inspect}"
|
||||
assert_not subject.key?(key), "Expected #{subject.inspect} to not have key #{key.inspect}"
|
||||
end
|
||||
|
||||
def from_json(options=nil)
|
||||
def from_json(options = nil)
|
||||
ActiveSupport::JSON.decode(@user.to_json(options))["user"]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -9,11 +9,11 @@ class TimeoutableTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
test 'should not be expired' do
|
||||
refute new_user.timedout?(29.minutes.ago)
|
||||
assert_not new_user.timedout?(29.minutes.ago)
|
||||
end
|
||||
|
||||
test 'should not be expired when params is nil' do
|
||||
refute new_user.timedout?(nil)
|
||||
assert_not new_user.timedout?(nil)
|
||||
end
|
||||
|
||||
test 'should use timeout_in method' do
|
||||
@@ -21,29 +21,29 @@ class TimeoutableTest < ActiveSupport::TestCase
|
||||
user.instance_eval { def timeout_in; 10.minutes end }
|
||||
|
||||
assert user.timedout?(12.minutes.ago)
|
||||
refute user.timedout?(8.minutes.ago)
|
||||
assert_not user.timedout?(8.minutes.ago)
|
||||
end
|
||||
|
||||
test 'should not be expired when timeout_in method returns nil' do
|
||||
user = new_user
|
||||
user.instance_eval { def timeout_in; nil end }
|
||||
refute user.timedout?(10.hours.ago)
|
||||
assert_not user.timedout?(10.hours.ago)
|
||||
end
|
||||
|
||||
test 'fallback to Devise config option' do
|
||||
swap Devise, timeout_in: 1.minute do
|
||||
user = new_user
|
||||
assert user.timedout?(2.minutes.ago)
|
||||
refute user.timedout?(30.seconds.ago)
|
||||
assert_not user.timedout?(30.seconds.ago)
|
||||
|
||||
Devise.timeout_in = 5.minutes
|
||||
refute user.timedout?(2.minutes.ago)
|
||||
assert_not user.timedout?(2.minutes.ago)
|
||||
assert user.timedout?(6.minutes.ago)
|
||||
end
|
||||
end
|
||||
|
||||
test 'required_fields should contain the fields that Devise uses' do
|
||||
assert_equal Devise::Models::Timeoutable.required_fields(User), []
|
||||
assert_equal [], Devise::Models::Timeoutable.required_fields(User)
|
||||
end
|
||||
|
||||
test 'should not raise error if remember_created_at is not empty and rememberable is disabled' do
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user