Compare commits

...

254 Commits

Author SHA1 Message Date
Carlos Antonio da Silva
f6e8d90b98 Release 4.7.3 2020-09-20 21:06:51 -03:00
Carlos Antonio da Silva
f6a6d4c34b Revert "Replace BLACKLIST_FOR_SERIALIZATION with DENYLIST_FOR_SERIALIZATION"
This reverts commit 2da46d8dd6.
2020-09-20 21:00:05 -03:00
Carlos Antonio da Silva
8f949ed391 Revert "Deprecate BLACKLIST_FOR_SERIALIZATION on all supported Rails versions"
This reverts commit 0c2cab7c94.
2020-09-20 21:00:03 -03:00
Carlos Antonio da Silva
f12be553cc Update changelog [ci skip] 2020-09-20 10:45:10 -03:00
Carlos Antonio da Silva
4896a9b41a Update bundle 2020-09-20 10:43:42 -03:00
mune
eed641d2be Add spaces around method arguments when setting default values
Closes #5288
2020-08-31 18:15:45 -03:00
Carlos Antonio da Silva
97aa37bb50 Use assert_empty minitest helper 2020-08-27 18:40:03 -03:00
Carlos Antonio da Silva
15135f7dc6 User assert_includes/refute_includes minitest helpers 2020-08-27 18:38:26 -03:00
Carlos Antonio da Silva
e39b9b9134 Fix order of arguments for assert_equal on tests
Use `assert_equal expected, actual` for proper error messages in case of
failures.
2020-08-27 18:24:17 -03:00
Carlos Antonio da Silva
4a5e7a9143 Switch to https for git repos in the lock file 2020-08-27 08:54:18 -03:00
Carlos Antonio da Silva
8664bac682 Merge pull request #5286 from clockspring/fix-5285
Fix hanging tests for streaming controllers using Devise
2020-08-27 08:52:17 -03:00
Tony Novak
3e588d2d25 Work around "uncaught throw :warden" issue in Rails 4 2020-08-26 12:02:11 -04:00
Tony Novak
23fbc35b2d Fix hanging tests for streaming controllers using Devise
Fixes #5285.
2020-08-26 12:02:09 -04:00
Carlos Antonio da Silva
2c844b0649 Merge branch 'ca-deprecate-blacklist-constant' into master
Closes #5280
2020-08-20 09:07:43 -03:00
Carlos Antonio da Silva
0c2cab7c94 Deprecate BLACKLIST_FOR_SERIALIZATION on all supported Rails versions
Deprecate `BLACKLIST_FOR_SERIALIZATION` constant in favor of a more
descriptive name `UNSAFE_ATTRIBUTES_FOR_SERIALIZATION`, removing
unnecessary usage of the word `blacklist` from devise.

The previous constant still works but will emit a warning if used, to
allow anyone still depending on it to upgrade.

This includes an internal backport of the Rails `deprecate_constant`
implementation that exists on Rails 5.1+ to be able to deprecate it
properly in prior versions, while we support those. (which I intend to
drop soon.)
2020-08-19 19:36:25 -03:00
Seiei Miyagi
2da46d8dd6 Replace BLACKLIST_FOR_SERIALIZATION with DENYLIST_FOR_SERIALIZATION 2020-08-17 22:17:06 +09:00
Daniel Pepper
507573994a Ensure serializable_hash doesn't raise with a frozen :except array
I ran into an issue where options[:except] is a frozen array, which
explodes when we try to concat values in `serializable_hash`. To fix this
we dup the `:except` option before concatenating with the other options
there.

Closes #5278.
2020-08-13 18:38:23 -03:00
Carlos Antonio da Silva
f26e05c200 Update bundle 2020-08-10 22:47:15 -03:00
Carlos Antonio da Silva
f5cc775a5f Remove commented out code 2020-06-23 08:50:20 -03:00
Carlos Antonio da Silva
b94b957490 Prefer american style english for code
Nothing personal, just seems to be much more common usage across the
code.
2020-06-23 08:50:20 -03:00
Carlos Antonio da Silva
057afdc1e6 Fix another thor deprecation warning in the install generator
This one has been showing up when running tests:

    Deprecation warning: Expected string default value for '--orm'; got false (boolean).
    This will be rejected in the future unless you explicitly pass the options
    `check_default_type: false` or call `allow_incompatible_default_type!` in your code
    You can silence deprecations warning by setting the environment variable THOR_SILENCE_DEPRECATION.
2020-06-18 18:02:43 -03:00
Carlos Antonio da Silva
c249ba991b Merge pull request #5258 from deivid-rodriguez/fix_thor_warning
The `:orm` option can also have string values. Fixes #5252.
2020-06-18 18:00:11 -03:00
David Rodríguez
ffa8a80f42 Fix warning from thor
The `:orm` option can also have string values.
2020-06-18 16:21:58 +02:00
Carlos Antonio da Silva
4f60544396 Improve deprecation message with example of how to remove it
The deprecation of `devise_error_messages!` wasn't super clear on what
was happening and how to get rid of the message, not it has a more
detailed explanation with an example of what to look for and what to
replace it with.

Closes #5257.
2020-06-17 08:52:43 -03:00
Rafael França
79d7eddfc3 Merge pull request #5256 from ptcodes/remove_heroku_anchor_link
Remove Heroku anchor link and fix some typos
2020-06-15 23:38:36 -04:00
Pavel Timofeev
b25492ea01 Remove Heroku anchor link and fix some typos 2020-06-15 23:19:31 -04:00
Руслан Корнев
0e33f55b7d Fixes broken image (#5253) [ci skip] 2020-06-12 21:37:02 -03:00
Carlos Antonio da Silva
6991ff4eb4 Oops, fix changelog [ci skip] 2020-06-10 15:28:31 -03:00
Carlos Antonio da Silva
16f27b3074 Bump to v4.7.2 2020-06-10 15:23:45 -03:00
Carlos Antonio da Silva
87108ad4d5 Merge pull request #5250 from hyuraku/remove_useless_rails51
remove unused rails51? method
2020-06-09 10:18:55 -03:00
hyuraku
6d37e32437 remove useless rails51? method 2020-06-09 21:50:30 +09:00
Carlos Antonio da Silva
a3c0c65269 Devise no longer supports Rails 3.2 since version 4 [ci skip]
And this `initialize_on_precompile` option is obsolete.
2020-06-08 18:44:21 -03:00
Carlos Antonio da Silva
2c1b5fb240 Update changelog with latest [ci skip] 2020-06-08 18:40:50 -03:00
Carlos Antonio da Silva
50f820a6cf Use master of Rails controller testing gem to remove Ruby 2.7 warning 2020-06-07 20:00:17 -03:00
Carlos Antonio da Silva
34d9053819 Remove unnecessary monkey-patch of test helpers with Rails 5+
This is warning on Ruby 2.7, and seems unnecessary since Rails 5+
adopted kwargs approach. We still need to handle the difference for
Rails < 5 for now, while we support it (which I would like to remove
soon.)
2020-06-07 20:00:17 -03:00
Carlos Antonio da Silva
94be5fb6a1 Remove mocha deprecation warning
Mocha deprecation warning at
    ...../active_support/dependencies.rb:324:in `require':
    Require 'mocha/test_unit', 'mocha/minitest' or 'mocha/api'
    instead of 'mocha/setup'.
2020-06-07 19:49:51 -03:00
Carlos Antonio da Silva
14a3084b59 Simplify the view generator with scoped views 2020-06-07 19:16:36 -03:00
Carlos Antonio da Silva
bbbff3a350 Add changelog entry for #5067 [ci skip] 2020-06-07 19:16:36 -03:00
Carlos Antonio da Silva
a451b98cf2 Revert "Updated README with additional video resources for learning Devise (#5232)"
This reverts commit d85d45bcef.

My mistake: this section is about *not* using Devise when starting with
Rails and building authentication for the first time, therefore we
should not be linking to Devise specific resources here.

[ci skip]
2020-06-05 17:49:32 -03:00
Carlos Antonio da Silva
c3759be33e Link to both Ryan Bates Railscasts [ci skip] 2020-06-05 17:47:05 -03:00
David Kimura
d85d45bcef Updated README with additional video resources for learning Devise (#5232)
[ci skip]
2020-06-05 17:44:37 -03:00
David Auza
cb8c72171f Update README.md with current link to Railscast (#5221)
Updated README.md with the latest link to Ryan Bates' Railscast
2020-06-05 17:43:56 -03:00
Vitalii Lazebnyi
e0b9915418 #5234 fix. Deprecated warning at controller_helpers.rb 2020-06-05 11:41:19 -03:00
Carlos Antonio da Silva
26c7dffe2a Remove test_after_commit from Rails 5+ Gemfiles
It is not required anymore since Rails does the right thing since Rails
5.0.
2020-06-05 11:41:19 -03:00
Carlos Antonio da Silva
22e2ab4be3 Update Gemfile to point to Rails 6.0.x
This is essentially the same as `gemfiles/Gemfile.rails-6.0-stable`, but
I'm keeping both for now since I want to change the main `Gemfile` later
to point to Rails master (`6.1.0.alpha`), so then I won't need to
recreate the `6.0-stable` Gemfile again.
2020-06-05 11:40:57 -03:00
Carlos Antonio da Silva
a3d9161712 Bundle update everything 2020-06-05 11:13:22 -03:00
Carlos Antonio da Silva
2e3b70ca62 Update Ruby versions to test against 2020-06-05 11:13:22 -03:00
Carlos Antonio da Silva
1a83b58d72 Remove Rails 6 from allow failures
Rails 6 is officially supported, so tests must pass with it.
2020-06-05 11:13:22 -03:00
Carlos Antonio da Silva
e3f4beced4 Add Rails 5.1 to the matrix
Not sure how/when this one was removed, probably just mistakenly, so
let's add it back for now, at least while we support multiple old Ruby /
Rails versions. (which I plan to remove support in the near future.)
2020-06-05 11:13:21 -03:00
Carlos Antonio da Silva
9437f2de57 Test with Ruby 2.7 2020-06-05 10:25:08 -03:00
Carlos Antonio da Silva
70f3ae24e0 Merge pull request #5229 from okuramasafumi/patch-1
Correct warden URL in README [ci skip]
2020-05-01 08:20:35 -03:00
OKURA Masafumi
64ea43f6ab Correct warden URL in README [ci skip]
Warden moved to its own organization so we should follow it.
2020-05-01 16:48:17 +09:00
Carlos Antonio da Silva
a59fd76da4 Merge pull request #5225 from chiastolite/remove_unused_method
Remove unused method from Devise::Generators::InstallGenerator
2020-04-26 14:37:20 -03:00
Hiroyuki Morita
1f30f6fa85 Remove unused method from Devise::Generators::InstallGenerator
`rails_4?` is not called anymore since 2024fca4df.
2020-04-23 08:19:21 +09:00
Rafael França
6486351350 Merge pull request #5215 from HLFH/master
Fix Deprecation warning: Expected string default value for '--orm'
2020-04-16 14:41:55 -04:00
HLFH
d65bb156c1 type: :boolean for :orm 2020-03-28 09:13:35 +00:00
Gaspard d'Hautefeuille
6851f1d1c4 Deprecation warning: Expected string default value for '--orm' 2020-03-26 17:13:51 +00:00
Rafael França
769506e96c Merge pull request #5204 from unleashy/patch-1
Clarify DatabaseAuthenticable's behaviour for password fields
2020-03-12 14:54:45 -04:00
unleashy
eefae83c92 Make a more accurate claim 2020-03-12 15:52:51 -03:00
Rafael França
ec0b55a13a Merge pull request #5208 from p8/document-changes-stretches
Explain how changing stretches affects existing password hashes
2020-03-12 11:33:25 -04:00
Petrik
63fe1a843f Explain how changing stretches affects existing password hashes 2020-03-12 16:16:55 +01:00
unleashy
748803cd59 Clarify DatabaseAuthenticable's behaviour
with regards to the `password` field
2020-03-05 14:47:43 -03:00
Carlos Antonio da Silva
97a6fd2895 Merge pull request #5193 from pickerflicker/skip-timeout-optimization
Avoid checking if the record timed out when skipping timeoutable
2020-03-01 18:04:19 -03:00
Steven Hsieh
12a265d1eb optimize earlier timeout_skip to avoid unecessary record lookup 2020-02-19 10:51:36 -08:00
Rafael França
29943a26e6 Merge pull request #5192 from fwolfst/update_readme_rails6
update README to reflect current Rails version
2020-02-06 12:53:06 -05:00
Felix Wolfsteller
249064d8f6 update README to reflect current Rails version
Paragraph defaults to description of how to test in Rails 5/6 now.
2020-02-06 18:13:30 +01:00
Rafael Mendonça França
f8daa52b9b Change license of the logo 2020-02-03 12:01:11 -05:00
Rafael Mendonça França
a17abad57a Remove all references to Plataformatec 2020-02-03 11:33:17 -05:00
Rafael França
3ef4e0b701 Merge pull request #5172 from lukerollans/chore/case-mapping-collisions-test
Add a test which checks for Case Mapping Collisions when requesting a password reset
2020-01-22 12:23:22 -05:00
Rafael França
83a32e6d21 Merge pull request #5174 from connorshea/fix-ruby-27-deprecation-warnings
Fix two deprecated usages of keyword arguments.
2019-12-27 12:44:32 -03:00
Connor Shea
a3fcb3b682 Fix two deprecated usages of keyword arguments.
This prevents us from using behavior that was deprecated in Ruby 2.7.
2019-12-26 17:44:53 -07:00
Luke Rollans
0d95c5ae8b Generalise email address 2019-12-17 13:47:40 +08:00
Luke Rollans
9fb079c097 Add a test which checks for Case Mapping Collisions when resetting pw
See here for more information
https://eng.getwisdom.io/hacking-github-with-unicode-dotless-i/
2019-12-17 13:43:53 +08:00
Leonardo Tegon
43068ac239 Merge pull request #5167 from plataformatec/sp-fix-typos
Fix typos
2019-11-29 09:53:03 -03:00
Samuel Pordeus
fb18c6ca8d Fix typos 2019-11-28 18:13:47 -03:00
Colin Ross
14863ba4c9 Documentation: Details/Notes regarding Rails API-only applications (#5152)
* doc: Add some additional details concerning using devise in an API-only Rails application

* Apply wording suggestions from code review

Co-Authored-By: Marcos Ferreira <mracos@users.noreply.github.com>

* Apply suggestions from code review

Co-Authored-By: Marcos Ferreira <mracos@users.noreply.github.com>
2019-10-29 15:06:37 -03:00
Rafael França
885c61ece3 Merge pull request #5157 from tabakazu/add_assert_and_replace_mathcer
Add assert to Lockable integration test and Replace mathcer `assert_not` to `refute`
2019-10-25 11:54:53 -04:00
tabakazu
940b939791 Add assert for check last_sign_in_ip value 2019-10-24 21:12:27 +09:00
Looi David
406915cb78 changed? behaviour has been updated (#5135)
* `changed?` behaviour has been updated

Due to 16ae3db5a5 `changed?` has been updated to check for dirtiness after save. The new method that behaves like the old `changed` is `saved_changes?`.

* Add comment to explain which method to used based on which rails version it is
2019-10-22 10:39:34 -03:00
Leonardo Tegon
c5de662454 Merge pull request #5153 from storrence88/patch-1
Update README.md
2019-10-14 14:21:00 -03:00
Steven Torrence
0a6cd99d03 Update README.md
Change before filter to before action to match the code example given below.
2019-10-11 09:27:46 -05:00
Leonardo Tegon
ffeb942699 Merge pull request #5148 from gurgelrenan/flash_message
Call set_flash_message helper instead of flash accessor
2019-10-07 15:35:00 -03:00
Leonardo Tegon
f148c90fc7 Merge pull request #5142 from rlue/doc/initializer
Explain layout of default config initializer
2019-10-07 15:02:24 -03:00
Renan Gurgel
d022fb8cc4 Update code with single-quotes 2019-10-03 14:27:59 -03:00
Renan Gurgel
421ffc479f Add test to admin error message 2019-10-03 14:15:47 -03:00
Renan Gurgel
0f134f7030 Call set_flash_message helper instead of flash accessor 2019-10-03 00:15:15 -03:00
Ryan Lue
5d73e1e3bb Explain layout of default config initializer [ci skip] 2019-09-27 06:21:27 +08:00
Marcos Ferreira
f48b6f1651 Merge pull request #5067 from shobhitic/master
Using scoped errors for scoped views. Fixes #5066
2019-09-17 14:49:57 -03:00
Marcos Ferreira
34ed989725 Move PR #5074 to unreleased in changelog [skip ci] 2019-09-17 13:38:00 -03:00
Marcos Ferreira
b52e642c01 Merge pull request #5074 from sergey-alekseev/increase-default-stretches-to-12
Increase default stretches to 12
2019-09-17 13:30:55 -03:00
Leonardo Tegon
098345aace Prepare for version 4.7.1 2019-09-06 10:20:20 -03:00
Leonardo Tegon
caa1a55d17 Update CHANGELOG.md [ci skip] 2019-09-05 09:55:12 -03:00
Leonardo Tegon
fee43f3c11 Always return an error when confirmation_token is blank (#5132)
As reported in https://github.com/plataformatec/devise/issues/5071, if
for some reason, a user in the database had the `confirmation_token`
column as a blank string, Devise would confirm that user after receiving
a request with a blank `confirmation_token` parameter.
After this commit, a request sending a blank `confirmation_token`
parameter will receive a validation error.
For applications that have users with a blank `confirmation_token` in
the database, it's recommended to manually regenerate or to nullify
them.
2019-09-04 15:42:48 -03:00
Leonardo Tegon
fad60747d5 Merge pull request #5125 from olleolleolle/patch-1
CI: Drop unused Travis sudo: false directive
2019-08-30 19:30:03 -03:00
Leonardo Tegon
5ceef2d4de Merge pull request #5131 from lslm/ls-fix-typo
Fix typo in email update message
2019-08-30 17:26:22 -03:00
Lucas Santos
6635caf12e Fix typo 2019-08-30 14:35:19 -03:00
Olle Jonsson
e051360ea2 CI: Drop unused Travis sudo: false directive 2019-08-26 13:36:34 +02:00
Leonardo Tegon
6bb74c5abf Update CHANGELOG.md [ci skip] 2019-08-19 13:32:56 -03:00
Leonardo Tegon
a79057070c Prepare for 4.7.0 release 2019-08-19 11:35:55 -03:00
Ewerton
12fc5b76d8 Update README.md (#5115) 2019-08-15 09:28:15 -03:00
Leonardo Tegon
ad5892391d Fix specs on Rails 6 RC2 (#5109)
* Fix specs on Rails 6 RC2

`ActiveRecord::MigrationContext` now has a `schema_migration` attribute.
Ref: https://github.com/rails/rails/pull/36439/files#diff-8d3c44120f7b67ff79e2fbe6a40d0ad6R1018

* Use `media_type` instead of `content_type`

Before Rails 6 RC2, the `ActionDispatch::Response#content_type` method
would return only the media part of the `Content-Type` header, without any
other parts. Now the `#content_type` method returns the entire header -
as it is - and `#media_type` should be used instead to get the previous
behavior.

Ref:
- https://github.com/rails/rails/pull/36034
- https://github.com/rails/rails/pull/36854

* Use render template instead of render file

Render file will need the full path in order to avoid security breaches.
In this particular case, there's no need to use render file, it's ok to
use render template.

Ref: https://github.com/rails/rails/pull/35688

* Don't set `represent_boolean_as_integer` on Rails 6

* Update comments [ci skip]
2019-08-07 12:32:01 -03:00
Leonardo Tegon
df43a3560a Rails 6 release candidate 2 on CI 2019-08-05 14:29:21 -03:00
Rafael França
9aa17eec07 Merge pull request #5099 from efojs/patch-1
Update Options section of comment in routes.rb
2019-07-16 02:43:34 +01:00
Denis Krasulin
45cc668683 Update routes.rb
Comment incorrectly states that default method is "get", while line 228 of /lib/devise.rb sets "delete": "The default method used while signing out: @@sign_out_via = :delete"
2019-07-16 01:08:44 +03:00
Vasiliy Ermolovich
19045a483d Merge pull request #5089 from abhijeetps/abhijeetps-patch-1
Updated Codeacademy's Rails Auth link
2019-07-02 10:11:33 +03:00
Abhijeet Singh
f618b88f91 Updated Codeacademy's Rails Auth link 2019-06-26 15:22:40 +05:30
Rafael França
81cb5b00f4 Merge pull request #5086 from plataformatec/rm-officially-support-6.0
Officially support Rails 6.0
2019-06-18 13:49:34 -04:00
Rafael Mendonça França
54fb582269 Officially support Rails 6.0
Also remove upper bound on railties so people can try devise with new
versions without having to wait us to change the gem and report bugs.
2019-06-12 16:10:13 -04:00
Rafael Mendonça França
44f7325a91 Remove unneeded require
The code that was using that constant is not being used anymore.

Closes #5083
2019-06-12 16:04:50 -04:00
Marcos Ferreira
4ab54943ad Merge pull request #5073 from plataformatec/mf-use-rails-6-rc-1-on-ci
Use rails 6.0.0.rc1 instead of the 6.0.0.beta-3 on CI
2019-05-14 13:27:28 -03:00
Sergey Alekseev
45245df16a update changelog
[skip ci]
2019-05-13 14:15:14 +03:00
Sergey Alekseev
63ea6533de increase default stretches to 12
Test script
---

```ruby
require 'bcrypt'
require 'benchmark'
Benchmark.measure { BCrypt::Password.create('password', cost: 12) }
```

Test results
---

- [Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz](https://ark.intel.com/content/www/us/en/ark/products/97535/intel-core-i5-7360u-processor-4m-cache-up-to-3-60-ghz.html): `#<Benchmark::Tms:0x00007fdd00a4eb30 @label="", @real=0.21730700000080105, @cstime=0.0, @cutime=0.0, @stime=0.00020399999999999585, @utime=0.21685199999999996, @total=0.21705599999999997>`
- [Intel(R) Core(TM) i7-8559U CPU @ 2.70GHz](https://ark.intel.com/content/www/us/en/ark/products/137979/intel-core-i7-8559u-processor-8m-cache-up-to-4-50-ghz.html): `#<Benchmark::Tms:0x00007fe91094fd30 @label="", @real=0.17964200000278652, @cstime=0.0, @cutime=0.0, @stime=7.399999999996298e-05, @utime=0.17950799999999845, @total=0.1795819999999984>`

Other gems
---

- bcrypt-ruby which is used by devise [updated](https://github.com/codahale/bcrypt-ruby/pull/181) their default cost to 12 (not released a gem version yet).
- rails has [a PR](https://github.com/rails/rails/pull/35321) from the Rails core team member to update their `ActiveModel::SecurePassword` which powers `has_secure_password` default cost to 13 (not merged yet).

Previous changes
---

[Previous PR](https://github.com/plataformatec/devise/pull/3549) to increase the default stretches to 12 was created more than 4 years ago. That time the default stretches value [was increased](9efc601c73) from 10 to 11.
2019-05-11 19:35:13 +03:00
Marcos Ferreira
aedc9b7696 Update CHANGELOG.md [ci skip] 2019-05-06 21:10:27 -03:00
Marcos Ferreira
28248e3167 Merge pull request #5069 from igorkasyanchuk/master
Fix rails_51_and_up? method for Rails 6.rc1
2019-05-06 21:03:16 -03:00
Igor Kasyanchuk
612e30258c Use better syntax to compare gem version 2019-05-05 03:44:44 -07:00
Marcos Ferreira
76c888268b Use rails 6.0.0.rc1 instead of the 6.0.0.beta-3 on CI
Also bumped sqlite from 1.3.6 to 1.4 because besides conflicting with
the version that the sqlite adapter was trying to load [0], it is supported
officially since rails 6 [1].

Related:
[0] rails/rails#35153
[1] rails/rails#35844
2019-05-04 15:43:31 -03:00
Marcos Ferreira
07f2712a22 Merge pull request #5065 from Vasfed/fix/rails6_deprecation_email_validation
Fix rails 6.0.rc1 email uniqueness validation deprecation error
2019-05-04 14:41:25 -03:00
Igor Kasyanchuk
75e8555035 Fix rails_51_and_up? method for Rails 6.rc1 2019-05-03 13:11:34 -07:00
Shobhit Bakliwal
a823e510f3 Using scoped errors for scoped views. Fixes #5066 2019-05-02 13:24:01 +05:30
Vasily Fedoseyev
2d53cf4424 Fix rails 6.0.rc1 email uniqueness validation deprecation error 2019-04-26 14:20:30 +03:00
Felipe Renan
e91b8ee0ba Merge pull request #5055 from saiqulhaq/master
refactor method name to be more consistent
2019-04-05 10:03:37 -03:00
Leonardo Tegon
eced9b015b Merge pull request #5057 from plataformatec/af-update-ci-with-rails-6
Update CI to rails 6.0.0.beta3
2019-04-04 15:40:07 -03:00
Ayrton Felipe
dbc3c4f08f Update CI to rails 6.0.0.beta3
In order to check CI behavior was requested by @tegon in slack
channel to update rails 6.0.0.beta1 to 6.0.0.beta3

Issue reference: 5037
2019-04-04 11:40:03 -03:00
M. Saiqul Haq
0d56ae2705 refactor method name to be more consistent 2019-04-04 07:01:39 +07:00
Lucas Ferreira
c1e4031e3b Merge pull request #5054 from ferrl/update-autocomplete
Update password confirmation autocomplete
2019-04-03 11:16:45 -03:00
Lucas Ferreira
964ae53e5b Update password confirmation autocomplete 2019-04-02 18:39:19 -03:00
Leonardo Tegon
2e5b5fcd70 Prepare for 4.6.2 release 2019-03-26 13:26:56 -03:00
Leonardo Tegon
241e8077e3 Update CHANGELOG.md [ci skip] 2019-03-26 13:23:20 -03:00
Leonardo Tegon
55e726e4a7 Merge pull request #5051 from plataformatec/mf-revert-update-encrypted-password-to-nil-if-password-is-nil
Reverts both "[#4245] Allow password to nil (#4261)" and "Add more tests (#4970)"
2019-03-26 11:37:27 -03:00
Marcos Ferreira
f9d13f015a Revert "[#4245] Allowing password to nil (#4261)"
This reverts commit 3aedbf0a4d.
2019-03-26 10:29:46 -03:00
Marcos Ferreira
e704221842 Revert "Add more tests (#4970)"
This reverts commit 05bf574799.
2019-03-26 10:29:16 -03:00
Leonardo Tegon
2a6d608bd8 Merge pull request #5050 from softwaregravy/patch-1
Fix dead link
2019-03-25 18:02:20 -03:00
John Hinnegan
b2dc388556 Fix dead link
The link that's in there goes to a non-existent page. I'm guessing it was moved. I put the link in that I think it was moved to.
2019-03-24 11:07:29 -04:00
Marcos Ferreira
214ce91bf7 Merge pull request #5045 from matheusbn/small-text-fix-in-strategies/authenticatable.rb [skip ci]
Fix RDoc text redundancy in authenticatable.rb strategy
2019-03-18 09:40:53 -03:00
Matheus Berkenbrock Nedel
a460d79b08 fix text redundancy 2019-03-17 21:20:06 -03:00
emersonthis
2f3a59640b Added mention of API mode complications to README (#5041) [ci skip] 2019-03-14 18:19:45 -03:00
Felipe Renan
1102600720 Force nokogiri 1.9.1 on Rails 4.1
Sometimes our CI breaks because it tries to fetch a higher nokogiri
version that requires Ruby 2.3+.
2019-03-03 20:48:40 -03:00
Leonardo Tegon
4e4e42e1ae Include note about security issues in ISSUE_TEMPLATE.md 2019-02-19 16:04:32 -03:00
Leonardo Tegon
20e299bce0 Prepare for 4.6.1 release 2019-02-11 11:38:35 -02:00
Leonardo Tegon
5be5220e5a Update CHANGELOG.md [ci skip] 2019-02-11 11:04:12 -02:00
Leonardo Tegon
fcb04f5302 Check if root_path is defined with #respond_to? instead of #present (#5022)
When an application does not define a `root`, the method will be
undefined instead of returning a falsey value.
This commit also includes a new test with fake objects that mimic this
behavior.

Related resources:

* 1aab449933 (diff-c1be825bdb5f3160081e41432f83d0d7R278)
* https://github.com/plataformatec/devise/issues/5021
2019-02-11 11:00:56 -02:00
Leonardo Tegon
45016829d6 Prepare for 4.6.0 release
It was necessary to manually set the `sqlite3` Gem version after the
release of version `1.4.0`.
See https://github.com/rails/rails/issues/35153 for more info.
2019-02-07 13:28:00 -02:00
Leonardo Tegon
337db5a3a2 Update CHANGELOG.md [ci skip] 2019-02-06 20:01:55 -02:00
Felipe Renan
a921c10e6a Merge pull request #5018 from plataformatec/frg-fix-webrat-warning
Fix webrat warnings
2019-02-04 15:54:36 -02:00
Felipe Renan
101e50f9df Fix webrat warnings
Forwarding methods to private methods is deprecated and produces a
warning after Ruby 2.4.

see: https://bugs.ruby-lang.org/issues/12782

To fix this issue I'm mocking patching webrat making RailsAdatper#response
method public since Webrat::Session is delegating functions to it.
2019-02-04 14:50:14 -02:00
Felipe Renan
6064ca8b73 Merge pull request #5014 from plataformatec/frg-fix-test-setup
Fix bin/test using Rails::TestUnit
2019-01-30 19:00:18 -02:00
Felipe Renan
2dd322579f Fix bin/test to use Rails::TestUnit
The command bin/test stop running single tests once Devise started to
support Rails 5.2. The problem is because we used `rails/test_unit/minitest_plugin`
and this file was moved to another place.

See: https://github.com/rails/rails/pull/29572

I'm not sure if we should require the `minitest-plugin` directly from
Rails like we were doing, I tried it and it didn't work. So I'm
changing this `bin/test` completely based on how Rails does that [here](https://github.com/rails/rails/blob/master/tools/test.rb)
2019-01-29 17:50:50 -02:00
Felipe Renan
e72839f4bc Merge pull request #5011 from plataformatec/frg-fix-sqlite-warning
Fix SQLite3 warning when running tests
2019-01-28 15:29:25 -02:00
Felipe Renan
45438fcfc4 Fix SQLite3 warning
Before setting this option, our test suite was giving the following warning:

```
DEPRECATION WARNING: Leaving `ActiveRecord::ConnectionAdapters::SQLite3Adapter.represent_boolean_as_integer`
set to false is deprecated. SQLite databases have used 't' and 'f' to serialize
boolean values and must have old data converted to 1 and 0 (its native boolean
serialization) before setting this flag to true. Conversion can be accomplished
by setting up a rake task which runs

  ExampleModel.where("boolean_column = 't'").update_all(boolean_column: 1)
  ExampleModel.where("boolean_column = 'f'").update_all(boolean_column: 0)

for all models and all boolean columns, after which the flag must be set to
true by adding the following to your application.rb file:

  Rails.application.config.active_record.sqlite3.represent_boolean_as_integer = true
 (called from <top (required)> at $PATH/devise/test/rails_app/app/active_record/user.rb:5)
```

After configuring `represent_boolean_as_integer = true` as specified
above, we don't have this warning anymore.

More info:
https://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/SQLite3Adapter.html#method-c-represent_boolean_as_integer
2019-01-28 14:39:06 -02:00
Felipe Renan
f3329110ba Update README to help run tests [ci skip] (#5012)
Adds a section to help contributors run Devise test suite.
2019-01-28 14:31:42 -02:00
Hyeonseok
369ba267ef removing white space in devise generator new.html.erb (#5010) 2019-01-24 10:20:03 -02:00
Felipe Renan
a42033cb04 Update CHANGELOG.md [ci skip] 2019-01-23 16:02:12 -02:00
Felipe Renan
1aab449933 Refactor fix #4127
* Adding to check if rootpath is present on url_helpers.
* Run this code only for Rails versions lower than 5.1.
2019-01-23 15:42:17 -02:00
Alessandro
ee65cd60c9 FIX plataformatec/devise#4127 (#4700) 2019-01-23 15:32:29 -02:00
Leonardo Tegon
c000b58c56 Add Rails 6 to CI (#5009) 2019-01-22 12:43:31 -02:00
Matthew Rudy Jacobs
40e8812d75 Apply Test Helper fix to Rails 6.0 as well as 5.x (#5002) 2019-01-17 18:29:00 -02:00
Felipe Renan
cc6046b8cc Merge pull request #5005 from plataformatec/frg-fix-travis-build
Fix travis build
2019-01-17 18:26:54 -02:00
Felipe Renan
6b1ead8654 Fix travis build
Now Travis uses bundler 2.0+ and it causes some build fails since we
still support Rails 4.

This commit set Travis to not use a bundler version higher than 2.0.

More info: https://docs.travis-ci.com/user/languages/ruby/#bundler-20
2019-01-17 17:45:12 -02:00
Patrick Jones
518f6f39bf Fixed broken README link in changelog [ci skip] (#4999) 2019-01-10 11:09:51 -02:00
Rafael França
6edbeb82cd Merge pull request #4998 from Atul9/update-license
Update copyright notice to 2019 [ci skip]
2019-01-07 14:23:26 -05:00
Atul Bhosale
a8d0a8f63d Update copyright notice to 2019 [ci skip] 2019-01-07 23:28:19 +05:30
Leonardo Tegon
62703943be Make #increment_failed_attempts concurrency safe (#4996)
As reported in #4981, the method `#increment_failed_attempts` of `Devise::Models::Lockable` was
not concurrency safe. The increment operation was being done in two steps: first the value was read from the database, and then incremented by 1. This may result in wrong values if two requests try to update the value concurrently. For example:

```
Browser1 -------> Read `failed_attempts` from DB (1) -------> Increment `failed_attempts` to 2
    Browser2 -------> Read `failed_attempts` from DB (1) -------> Increment `failed_attempts` to 2
```

In the example above, `failed_attempts` should have been set to 3, but it will be set to 2. 

This commit handles this case by calling `ActiveRecord::CounterCache.increment_counter` method, which will do both steps at once, reading the value straight from the database.

This commit also adds a `ActiveRecord::AttributeMethods::Dirty#reload` call to ensure that the application gets the updated value - i.e. that other request might have updated. 
Although this does not ensure that the value is in fact the most recent one - other request could've updated it after the `reload` call - it seems good enough for this implementation. 
Even if a request does not locks the account because it has a stale value, the next one - that updated that value - will do it. That's why we decided not to use a pessimistic lock here.

Closes #4981.
2018-12-28 17:00:50 -02:00
kenji kobayashi
e3a00b27d1 Add an option to not automatically sign in a user after changing a password (#4569) 2018-12-28 11:29:58 -02:00
Pavel Pestau
8266e85576 Removing extra characters (#4991) 2018-12-21 10:18:05 -02:00
Pavel Pestau
4372dd402b Removed extra characters (#4988) 2018-12-20 11:51:19 -02:00
Marcos Ferreira
6e4b0b94bc Don't run gem update --system and gem install bundler on CI
There were some issues with the combination of some `bundler` and `rubygems` versions.
We got around that by always updating `bundler` in the CI but since those issues
were fixed we can quit doing that.

Related to `gem update --system`:
- travis-ci/travis-ci#8978
- rubygems/rubygems#2123

Related to `gem install bundler`:
- travis-ci/travis-ci#9333
- travis-ci/travis-ci#8969
- bundler/bundler#6340
2018-12-19 17:04:56 -02:00
Leonardo Tegon
bf74a506c8 Update CHANGELOG.md [ci skip] 2018-12-19 10:32:50 -02:00
Marcos Ferreira
e01fb8bb22 Merge pull request #4989 from plataformatec/mf-fix-unclosed-tag-error-messages-partial
Fix unclosed html tag and add deprecation warn
2018-12-19 09:52:10 -02:00
Marcos Ferreira
14785afe8d Add a deprecation warn for DeviseHelper.devise_error_messages!
To customize the error style one should modifying the
`devise/shared/error_messages` partial.
2018-12-18 21:15:13 -02:00
Marcos Ferreira
66a96ab9d6 Fix unclosed li tag in error_messages partial 2018-12-18 21:15:11 -02:00
Graham Brereton
76b87dc0e8 Refactor the devise_error_messages! helper to render a partial (#4616)
This should make it more intuitive and easier for developers using the
project to implement their own layout for errors.
2018-12-18 21:01:16 -02:00
Leonardo Tegon
cb663e96a3 Update CHANGELOG.md [ci skip] 2018-12-04 14:37:20 -02:00
Stan Hu
1192c76f62 Fix corner case when confirmation_sent_at is equal to 0.days.ago (#4529)
If `Confirmable#confirmation_sent_at` is equal to `0.days.ago`, then
`confirmation_period_valid?` will be deemed valid even if the setting is
configured to disable this outright. To prevent this error, we explicitly
check the configuration setting to be `0.days.ago`.
2018-12-04 14:34:32 -02:00
Leonardo Tegon
ecd2187652 Update CHANGELOG.md [ci skip] 2018-11-30 17:43:28 -02:00
ihatov08
d1571627b7 Add deprication waring if use options argument at DatabaseAuthenticatable#update_with_password,#update_without_password (#4935) 2018-11-28 17:58:10 -02:00
Leonardo Tegon
52b24e41de Fix typo [ci skip] 2018-11-23 13:26:26 -02:00
Leonardo Tegon
5f62f28d6e Explain the code that prevents enumeration attacks 2018-11-22 20:38:02 -02:00
Jason Lee
c84169122f Ignore useless files into the gem file. (#4955) 2018-11-22 20:04:53 -02:00
Kanmaniselvan Murugesan
bafc23eae5 Issue 4895: Add after_database_authentication callback after sign_in immediately after password update (#4916) 2018-11-22 19:13:55 -02:00
Leonardo Tegon
aa6cb411bc Add missing specs for #find_or_initialize_with_errors
After merging https://github.com/plataformatec/devise/pull/4797, I
noticed that we had no specs for the scenarios where this method was
adding the errors to the resource. This commit adds tests to cover those
cases.
2018-11-22 18:44:09 -02:00
Ryan Lue
354df3bc65 [bugfix] [refactoring] Sanitize parameters in find_or_initialize_with_errors (#4797)
* Use parameter sanitizer for new records in find_or_initialize_with_errors

* Add test for find_or_initialize_with_errors bugfix
2018-11-22 15:10:50 -02:00
Kopylov Vladislav
6f140faf0d fixed description for Devise::Generators::ControllersGenerator (#4975) 2018-11-21 19:20:23 -02:00
Leonardo Tegon
05bf574799 Add more tests (#4970)
After merging #4261, I realized that we could add a couple more
tests, to ensure the new behavior added to `#valid_password?` - which is
that it should return `false` when the password is either `nil` or blank
('').
I've also removed [this
condition](https://github.com/plataformatec/devise/blob/master/lib/devise/models/database_authenticatable.rb#L68)
because it's already present at `Devise::Encryptor` module in the
`.compare`
[method](https://github.com/plataformatec/devise/blob/master/lib/devise/encryptor.rb#L15).
2018-11-13 15:29:14 -02:00
Colin Ross
40f02ae69b Only flash if the request object that is loaded supports it (#4950) 2018-11-13 15:26:00 -02:00
sivagollapalli
3aedbf0a4d [#4245] Allowing password to nil (#4261)
* [#4245] Allowing password to nil

* Set encrypted password to nil if password is nil

* [#4245] Fixing the build

* Removed unnecessary code
2018-11-13 13:57:23 -02:00
John Gabriel
fa067b31c6 chore(docs): allow_unconfirmed_access_for = nil (#2275) (#4964) 2018-11-12 14:27:27 -02:00
Vasiliy Ermolovich
517010e2c5 Merge pull request #4961 from HarlemSquirrel/issue-template-20181028
Fix Issue template grammar
2018-10-28 21:01:28 +03:00
Vasiliy Ermolovich
4adc792422 Merge pull request #4960 from HarlemSquirrel/contributing-20181028
Fix CONTRIBUTING.md typo
2018-10-28 19:51:59 +03:00
Kevin McCormack
0640b318ca Fix Issue template grammar 2018-10-28 12:41:08 -04:00
Kevin McCormack
95fad8b408 Fix CONTRIBUTING.md typo 2018-10-28 12:36:00 -04:00
Sam Weerasinghe
94adec3cee Issue #4941 , handle error 'Please specify the Rails release the migration was written for' (#4942) 2018-10-03 15:21:59 -03:00
Ieva S
87b73540a4 Updated year in MIT-LICENSE (#4948) 2018-10-01 08:38:41 -03:00
Isaac Orme
25f908ad9c issue 4526 adds skip email and password change notifications methods (#4824) 2018-09-28 18:55:00 -03:00
Rafael França
4656e96d9e Merge pull request #4938 from colinross/issue-#4931-missing-comma
Missing comma in form input
2018-09-19 22:03:22 -04:00
Colin Ross
389cd85d47 Missing comma in form input 2018-09-19 18:19:56 -07:00
Leonardo Tegon
3b0bc08ec6 Prepare for 4.5.0 release 2018-08-15 20:03:08 -03:00
Leonardo Tegon
2eca92f950 Update CHANGELOG.md 2018-08-15 17:05:50 -03:00
Isaac Orme
acc45c5a44 issue 4356 adds is_navigational_format? check to after_sign_up_path_for (#4833) 2018-08-02 11:02:50 -03:00
Guillaume CABANEL
e4dd1509c4 Update README.md (#4911)
update links to rubydoc.info to the url `www.rubydoc.info` since the ssl certificate is only valid for www.rubydoc.info (not rubydoc.info)
2018-07-31 11:36:42 -03:00
Phil Nash
b8f644198d Corrects brakes -> breaks when talking about tests (#4897) 2018-07-03 09:52:07 -03:00
lucfranken
715192a770 Improve getting started text on Gemfile (#4875)
The original text: 

> You can add it to your Gemfile with:

Could easily be read as: "Run this command to add it to your Gemfile"

That's what I did at least. I think the change makes it much clearer that you need to really manually add a line of text into the Gemfile.

One of the reasons why this is not fully clear is that it's badly visible on Github whether a command is a console / terminal command or a ruby line of code. Visually they look the same except for the $ sign which is easy to overlook.
2018-05-16 14:48:24 -03:00
Josh Pencheon
31aceeb104 Fix bug: ParameterFilter should not add keys (#3431) (#4457)
If called with a hash that has a `default` / `default_proc`
configured, `Devise::ParameterFilter` can add in missing keys
it was due to attempt to sanitise the values for.

This patch prevents this from happening, whilst also clarifying
the filtering intent of `ParamaterFilter`.

(This can also occur if NilClass has been augmented with definitions
for `strip` or `downcase`.)

Fixes #3431.
2018-05-15 10:47:18 -03:00
Samy Kacimi
af8f7e9797 remove :trackable from the default modules (#4857)
This removes :trackable from the default modules in the generators,
to be more GDPR-friendly.
2018-05-14 18:11:15 -03:00
Gencer W. Genç
6c916488af find auto-generated secret_key_base in development (#4869)
With this fix, we will try latest changes in Rails 5.2 together with standard auto-generated secret_key_base in development as a fallback.

If no specified key found, auto-generated value will be used instead.
2018-05-14 18:09:25 -03:00
Maud de Vries
246a50876a Mention the -c flag for the controller generator
Similar to the views section, that mentions the -v flag
2018-05-11 10:20:23 -03:00
Andrey Andreev
8866b8e5eb Fix error when params is not a hash 2018-05-09 14:56:50 -03:00
Tony Correia
1c8e97c75a Issue 4763: Change login errors for when in paranoid mode 2018-05-09 10:49:27 -03:00
Gustavo Bazan
cd9ad848fb Update simple form templates
Update `simple_form` templates with changes from 16b3d6d67c and 6260c29a86
2018-05-08 15:42:26 -03:00
Vasiliy Ermolovich
be15116426 Merge pull request #4858 from lookageek/patch-1
Fix in rdoc of DeviseController#_prefixes
2018-05-03 13:12:38 +03:00
Jayanth Manklu
9d90a559ce Fix in rdoc of DeviseController#_prefixes
Removing an additional "is"
2018-05-03 15:36:43 +05:30
Rafael França
d98f38cf5f Merge pull request #4848 from abhishekkanojia/refactor_code
Remove redundant self from database_authenticatable module.
2018-04-23 12:08:42 -04:00
Abhishek kanojia
f99636da76 Remove redundant self from database_authenticatable module. 2018-04-22 11:57:18 +05:30
Gustavo Bazan
6260c29a86 Improve passwords autocomplete
Use `autocomplete="new-password"` or `autocomplete="current-password"` to better signal to browsers and password managers how to handle the password fields.

This feature is especially useful for “change your password” and “new user” forms
2018-04-19 12:58:58 -04:00
Rafael França
45481df14a Merge pull request #4843 from lancecarlson/master
upgrade dependencies for rails and responders
2018-04-18 13:55:41 -04:00
Lance Carlson
7eccd4e9c6 upgrade dependencies for rails and responders 2018-04-17 00:03:12 -04:00
yhirano55
2cf18f99e0 CI against Ruby 2.3.7, 2.4.4, 2.5.1 2018-04-07 00:21:12 -03:00
Leonardo Tegon
bcbea08187 Add note in the documentation about sign_in and timeoutable
In order to use the `sign_in` helper along with the timeoutable module,
we have to set `env["devise.skip_timeout"] = true` in the request.
Currently, we do this in the sessions controller: https://github.com/plataformatec/devise/blob/master/app/controllers/devise/sessions_controller.rb#L7
This commit adds a note to the `sign_in` documentation to help other
developers that want to use custom warden strategies.

Closes #4773
2018-04-04 21:00:49 -03:00
Max Kramer
b20de505ab Split IP resolution from update_tracked_fields
This permits users to easily customize where the ip address
should be resolved.  When fronting the application with a webserver or
load balancer, the ip address may be the server and not be the user.

E.g. consider the IP address is passed as the header: "X-Forwarded-For".

```ruby
class User
  devise :trackable

  protected
    def extract_ip_from(request)
      request.headers["X-Forwarded-For"]
    end
end
```
2018-04-03 09:53:28 -03:00
yusukemorita
20bde34981 added link to integration tests section 2018-03-30 10:57:12 -03:00
yusukemorita
e9abba797a added comment in README about controller tests for rails 5 2018-03-30 10:57:12 -03:00
Koichi ITO
dac90eeb80 Use update instead of update_attributes
`update_attributes` and `update_attributes!` will be deprecated in Rails 6.

Refer 5645149d3a
2018-03-29 15:39:24 -03:00
Wolfram Nikolas Müller
f220b992c3 add test for lazy loading hook 2018-03-29 15:32:46 -03:00
Wolfram Nikolas Müller
2bb8e1c236 Fix missing do block in config 2018-03-29 15:32:46 -03:00
Wolfram Nikolas Müller
e44a8b2d43 Include configuration for Turbolinks in devise initializer template 2018-03-29 15:32:46 -03:00
Wolfram Nikolas Müller
268bd69164 Allow people to extend devise failure app, through invoking ActiveSupport.run_load_hooks once Devise::FailureApp is loaded 2018-03-29 15:32:46 -03:00
Eden Rohatensky
d750709250 Use before_action instead of before_filter 2018-03-28 09:12:11 -03:00
Fred Ngo
c9a2d0654e Update sample code in Devise::Models::Authenticatable.
- DRY up some of the sample code by refactoring into smaller methods.
- ‘Namespace’ method names to reduce chances of conflict.
- Mark send_pending_devise_notifications, pending_devise_notifications, and render_and_send_devise_message as `private` since they are only used internally.
- Update comments.
2018-03-23 22:42:48 -03:00
Johan Kim
26723d9bbc cleanup in ToC 2018-03-23 10:05:31 -03:00
Leonardo Tegon
75f9e76f65 Prepare for 4.4.3 release 2018-03-17 20:44:00 -03:00
Leonardo Tegon
962cea2039 Create Devise::SecretKeyFinder
When supporting Rails 5.2 credentials on
https://github.com/plataformatec/devise/pull/4712, we ended up breaking
apps that were upgraded to Rails 5.2 and weren't using `credentials`
to store their `secret_key_base`. See
https://github.com/plataformatec/devise/issues/4807 for more context.
To fix it, we're now checking whether the key is present before using it.
Since there weren't any automated test for this - the conditionals were
in a Rails engine initializer - I've extracted it to a new class so that
we are able to test it easily.

Fixes #4807
2018-03-17 20:28:38 -03:00
Leonardo Tegon
64aad8b138 Fix Devise::Test::ControllerHelpers
This was broken on 3e23371b01 (diff-bafaaa60fc003e648eb4981c9add523eR142)
because of a call to the method `Devise::Test.rails5?` which is only
defined inside our test suite's rails app a45bbe1783/test/rails_app/config/boot.rb (L19)
This commits checks for the rails version directly.
2018-03-16 11:17:48 -03:00
Leonardo Tegon
0d279415f3 Prepare for 4.4.2 release 2018-03-15 09:56:15 -03:00
Leonardo Tegon
fc45f916d6 Update CHANGELOG.md 2018-03-15 09:48:59 -03:00
Leonardo Tegon
3722aa6296 Revert "Replace log_process_action to append_info_to_payload" 2018-03-15 09:43:12 -03:00
Leonardo Tegon
5664b19703 Ensure Devise isn't performing model validations 2018-03-14 15:21:07 -03:00
Leonardo Tegon
d870c0dced Check if the record is persisted in update_tracked_fields!
In some cases, invalid records could be created during the signup
process because we were calling `save(validate: false)` inside the
`update_tracked_fields!` method. See
https://github.com/plataformatec/devise/issues/4673 for more
information.
This was fixed on https://github.com/plataformatec/devise/pull/4674 by
calling `save` directly, but it caused some trouble and confusion since
it changed Devise's behavior significantly.
We talked about on https://github.com/plataformatec/devise/issues/4790
and it doesn't even make sense to call `save` on an object that isn't
persisted yet, so I've added a guard clause to the
`update_tracked_fields!` method.

Fixes https://github.com/plataformatec/devise/issues/4790
2018-03-14 15:21:07 -03:00
Danilo Araújo Silva
8ab7963e50 Creating a new section for controller configuration on devise.rb template
Creating a new section called `Controller configuration`.

An optional devise configuration is set `config.parent_controller` but this configuration is missing in the `devise.rb` template file.
2018-03-14 15:09:04 -03:00
Rafael França
d545fe3e3f Merge pull request #4784 from gmcnaughton/fix-controller-tests-content_type
Fixes #4783 - preserve content_type for unauthenticated test responses
2018-02-26 13:04:03 -05:00
Gordon McNaughton
3e23371b01 Preserve content_type for unauthenticated tests
In Rails 4, for unauthenticated controller tests which trigger the
failure app, ensure that the simulated failure response includes a
content_type (broken in bb44d42).

This works in Rails5, which parses the content-type header on-demand,
but not in Rails4 which requires setting the response's content_type
explicitly.

Fixes #4783.
2018-02-26 12:15:36 -05:00
Leonardo Tegon
6bda962547 Update CHANGELOG.md [ci skip] 2018-02-22 18:00:13 -03:00
Leonardo Tegon
f141bb57ec Update CHANGELOG.md [ci skip] 2018-02-22 17:59:33 -03:00
Rafael França
9001123b7e Merge pull request #4779 from Fudoshiki/master
Allow test rails 6
2018-02-22 14:30:01 -05:00
Yuri S
5919620b24 change right border 2018-02-22 21:55:17 +05:00
Justin Coyne
a45bbe1783 Test on Rails 5.2.0.rc1 (#4711) 2018-02-22 10:05:19 -03:00
Yuri S
2514c69d81 Allow rails 6 2018-02-21 07:18:36 +05:00
Leonardo Tegon
8b53975652 Improve documentation about the test suite (#4774) 2018-02-06 10:49:45 -02:00
Gencer W. Genç
bdd6081815 Support for :credentials on Rails v5.2.x. (#4712)
This fixes #4710.

Rails introduced :secrets in v5.1. They somehow changed it to :credentials. This fix represents this change.

Devise will now look :credentials first, then fallback to :secrets for 5.1.x compatibility then it will check for standard secret key. If three not found then exception will arise.
2018-01-23 19:19:29 -02:00
Leonardo Tegon
e55c9caa05 Prepare for 4.4.1 release 2018-01-23 15:03:41 -02:00
Leonardo Tegon
0f8695dd4b Update CHANGELOG.md [ci skip] 2018-01-23 13:31:26 -02:00
Alex Matchneer
d9deeba582 Fix signed_in? docs w.r.t. running auth hooks (#4733)
Addresses #4599

The docs previously mentioned that authentication hooks are not run when `signed_in?` is called, when in fact they are. This commit fixes the comment and suggests calling `authenticated?` on warden directly as an alternative for when you _don't_ want to run auth hooks.
2018-01-23 13:18:37 -02:00
Leonardo Tegon
d1948b79d3 Fix ActiveRecord check on Confirmable (#4752)
* Fix `ActiveRecord` check on `Confirmable`

As pointed out by @dark-panda in #4302, the condition for an
`ActiveRecord` model is wrong inside the `Confirmable` initialization
block.

https://github.com/plataformatec/devise/pull/4302#issuecomment-355103489

* Add specs
2018-01-16 10:25:20 -02:00
Rafael França
371d657e35 Merge pull request #4753 from segiddins/patch-1
[Gemspec] Ensure it is loaded as utf-8
2018-01-15 15:03:03 -05:00
Samuel Giddins
82087ce211 [Gemspec] Ensure it is loaded as utf-8 2018-01-12 21:26:42 -08:00
Leonardo Tegon
463351922f Update copyright [ci skip] 2018-01-03 21:20:13 -02:00
147 changed files with 2749 additions and 944 deletions

View File

@@ -2,14 +2,19 @@ language: ruby
rvm:
- 2.1.10
- 2.2.8
- 2.3.5
- 2.4.2
- 2.5.0
- 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
@@ -18,27 +23,68 @@ matrix:
exclude:
- rvm: 2.1.10
gemfile: Gemfile
- rvm: 2.5.0
- 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.4.2
- 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: 2.1.10
gemfile: gemfiles/Gemfile.rails-5.0-stable
- rvm: 2.1.10
gemfile: Gemfile
- 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
sudo: false
cache: bundler
env:
@@ -47,8 +93,9 @@ env:
- 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"
- gem update --system
before_script: "bundle update"

View File

@@ -1,4 +1,125 @@
### Unreleased
### 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)
* Ruby 2.7 support (kwarg warnings removed)
* bug fixes
* Generate scoped views with proper scoped errors partial (by @shobhitic)
* Allow to set scoped `already_authenticated` error messages (by @gurgelrenan)
### 4.7.1 - 2019-09-06
* bug fixes
* Fix an edge case where records with a blank `confirmation_token` could be confirmed (by @tegon)
* Fix typo inside `update_needs_confirmation` i18n key (by @lslm)
### 4.7.0 - 2019-08-19
* enhancements
* Support Rails 6.0
* Update CI to rails 6.0.0.beta3 (by @tunnes)
* refactor method name to be more consistent (by @saiqulhaq)
* Fix rails 6.0.rc1 email uniqueness validation deprecation warning (by @Vasfed)
* bug fixes
* Add `autocomplete="new-password"` to `password_confirmation` fields (by @ferrl)
* Fix rails_51_and_up? method for Rails 6.rc1 (by @igorkasyanchuk)
### 4.6.2 - 2019-03-26
* bug fixes
* Revert "Set `encrypted_password` to `nil` when `password` is set to `nil`" since it broke backward compatibility with existing applications. See more on https://github.com/heartcombo/devise/issues/5033#issuecomment-476386275 (by @mracos)
### 4.6.1 - 2019-02-11
* bug fixes
* Check if `root_path` is defined with `#respond_to?` instead of `#present` (by @tegon)
### 4.6.0 - 2019-02-07
* enhancements
* Allow to skip email and password change notifications (by @iorme1)
* Include the use of `nil` for `allow_unconfirmed_access_for` in the docs (by @joaumg)
* Ignore useless files into the `.gem` file (by @huacnlee)
* Explain the code that prevents enumeration attacks inside `Devise::Strategies::DatabaseAuthenticatable` (by @tegon)
* Refactor the `devise_error_messages!` helper to render a partial (by @prograhamer)
* Add an option (`Devise.sign_in_after_change_password`) to not automatically sign in a user after changing a password (by @knjko)
* bug fixes
* Fix missing comma in Simple Form generator (by @colinross)
* Fix error with migration generator in Rails 6 (by @oystersauce8)
* Set `encrypted_password` to `nil` when `password` is set to `nil` (by @sivagollapalli)
* Consider whether the request supports flash messages inside `Devise::Controllers::Helpers#is_flashing_format?` (by @colinross)
* Fix typo inside `Devise::Generators::ControllersGenerator` (by @kopylovvlad)
* Sanitize parameters inside `Devise::Models::Authenticatable#find_or_initialize_with_errors` (by @rlue)
* `#after_database_authentication` callback was not called after authentication on password reset (by @kanmaniselvan)
* Fix corner case when `#confirmation_period_valid?` was called at the same second as `confirmation_sent_at` was set. Mostly true for date types that only have second precisions. (by @stanhu)
* Fix unclosed `li` tag in `error_messages` partial (by @mracos)
* Fix Routes issue when devise engine is mounted in another engine on Rails versions lower than 5.1 (by @a-barbieri)
* Make `#increment_failed_attempts` concurrency safe (by @tegon)
* Apply Test Helper fix to Rails 6.0 as well as 5.x (by @matthewrudy)
* deprecations
* The second argument of `DatabaseAuthenticatable`'s `#update_with_password` and `#update_without_password` is deprecated and will be removed in the next major version. It was added to support a feature deprecated in Rails 4, so you can safely remove it from your code. (by @ihatov08)
* The `DeviseHelper.devise_error_messages!` is deprecated and will be removed in the next major version. Use the `devise/shared/error_messages` partial instead. (by @mracos)
### 4.5.0 - 2018-08-15
* enhancements
* Use `before_action` instead of `before_filter` (by @edenthecat)
* Allow people to extend devise failure app, through invoking `ActiveSupport.run_load_hooks` once `Devise::FailureApp` is loaded (by @wnm)
* Use `update` instead of `update_attributes` (by @koic)
* Split IP resolution from `update_tracked_fields` (by @mckramer)
* upgrade dependencies for rails and responders (by @lancecarlson)
* Add `autocomplete="new-password"` to new password fields (by @gssbzn)
* Add `autocomplete="current-password"` to current password fields (by @gssbzn)
* Remove redundant `self` from `database_authenticatable` module (by @abhishekkanojia)
* Update `simple_form` templates with changes from https://github.com/heartcombo/devise/commit/16b3d6d67c7e017d461ea17ed29ea9738dc77e83 and https://github.com/heartcombo/devise/commit/6260c29a867b9a656f1e1557abe347a523178fab (by @gssbzn)
* Remove `:trackable` from the default modules in the generators, to be more GDPR-friendly (by @fakenine)
* bug fixes
* Use same string on failed login regardless of whether account exists when in paranoid mode (by @TonyMK9068)
* Fix error when params is not a hash inside `Devise::ParameterSanitizer` (by @b0nn1e)
* Look for `secret_key_base` inside `Rails.application` (by @gencer)
* Ensure `Devise::ParameterFilter` does not add missing keys when called with a hash that has a `default` / `default_proc`
configured (by @joshpencheon)
* Adds `is_navigational_format?` check to `after_sign_up_path_for` to keep consistency (by @iorme1)
### 4.4.3 - 2018-03-17
* bug fixes
* Fix undefined method `rails5?` for Devise::Test:Module (by @tegon)
* Fix: secret key was being required to be set inside credentials on Rails 5.2 (by @tegon)
### 4.4.2 - 2018-03-15
* enhancements
* Support for :credentials on Rails v5.2.x. (by @gencer)
* Improve documentation about the test suite. (by @tegon)
* Test with Rails 5.2.rc1 on Travis. (by @jcoyne)
* Allow test with Rails 6. (by @Fudoshiki)
* Creating a new section for controller configuration on `devise.rb` template (by @Danilo-Araujo-Silva)
* bug fixes
* Preserve content_type for unauthenticated tests (by @gmcnaughton)
* Check if the resource is persisted in `update_tracked_fields!` instead of performing validations (by @tegon)
* Revert "Replace log_process_action to append_info_to_payload" (by @tegon)
### 4.4.1 - 2018-01-23
* bug fixes
* Ensure Gemspec is loaded as utf-8. (by @segiddins)
* Fix `ActiveRecord` check on `Confirmable`. (by @tegon)
* Fix `signed_in?` docs without running auth hooks. by (@machty)
### 4.4.0 - 2017-12-29
@@ -17,7 +138,7 @@
* Validations were being ignored on singup in the `Trackable#update_tracked_fields!` method. (by @AshleyFoster)
* Do not modify options for `#serializable_hash`. (by @guigs)
* Email confirmations were being sent on sign in/sign out for application using `mongoid` and `mongoid-paperclip` gems. This is because previously we were checking if a model is from Active Record by checking if the method `after_commit` was defined - since `mongoid` doesn' have one - but `mongoid-paperclip` gem does define one, which cause this issue. (by @fjg)
### 4.3.0 - 2017-05-14
* Enhancements
@@ -206,8 +327,8 @@
end
```
You can check more examples and explanations on the [README section](/plataformatec/devise#strong-parameters)
You can check more examples and explanations on the [README section](README.md#strong-parameters)
and on the [ParameterSanitizer docs](lib/devise/parameter_sanitizer.rb).
Please check [3-stable](https://github.com/plataformatec/devise/blob/3-stable/CHANGELOG.md)
Please check [3-stable](https://github.com/heartcombo/devise/blob/3-stable/CHANGELOG.md)
for previous changes.

View File

@@ -17,6 +17,6 @@ Project maintainers have the right and responsibility to remove, edit, or reject
This code of conduct applies both within project spaces and in public spaces when an individual is representing the project or its community.
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by sending an email to [conduct@plataformatec.com.br](conduct@plataformatec.com.br) or contacting one or more of the project maintainers.
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by sending an email to [heartcombo@googlegroups.com](heartcombo@googlegroups.com) or contacting one or more of the project maintainers.
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0, available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/)

View File

@@ -8,7 +8,7 @@ expected to follow our [Code of Conduct](CODE_OF_CONDUCT.md).
## Reporting Issues
Before reporting a new issue, please be sure that the issue wasn't already
reported or fixed by searching on GitHub through our [issues](https://github.com/plataformatec/devise/issues).
reported or fixed by searching on GitHub through our [issues](https://github.com/heartcombo/devise/issues).
When creating a new issue, be sure to include a **title and clear description**,
as much relevant information as possible, and either a test case example or
@@ -22,7 +22,7 @@ Please do not attempt to translate Devise built in views. The views are meant
to be a starting point for fresh apps and not production material - eventually
all applications will require custom views where you can write your own copy and
translate it if the application requires it . For historical references, please look into closed
[Issues/Pull Requests](https://github.com/plataformatec/devise/issues?q=i18n) regarding
[Issues/Pull Requests](https://github.com/heartcombo/devise/issues?q=i18n) regarding
internationalization.
Avoid opening new issues to ask questions in our issues tracker. Please go through
@@ -30,7 +30,7 @@ the project wiki, documentation and source code first, or try to ask your questi
on [Stack Overflow](http://stackoverflow.com/questions/tagged/devise).
**If you find a security bug, do not report it through GitHub. Please send an
e-mail to [opensource@plataformatec.com.br](mailto:opensource@plataformatec.com.br)
e-mail to [heartcombo@googlegroups.com](mailto:heartcombo@googlegroups.com)
instead.**
## Sending Pull Requests
@@ -50,7 +50,7 @@ are beneficial to a wide range of use cases or it's an application specific chan
that might not be so valuable to other applications. Some changes can be introduced
as a new `devise-something` gem instead of belonging to the main codebase.
When adding new settings, you can take advantage of the [`Devise::Models.config`](https://github.com/plataformatec/devise/blob/245b1f9de0b3386b7913e14b60ea24f43b77feb0/lib/devise/models.rb#L13-L50) method to add class and instance level fallbacks
When adding new settings, you can take advantage of the [`Devise::Models.config`](https://github.com/heartcombo/devise/blob/245b1f9de0b3386b7913e14b60ea24f43b77feb0/lib/devise/models.rb#L13-L50) method to add class and instance level fallbacks
to the new setting.
We also welcome Pull Requests that improve our existing documentation (both our
@@ -64,9 +64,9 @@ open issues to help troubleshoot and fix existing bugs on Devise. Here is what
you can do:
* Help ensure that existing issues follows the recommendations from the
_[Reporting Issues](#reporting-issues)_ section, providing feeback to the issue's
_[Reporting Issues](#reporting-issues)_ section, providing feedback to the issue's
author on what might be missing.
* Review and update the existing content of our [Wiki](https://github.com/plataformatec/devise/wiki)
* Review and update the existing content of our [Wiki](https://github.com/heartcombo/devise/wiki)
with up to date instructions and code samples - the wiki was grown with several
different tutorials and references that we can't keep track of everything, so if
there is a page that showcases an integration or customization that you are

24
Gemfile
View File

@@ -4,34 +4,34 @@ source "https://rubygems.org"
gemspec
gem "rails", "~> 5.1"
gem "omniauth", "~> 1.3"
gem "oauth2"
gem "rails", "~> 6.0.0"
gem "omniauth"
gem "omniauth-oauth2"
gem "rdoc"
gem "activemodel-serializers-xml", github: "rails/activemodel-serializers-xml"
gem "rails-controller-testing"
gem "rails-controller-testing", github: "rails/rails-controller-testing"
gem "responders", "~> 2.1"
gem "responders", "~> 3.0"
group :test do
gem "omniauth-facebook"
gem "omniauth-openid"
gem "timecop"
gem "webrat", "0.7.3", require: false
gem "mocha", "~> 1.1", require: false
end
platforms :jruby do
gem "activerecord-jdbc-adapter"
gem "activerecord-jdbcsqlite3-adapter"
gem "jruby-openssl"
platforms :ruby do
gem "sqlite3", "~> 1.4"
end
platforms :ruby do
gem "sqlite3"
end
# platforms :jruby do
# gem "activerecord-jdbc-adapter"
# gem "activerecord-jdbcsqlite3-adapter"
# gem "jruby-openssl"
# end
# TODO:
# group :mongoid do

View File

@@ -1,193 +1,219 @@
GIT
remote: git://github.com/rails/activemodel-serializers-xml.git
revision: dd9c0acf26aab111ebc647cd8deb99ebc6946531
remote: https://github.com/rails/activemodel-serializers-xml.git
revision: 694f4071c6b16e4c8597cc323c241b5f787b3ea8
specs:
activemodel-serializers-xml (1.0.1)
activemodel (> 5.x)
activesupport (> 5.x)
activemodel-serializers-xml (1.0.2)
activemodel (>= 5.0.0.a)
activesupport (>= 5.0.0.a)
builder (~> 3.1)
GIT
remote: https://github.com/rails/rails-controller-testing.git
revision: 4b15c86e82ee380f2a7cc009e470368f7520560a
specs:
rails-controller-testing (1.0.5)
actionpack (>= 5.0.1.rc1)
actionview (>= 5.0.1.rc1)
activesupport (>= 5.0.1.rc1)
PATH
remote: .
specs:
devise (4.4.0)
devise (4.7.3)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0, < 5.2)
railties (>= 4.1.0)
responders
warden (~> 1.2.3)
GEM
remote: https://rubygems.org/
specs:
actioncable (5.1.0)
actionpack (= 5.1.0)
actioncable (6.0.3.3)
actionpack (= 6.0.3.3)
nio4r (~> 2.0)
websocket-driver (~> 0.6.1)
actionmailer (5.1.0)
actionpack (= 5.1.0)
actionview (= 5.1.0)
activejob (= 5.1.0)
websocket-driver (>= 0.6.1)
actionmailbox (6.0.3.3)
actionpack (= 6.0.3.3)
activejob (= 6.0.3.3)
activerecord (= 6.0.3.3)
activestorage (= 6.0.3.3)
activesupport (= 6.0.3.3)
mail (>= 2.7.1)
actionmailer (6.0.3.3)
actionpack (= 6.0.3.3)
actionview (= 6.0.3.3)
activejob (= 6.0.3.3)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.1.0)
actionview (= 5.1.0)
activesupport (= 5.1.0)
rack (~> 2.0)
rack-test (~> 0.6.3)
actionpack (6.0.3.3)
actionview (= 6.0.3.3)
activesupport (= 6.0.3.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.1.0)
activesupport (= 5.1.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (6.0.3.3)
actionpack (= 6.0.3.3)
activerecord (= 6.0.3.3)
activestorage (= 6.0.3.3)
activesupport (= 6.0.3.3)
nokogiri (>= 1.8.5)
actionview (6.0.3.3)
activesupport (= 6.0.3.3)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.1.0)
activesupport (= 5.1.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (6.0.3.3)
activesupport (= 6.0.3.3)
globalid (>= 0.3.6)
activemodel (5.1.0)
activesupport (= 5.1.0)
activerecord (5.1.0)
activemodel (= 5.1.0)
activesupport (= 5.1.0)
arel (~> 8.0)
activesupport (5.1.0)
activemodel (6.0.3.3)
activesupport (= 6.0.3.3)
activerecord (6.0.3.3)
activemodel (= 6.0.3.3)
activesupport (= 6.0.3.3)
activestorage (6.0.3.3)
actionpack (= 6.0.3.3)
activejob (= 6.0.3.3)
activerecord (= 6.0.3.3)
marcel (~> 0.3.1)
activesupport (6.0.3.3)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
arel (8.0.0)
bcrypt (3.1.11)
builder (3.2.3)
concurrent-ruby (1.0.5)
erubi (1.6.0)
faraday (0.11.0)
zeitwerk (~> 2.2, >= 2.2.2)
bcrypt (3.1.16)
builder (3.2.4)
concurrent-ruby (1.1.7)
crass (1.0.6)
erubi (1.9.0)
faraday (1.0.1)
multipart-post (>= 1.2, < 3)
globalid (0.4.0)
globalid (0.4.2)
activesupport (>= 4.2.0)
hashie (3.5.5)
i18n (0.8.1)
jwt (1.5.6)
loofah (2.0.3)
hashie (4.1.0)
i18n (1.8.5)
concurrent-ruby (~> 1.0)
jwt (2.2.2)
loofah (2.7.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.6.5)
mime-types (>= 1.16, < 4)
metaclass (0.0.4)
method_source (0.8.2)
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_portile2 (2.1.0)
minitest (5.10.1)
mocha (1.2.1)
metaclass (~> 0.0.1)
multi_json (1.12.1)
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.2)
mocha (1.11.2)
multi_json (1.15.0)
multi_xml (0.6.0)
multipart-post (2.0.0)
nio4r (2.0.0)
nokogiri (1.7.1)
mini_portile2 (~> 2.1.0)
oauth2 (1.3.1)
faraday (>= 0.8, < 0.12)
jwt (~> 1.0)
multipart-post (2.1.1)
nio4r (2.5.4)
nokogiri (1.10.10)
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.6.1)
hashie (>= 3.4.6, < 3.6.0)
omniauth (1.9.1)
hashie (>= 3.4.6)
rack (>= 1.6.2, < 3)
omniauth-facebook (4.0.0)
omniauth-facebook (7.0.0)
omniauth-oauth2 (~> 1.2)
omniauth-oauth2 (1.4.0)
oauth2 (~> 1.0)
omniauth (~> 1.2)
omniauth-oauth2 (1.7.0)
oauth2 (~> 1.4)
omniauth (~> 1.9)
omniauth-openid (1.0.1)
omniauth (~> 1.0)
rack-openid (~> 1.3.1)
orm_adapter (0.5.0)
rack (2.0.1)
rack (2.2.3)
rack-openid (1.3.1)
rack (>= 1.1.0)
ruby-openid (>= 2.1.8)
rack-test (0.6.3)
rack (>= 1.0)
rails (5.1.0)
actioncable (= 5.1.0)
actionmailer (= 5.1.0)
actionpack (= 5.1.0)
actionview (= 5.1.0)
activejob (= 5.1.0)
activemodel (= 5.1.0)
activerecord (= 5.1.0)
activesupport (= 5.1.0)
bundler (>= 1.3.0, < 2.0)
railties (= 5.1.0)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (6.0.3.3)
actioncable (= 6.0.3.3)
actionmailbox (= 6.0.3.3)
actionmailer (= 6.0.3.3)
actionpack (= 6.0.3.3)
actiontext (= 6.0.3.3)
actionview (= 6.0.3.3)
activejob (= 6.0.3.3)
activemodel (= 6.0.3.3)
activerecord (= 6.0.3.3)
activestorage (= 6.0.3.3)
activesupport (= 6.0.3.3)
bundler (>= 1.3.0)
railties (= 6.0.3.3)
sprockets-rails (>= 2.0.0)
rails-controller-testing (1.0.1)
actionpack (~> 5.x)
actionview (~> 5.x)
activesupport (~> 5.x)
rails-dom-testing (2.0.2)
activesupport (>= 4.2.0, < 6.0)
nokogiri (~> 1.6)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
railties (5.1.0)
actionpack (= 5.1.0)
activesupport (= 5.1.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
railties (6.0.3.3)
actionpack (= 6.0.3.3)
activesupport (= 6.0.3.3)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (12.0.0)
rdoc (5.1.0)
responders (2.4.0)
actionpack (>= 4.2.0, < 5.3)
railties (>= 4.2.0, < 5.3)
ruby-openid (2.7.0)
sprockets (3.7.1)
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.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.0)
sprockets-rails (3.2.2)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.3.13)
thor (0.19.4)
sqlite3 (1.4.2)
thor (1.0.1)
thread_safe (0.3.6)
tzinfo (1.2.3)
timecop (0.9.1)
tzinfo (1.2.7)
thread_safe (~> 0.1)
warden (1.2.7)
rack (>= 1.0)
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.6.5)
websocket-driver (0.7.3)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2)
websocket-extensions (0.1.5)
zeitwerk (2.4.0)
PLATFORMS
ruby
DEPENDENCIES
activemodel-serializers-xml!
activerecord-jdbc-adapter
activerecord-jdbcsqlite3-adapter
devise!
jruby-openssl
mocha (~> 1.1)
oauth2
omniauth (~> 1.3)
omniauth
omniauth-facebook
omniauth-oauth2
omniauth-openid
rails (~> 5.1)
rails-controller-testing
rails (~> 6.0.0)
rails-controller-testing!
rdoc
responders (~> 2.1)
sqlite3
responders (~> 3.0)
sqlite3 (~> 1.4)
timecop
webrat (= 0.7.3)
BUNDLED WITH
1.15.3
1.17.3

View File

@@ -1,7 +1,8 @@
## Precheck
## Pre-check
- Do not use the issues tracker for help or support, try Stack Overflow.
- For bugs, do a quick search and make sure the bug has not yet been reported
- If you found a security bug, do not report it through GitHub. Please send an e-mail to heartcombo@googlegroups.com instead.
- Finally, be nice and have fun!
## Environment
@@ -12,7 +13,7 @@
## Current behavior
Include code samples, errors, steps to reproduce the error and stacktraces if appropriate.
Include code samples, errors, steps to reproduce the error and stack traces if appropriate.
Will be even more helpful if you provide a sample application or a test case that reproduces the error.

View File

@@ -1,4 +1,5 @@
Copyright 2009-2017 Plataformatec. http://plataformatec.com.br
Copyright 2020 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
a copy of this software and associated documentation files (the

182
README.md
View File

@@ -1,11 +1,7 @@
![Devise Logo](https://raw.github.com/plataformatec/devise/master/devise.png)
![Devise Logo](https://raw.github.com/heartcombo/devise/master/devise.png)
By [Plataformatec](http://plataformatec.com.br/).
[![Build Status](https://api.travis-ci.org/plataformatec/devise.svg?branch=master)](http://travis-ci.org/plataformatec/devise)
[![Code Climate](https://codeclimate.com/github/plataformatec/devise.svg)](https://codeclimate.com/github/plataformatec/devise)
This README is [also available in a friendly navigable format](http://devise.plataformatec.com.br/).
[![Build Status](https://api.travis-ci.org/heartcombo/devise.svg?branch=master)](http://travis-ci.org/heartcombo/devise)
[![Code Climate](https://codeclimate.com/github/heartcombo/devise.svg)](https://codeclimate.com/github/heartcombo/devise)
Devise is a flexible authentication solution for Rails based on Warden. It:
@@ -16,16 +12,16 @@ Devise is a flexible authentication solution for Rails based on Warden. It:
It's composed of 10 modules:
* [Database Authenticatable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/DatabaseAuthenticatable): hashes and stores a password in the database to validate the authenticity of a user while signing in. The authentication can be done both through POST requests or HTTP Basic Authentication.
* [Omniauthable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Omniauthable): adds OmniAuth (https://github.com/omniauth/omniauth) support.
* [Confirmable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Confirmable): sends emails with confirmation instructions and verifies whether an account is already confirmed during sign in.
* [Recoverable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Recoverable): resets the user password and sends reset instructions.
* [Registerable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Registerable): handles signing up users through a registration process, also allowing them to edit and destroy their account.
* [Rememberable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Rememberable): manages generating and clearing a token for remembering the user from a saved cookie.
* [Trackable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Trackable): tracks sign in count, timestamps and IP address.
* [Timeoutable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Timeoutable): expires sessions that have not been active in a specified period of time.
* [Validatable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Validatable): provides validations of email and password. It's optional and can be customized, so you're able to define your own validations.
* [Lockable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Lockable): locks an account after a specified number of failed sign-in attempts. Can unlock via email or after a specified time period.
* [Database Authenticatable](http://www.rubydoc.info/github/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.
## Table of Contents
@@ -53,16 +49,11 @@ It's composed of 10 modules:
- [Integration tests](#integration-tests)
- [OmniAuth](#omniauth)
- [Configuring multiple models](#configuring-multiple-models)
- [Create a migration with the required fields](#create-a-migration-with-the-required-fields)
- [Inside your Admin model](#inside-your-admin-model)
- [Inside your routes](#inside-your-routes)
- [Inside your protected controller](#inside-your-protected-controller)
- [Inside your controllers and views](#inside-your-controllers-and-views)
- [ActiveJob Integration](#activejob-integration)
- [Password reset tokens and Rails logs](#password-reset-tokens-and-rails-logs)
- [Other ORMs](#other-orms)
- [Rails API mode](#rails-api-mode)
- [Additional information](#additional-information)
- [Heroku](#heroku)
- [Warden](#warden)
- [Contributors](#contributors)
- [License](#license)
@@ -77,15 +68,15 @@ It's composed of 10 modules:
The Devise Wiki has lots of additional information about Devise including many "how-to" articles and answers to the most frequently asked questions. Please browse the Wiki after finishing this README:
https://github.com/plataformatec/devise/wiki
https://github.com/heartcombo/devise/wiki
### Bug reports
If you discover a problem with Devise, we would like to know about it. However, we ask that you please review these guidelines before submitting a bug report:
https://github.com/plataformatec/devise/wiki/Bug-reports
https://github.com/heartcombo/devise/wiki/Bug-reports
If you have discovered a security related bug, please do *NOT* use the GitHub issue tracker. Send an email to opensource@plataformatec.com.br.
If you have discovered a security related bug, please do *NOT* use the GitHub issue tracker. Send an email to heartcombo@googlegroups.com.
### StackOverflow and Mailing List
@@ -101,7 +92,7 @@ https://groups.google.com/group/plataformatec-devise
You can view the Devise documentation in RDoc format here:
http://rubydoc.info/github/plataformatec/devise/master/frames
http://rubydoc.info/github/heartcombo/devise/master/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.
@@ -109,35 +100,82 @@ If you need to use Devise with previous versions of Rails, you can always run "g
There are a few example applications available on GitHub that demonstrate various features of Devise with different versions of Rails. You can view them here:
https://github.com/plataformatec/devise/wiki/Example-Applications
https://github.com/heartcombo/devise/wiki/Example-Applications
### Extensions
Our community has created a number of extensions that add functionality above and beyond what is included with Devise. You can view a list of available extensions and add your own here:
https://github.com/plataformatec/devise/wiki/Extensions
https://github.com/heartcombo/devise/wiki/Extensions
### Contributing
We hope that you will consider contributing to Devise. Please read this short overview for some information about how to get started:
https://github.com/plataformatec/devise/wiki/Contributing
https://github.com/heartcombo/devise/wiki/Contributing
You will usually want to write tests for your changes. To run the test suite, go into Devise's top-level directory and run "bundle install" and "rake". For the tests to pass, you will need to have a MongoDB server (version 2.0 or newer) running on your system.
You will usually want to write tests for your changes. To run the test suite, go into Devise's top-level directory and run `bundle install` and `bin/test`.
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`:
```
DEVISE_ORM=mongoid bin/test
==> Devise.orm = :mongoid
```
When running the tests for Mongoid, you will need to have a MongoDB server (version 2.0 or newer) running on your system.
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.
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
BUNDLE_GEMFILE=gemfiles/Gemfile.rails-4.1-stable bundle install
BUNDLE_GEMFILE=gemfiles/Gemfile.rails-4.1-stable bin/test
```
You can also combine both of them if the tests broke for Mongoid:
```bash
BUNDLE_GEMFILE=gemfiles/Gemfile.rails-4.1-stable bundle install
BUNDLE_GEMFILE=gemfiles/Gemfile.rails-4.1-stable DEVISE_ORM=mongoid bin/test
```
### Running tests
Devise uses [Mini Test](https://github.com/seattlerb/minitest) as test framework.
* Running all tests:
```bash
bin/test
```
* Running tests for an specific file:
```bash
bin/test test/models/trackable_test.rb
```
* Running a specific test given a regex:
```bash
bin/test test/models/trackable_test.rb:16
```
## Starting with Rails?
If you are building your first Rails application, we recommend you *do not* use Devise. Devise requires a good understanding of the Rails Framework. In such cases, we advise you to start a simple authentication system from scratch. Today, we have three resources that should help you get started:
If you are building your first Rails application, we recommend you *do not* use Devise. Devise requires a good understanding of the Rails Framework. In such cases, we advise you to start a simple authentication system from scratch. Here's a few resources that should help you get started:
* Michael Hartl's online book: https://www.railstutorial.org/book/modeling_users
* Ryan Bates' Railscast: http://railscasts.com/episodes/250-authentication-from-scratch
* Codecademy's Ruby on Rails: Authentication and Authorization: http://www.codecademy.com/en/learn/rails-auth
* Ryan Bates' Railscasts: http://railscasts.com/episodes/250-authentication-from-scratch and http://railscasts.com/episodes/250-authentication-from-scratch-revised
* Codecademy's Ruby on Rails: Authentication and Authorization: https://www.codecademy.com/learn/rails-auth
Once you have solidified your understanding of Rails and authentication mechanisms, we assure you Devise will be very pleasant to work with. :smiley:
## Getting started
Devise 4.0 works with Rails 4.1 onwards. You can add it to your Gemfile with:
Devise 4.0 works with Rails 4.1 onwards. Add the following line to your Gemfile:
```ruby
gem 'devise'
@@ -166,7 +204,7 @@ In the following command you will replace `MODEL` with the class name used for t
$ rails generate devise MODEL
```
Next, check the MODEL for any additional configuration options you might want to add, such as confirmable or lockable. If you add an option, be sure to inspect the migration file (created by the generator if your ORM supports them) and uncomment the appropriate section. For example, if you add the confirmable option in the model, you'll need to uncomment the Confirmable section in the migration.
Next, check the MODEL for any additional configuration options you might want to add, such as confirmable or lockable. If you add an option, be sure to inspect the migration file (created by the generator if your ORM supports them) and uncomment the appropriate section. For example, if you add the confirmable option in the model, you'll need to uncomment the Confirmable section in the migration.
Then run `rails db:migrate`
@@ -227,16 +265,16 @@ member_session
The Devise method in your models also accepts some options to configure its modules. For example, you can choose the cost of the hashing algorithm with:
```ruby
devise :database_authenticatable, :registerable, :confirmable, :recoverable, stretches: 12
devise :database_authenticatable, :registerable, :confirmable, :recoverable, stretches: 13
```
Besides `:stretches`, you can define `:pepper`, `:encryptor`, `:confirm_within`, `:remember_for`, `:timeout_in`, `:unlock_in` among other options. For more details, see the initializer file that was created when you invoked the "devise:install" generator described above. This file is usually located at `/config/initializers/devise.rb`.
### Strong Parameters
![The Parameter Sanitizer API has changed for Devise 4](http://messages.hellobits.com/warning.svg?message=The%20Parameter%20Sanitizer%20API%20has%20changed%20for%20Devise%204)
The Parameter Sanitizer API has changed for Devise 4 :warning:
*For previous Devise versions see https://github.com/plataformatec/devise/tree/3-stable#strong-parameters*
*For previous Devise versions see https://github.com/heartcombo/devise/tree/3-stable#strong-parameters*
When you customize your own views, you may end up adding new attributes to forms. Rails 4 moved the parameter sanitization from the model to the controller, causing Devise to handle this concern at the controller as well.
@@ -246,7 +284,7 @@ There are just three actions in Devise that allow any set of parameters to be pa
* `sign_up` (`Devise::RegistrationsController#create`) - Permits authentication keys plus `password` and `password_confirmation`
* `account_update` (`Devise::RegistrationsController#update`) - Permits authentication keys plus `password`, `password_confirmation` and `current_password`
In case you want to permit additional parameters (the lazy way™), you can do so using a simple before filter in your `ApplicationController`:
In case you want to permit additional parameters (the lazy way™), you can do so using a simple before action in your `ApplicationController`:
```ruby
class ApplicationController < ActionController::Base
@@ -274,7 +312,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
@@ -375,6 +413,7 @@ If the customization at the views level is not enough, you can customize each co
...
end
```
(Use the -c flag to specify a controller, for example: `rails generate devise:controllers users -c=sessions`)
2. Tell the router to use this controller:
@@ -396,7 +435,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
@@ -420,7 +459,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/plataformatec/devise/master/ActionDispatch/Routing/Mapper%3Adevise_for) for details.
Be sure to check `devise_for` [documentation](http://www.rubydoc.info/github/heartcombo/devise/master/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:
@@ -476,7 +515,7 @@ en:
Take a look at our locale file to check all available messages. You may also be interested in one of the many translations that are available on our wiki:
https://github.com/plataformatec/devise/wiki/I18n
https://github.com/heartcombo/devise/wiki/I18n
Caution: Devise Controllers inherit from ApplicationController. If your app uses multiple locales, you should be sure to set I18n.locale in ApplicationController.
@@ -488,12 +527,21 @@ cases/specs.
### Controller tests
Controller tests require that you include `Devise::Test::ControllerHelpers` on
Controller tests require that you include `Devise::Test::IntegrationHelpers` on
your test case or its parent `ActionController::TestCase` superclass.
For Rails versions prior to 5, include `Devise::Test::ControllerHelpers` instead, since the superclass
for controller tests was changed to ActionDispatch::IntegrationTest
(for more details, see the [Integration tests](#integration-tests) section).
```ruby
class PostsControllerTest < ActionController::TestCase
include Devise::Test::ControllerHelpers
include Devise::Test::IntegrationHelpers # Rails >= 5
end
```
```ruby
class PostsControllerTest < ActionController::TestCase
include Devise::Test::ControllerHelpers # Rails < 5
end
```
@@ -573,7 +621,7 @@ are executed in your tests.
You can read more about testing your Rails 3 - Rails 4 controllers with RSpec in the wiki:
* https://github.com/plataformatec/devise/wiki/How-To:-Test-controllers-with-Rails-3-and-4-%28and-RSpec%29
* https://github.com/heartcombo/devise/wiki/How-To:-Test-controllers-with-Rails-(and-RSpec)
### OmniAuth
@@ -585,7 +633,7 @@ config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
You can read more about OmniAuth support in the wiki:
* https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview
* https://github.com/heartcombo/devise/wiki/OmniAuth:-Overview
### Configuring multiple models
@@ -632,7 +680,7 @@ end
### Password reset tokens and Rails logs
If you enable the [Recoverable](http://rubydoc.info/github/plataformatec/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/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:
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.
@@ -648,32 +696,50 @@ config.log_level = :warn
Devise supports ActiveRecord (default) and Mongoid. To select another ORM, simply require it in the initializer file.
## Additional information
### Rails API Mode
### Heroku
Rails 5+ has a built-in [API Mode](https://edgeguides.rubyonrails.org/api_app.html) which optimizes Rails for use as an API (only). Devise is _somewhat_ able to handle applications that are built in this mode without additional modifications in the sense that it should not raise exceptions and the like. But some issues may still arise during `development`/`testing`, as we still don't know the full extent of this compatibility. (For more information, see [issue #4947](https://github.com/heartcombo/devise/issues/4947/))
Using Devise on Heroku with Ruby on Rails 3.2 requires setting:
#### Supported Authentication Strategies
API-only applications don't support browser-based authentication via cookies, which is devise's default. Yet, devise can still provide authentication out of the box in those cases with the `http_authenticatable` strategy, which uses HTTP Basic Auth and authenticates the user on each request. (For more info, see this wiki article for [How To: Use HTTP Basic Authentication](https://github.com/heartcombo/devise/wiki/How-To:-Use-HTTP-Basic-Authentication))
The devise default for HTTP Auth is disabled, so it will need to be enabled in the devise initializer for the database strategy:
```ruby
config.assets.initialize_on_precompile = false
config.http_authenticatable = [:database]
```
Read more about the potential issues at http://guides.rubyonrails.org/asset_pipeline.html
This restriction does not limit you from implementing custom warden strategies, either in your application or via gem-based extensions for devise.
A common authentication strategy for APIs is token-based authentication. For more information on extending devise to support this type of authentication and others, see the wiki article for [Simple Token Authentication Examples and alternatives](https://github.com/heartcombo/devise/wiki/How-To:-Simple-Token-Authentication-Example#alternatives) or this blog post on [Custom authentication methods with Devise](http://blog.plataformatec.com.br/2019/01/custom-authentication-methods-with-devise/).
#### Testing
API Mode changes the order of the middleware stack, and this can cause problems for `Devise::Test::IntegrationHelpers`. This problem usually surfaces as an ```undefined method `[]=' for nil:NilClass``` error when using integration test helpers, such as `#sign_in`. The solution is simply to reorder the middlewares by adding the following to test.rb:
```ruby
Rails.application.config.middleware.insert_before Warden::Manager, ActionDispatch::Cookies
Rails.application.config.middleware.insert_before Warden::Manager, ActionDispatch::Session::CookieStore
```
For a deeper understanding of this, review [this issue](https://github.com/heartcombo/devise/issues/4696).
Additionally be mindful that without views supported, some email-based flows from Confirmable, Recoverable and Lockable are not supported directly at this time.
## Additional information
### Warden
Devise is based on Warden, which is a general Rack authentication framework created by Daniel Neighman. We encourage you to read more about Warden here:
https://github.com/hassox/warden
https://github.com/wardencommunity/warden
### Contributors
We have a long list of valued contributors. Check them all at:
https://github.com/plataformatec/devise/graphs/contributors
https://github.com/heartcombo/devise/graphs/contributors
## License
MIT License. Copyright 2009-2017 Plataformatec. http://plataformatec.com.br
MIT License. Copyright 2020 Rafael França, Leonardo Tegon, Carlos Antônio da Silva. Copyright 2009-2019 Plataformatec.
You are not granted rights or licenses to the trademarks of Plataformatec, including without limitation the Devise name or logo.
The Devise logo is licensed under [Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License](https://creativecommons.org/licenses/by-nc-nd/4.0/).

View File

@@ -39,6 +39,7 @@ class Devise::PasswordsController < DeviseController
if Devise.sign_in_after_reset_password
flash_message = resource.active_for_authentication? ? :updated : :updated_not_active
set_flash_message!(:notice, flash_message)
resource.after_database_authentication
sign_in(resource_name, resource)
else
set_flash_message!(:notice, :updated_not_active)

View File

@@ -50,12 +50,9 @@ class Devise::RegistrationsController < DeviseController
resource_updated = update_resource(resource, account_update_params)
yield resource if block_given?
if resource_updated
if is_flashing_format?
flash_key = update_needs_confirmation?(resource, prev_unconfirmed_email) ?
:update_needs_confirmation : :updated
set_flash_message :notice, flash_key
end
bypass_sign_in resource, scope: resource_name
set_flash_message_for_update(resource, prev_unconfirmed_email)
bypass_sign_in resource, scope: resource_name if sign_in_after_change_password?
respond_with resource, location: after_update_path_for(resource)
else
clean_up_passwords resource
@@ -112,7 +109,7 @@ class Devise::RegistrationsController < DeviseController
# The path used after sign up. You need to overwrite this method
# in your own RegistrationsController.
def after_sign_up_path_for(resource)
after_sign_in_path_for(resource)
after_sign_in_path_for(resource) if is_navigational_format?
end
# The path used after sign up for inactive accounts. You need to overwrite
@@ -127,7 +124,7 @@ class Devise::RegistrationsController < DeviseController
# The default url to be used after updating a resource. You need to overwrite
# this method in your own RegistrationsController.
def after_update_path_for(resource)
signed_in_root_path(resource)
sign_in_after_change_password? ? signed_in_root_path(resource) : new_session_path(resource_name)
end
# Authenticates the current scope and gets the current resource from the session.
@@ -147,4 +144,25 @@ class Devise::RegistrationsController < DeviseController
def translation_scope
'devise.registrations'
end
private
def set_flash_message_for_update(resource, prev_unconfirmed_email)
return unless is_flashing_format?
flash_key = if update_needs_confirmation?(resource, prev_unconfirmed_email)
:update_needs_confirmation
elsif sign_in_after_change_password?
:updated
else
:updated_but_not_signed_in
end
set_flash_message :notice, flash_key
end
def sign_in_after_change_password?
return true if account_update_params[:password].blank?
Devise.sign_in_after_change_password
end
end

View File

@@ -22,7 +22,7 @@ class DeviseController < Devise.parent_controller.constantize
# Action Controller tests that forces _prefixes to be
# loaded before even having a request object.
#
# This method should be public as it is is in ActionPack
# This method should be public as it is in ActionPack
# itself. Changing its visibility may break other gems.
def _prefixes #:nodoc:
@_prefixes ||= if self.class.scoped_views? && request && devise_mapping
@@ -112,7 +112,7 @@ MESSAGE
end
if authenticated && resource = warden.user(resource_name)
flash[:alert] = I18n.t("devise.failure.already_authenticated")
set_flash_message(:alert, 'already_authenticated', scope: 'devise.failure')
redirect_to after_sign_in_path_for(resource)
end
end
@@ -184,7 +184,7 @@ MESSAGE
options[:default] = Array(options[:default]).unshift(kind.to_sym)
options[:resource_name] = resource_name
options = devise_i18n_options(options)
I18n.t("#{options[:resource_name]}.#{kind}", options)
I18n.t("#{options[:resource_name]}.#{kind}", **options)
end
# Controllers inheriting DeviseController are advised to override this

View File

@@ -1,27 +1,30 @@
# frozen_string_literal: true
module DeviseHelper
# A simple way to show error messages for the current devise resource. If you need
# to customize this method, you can either overwrite it in your application helpers or
# copy the views to your application.
#
# This method is intended to stay simple and it is unlikely that we are going to change
# it to add more behavior or options.
# Retain this method for backwards compatibility, deprecated in 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 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?
messages = resource.errors.full_messages.map { |msg| content_tag(:li, msg) }.join
sentence = I18n.t("errors.messages.not_saved",
count: resource.errors.count,
resource: resource.class.model_name.human.downcase)
html = <<-HTML
<div id="error_explanation">
<h2>#{sentence}</h2>
<ul>#{messages}</ul>
</div>
HTML
html.html_safe
render "devise/shared/error_messages", resource: resource
end
end

View File

@@ -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

View File

@@ -1,7 +1,7 @@
<h2>Resend confirmation instructions</h2>
<%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %>
<%= devise_error_messages! %>
<%= render "devise/shared/error_messages", resource: resource %>
<div class="field">
<%= f.label :email %><br />

View File

@@ -1,7 +1,7 @@
<h2>Change your password</h2>
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %>
<%= devise_error_messages! %>
<%= render "devise/shared/error_messages", resource: resource %>
<%= f.hidden_field :reset_password_token %>
<div class="field">
@@ -9,12 +9,12 @@
<% if @minimum_password_length %>
<em>(<%= @minimum_password_length %> characters minimum)</em><br />
<% end %>
<%= f.password_field :password, autofocus: true, autocomplete: "off" %>
<%= f.password_field :password, autofocus: true, autocomplete: "new-password" %>
</div>
<div class="field">
<%= f.label :password_confirmation, "Confirm new password" %><br />
<%= f.password_field :password_confirmation, autocomplete: "off" %>
<%= f.password_field :password_confirmation, autocomplete: "new-password" %>
</div>
<div class="actions">

View File

@@ -1,7 +1,7 @@
<h2>Forgot your password?</h2>
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %>
<%= devise_error_messages! %>
<%= render "devise/shared/error_messages", resource: resource %>
<div class="field">
<%= f.label :email %><br />

View File

@@ -1,7 +1,7 @@
<h2>Edit <%= resource_name.to_s.humanize %></h2>
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
<%= devise_error_messages! %>
<%= render "devise/shared/error_messages", resource: resource %>
<div class="field">
<%= f.label :email %><br />
@@ -14,7 +14,7 @@
<div class="field">
<%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
<%= f.password_field :password, autocomplete: "off" %>
<%= f.password_field :password, autocomplete: "new-password" %>
<% if @minimum_password_length %>
<br />
<em><%= @minimum_password_length %> characters minimum</em>
@@ -23,12 +23,12 @@
<div class="field">
<%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation, autocomplete: "off" %>
<%= f.password_field :password_confirmation, autocomplete: "new-password" %>
</div>
<div class="field">
<%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
<%= f.password_field :current_password, autocomplete: "off" %>
<%= f.password_field :current_password, autocomplete: "current-password" %>
</div>
<div class="actions">

View File

@@ -1,7 +1,7 @@
<h2>Sign up</h2>
<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<%= render "devise/shared/error_messages", resource: resource %>
<div class="field">
<%= f.label :email %><br />
@@ -13,12 +13,12 @@
<% if @minimum_password_length %>
<em>(<%= @minimum_password_length %> characters minimum)</em>
<% end %><br />
<%= f.password_field :password, autocomplete: "off" %>
<%= f.password_field :password, autocomplete: "new-password" %>
</div>
<div class="field">
<%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation, autocomplete: "off" %>
<%= f.password_field :password_confirmation, autocomplete: "new-password" %>
</div>
<div class="actions">

View File

@@ -8,15 +8,15 @@
<div class="field">
<%= f.label :password %><br />
<%= f.password_field :password, autocomplete: "off" %>
<%= f.password_field :password, autocomplete: "current-password" %>
</div>
<% if devise_mapping.rememberable? -%>
<% if devise_mapping.rememberable? %>
<div class="field">
<%= f.check_box :remember_me %>
<%= f.label :remember_me %>
</div>
<% end -%>
<% end %>
<div class="actions">
<%= f.submit "Log in" %>

View File

@@ -0,0 +1,15 @@
<% if resource.errors.any? %>
<div id="error_explanation">
<h2>
<%= I18n.t("errors.messages.not_saved",
count: resource.errors.count,
resource: resource.class.model_name.human.downcase)
%>
</h2>
<ul>
<% resource.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>

View File

@@ -1,25 +1,25 @@
<%- if controller_name != 'sessions' %>
<%= link_to "Log in", new_session_path(resource_name) %><br />
<% end -%>
<% end %>
<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
<%= link_to "Sign up", new_registration_path(resource_name) %><br />
<% end -%>
<% end %>
<%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %>
<%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
<% end -%>
<% end %>
<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
<% end -%>
<% end %>
<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
<%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br />
<% end -%>
<% end %>
<%- if devise_mapping.omniauthable? %>
<%- resource_class.omniauth_providers.each do |provider| %>
<%= link_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider) %><br />
<% end -%>
<% end -%>
<% end %>
<% end %>

View File

@@ -1,7 +1,7 @@
<h2>Resend unlock instructions</h2>
<%= form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| %>
<%= devise_error_messages! %>
<%= render "devise/shared/error_messages", resource: resource %>
<div class="field">
<%= f.label :email %><br />

View File

@@ -1,13 +1,17 @@
#!/usr/bin/env ruby
$: << File.expand_path(File.expand_path('../../test', __FILE__))
require 'bundler/setup'
# Remove this begin/rescue once Rails 4 support is removed.
begin
require 'rails/test_unit/minitest_plugin'
require 'bundler/setup'
require 'rails/test_unit/runner'
require 'rails/test_unit/reporter'
require 'rails/test_unit/line_filtering'
Rails::TestUnitReporter.executable = 'bin/test'
Rails::TestUnit::Runner.parse_options(ARGV)
Rails::TestUnit::Runner.run(ARGV)
rescue LoadError
exec 'rake'
end
Rails::TestUnitReporter.executable = 'bin/test'
exit Minitest.run(ARGV)

View File

@@ -1,4 +1,4 @@
# Additional translations at https://github.com/plataformatec/devise/wiki/I18n
# Additional translations at https://github.com/heartcombo/devise/wiki/I18n
en:
devise:
@@ -42,8 +42,9 @@ en:
signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated."
signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked."
signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account."
update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirm link to confirm your new email address."
update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirmation link to confirm your new email address."
updated: "Your account has been updated successfully."
updated_but_not_signed_in: "Your account has been updated successfully, but since your password was changed, you need to sign in again"
sessions:
signed_in: "Signed in successfully."
signed_out: "Signed out successfully."

View File

@@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-
# frozen_string_literal: true
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "devise/version"
@@ -10,19 +10,18 @@ Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.licenses = ["MIT"]
s.summary = "Flexible authentication solution for Rails with Warden"
s.email = "contact@plataformatec.com.br"
s.homepage = "https://github.com/plataformatec/devise"
s.email = "heartcombo@googlegroups.com"
s.homepage = "https://github.com/heartcombo/devise"
s.description = "Flexible authentication solution for Rails with Warden"
s.authors = ['José Valim', 'Carlos Antônio']
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- test/*`.split("\n")
s.files = Dir["{app,config,lib}/**/*", "CHANGELOG.md", "MIT-LICENSE", "README.md"]
s.require_paths = ["lib"]
s.required_ruby_version = '>= 2.1.0'
s.add_dependency("warden", "~> 1.2.3")
s.add_dependency("orm_adapter", "~> 0.1")
s.add_dependency("bcrypt", "~> 3.0")
s.add_dependency("railties", ">= 4.1.0", "< 5.2")
s.add_dependency("railties", ">= 4.1.0")
s.add_dependency("responders")
end

View File

@@ -8,10 +8,13 @@ gem "rails", github: "rails/rails", branch: "4-1-stable"
gem "omniauth"
gem "omniauth-oauth2"
gem "rdoc", "~> 5.1"
# Force this version because it's breaking on CI since a higher nokogiri version requires Ruby 2.3+.
gem "nokogiri", "1.9.1"
group :test do
gem "omniauth-facebook"
gem "omniauth-openid"
gem "timecop"
gem "webrat", "0.7.3", require: false
gem "mocha", "~> 1.1", require: false
gem 'test_after_commit', require: false
@@ -24,7 +27,7 @@ platforms :jruby do
end
platforms :ruby do
gem "sqlite3"
gem "sqlite3", "~> 1.3.6"
end
group :mongoid do

View File

@@ -1,5 +1,5 @@
GIT
remote: git://github.com/rails/rails.git
remote: https://github.com/rails/rails.git
revision: 0cad778c2605a5204a05a9f1dbd3344e39f248d8
branch: 4-1-stable
specs:
@@ -7,30 +7,6 @@ GIT
actionpack (= 4.1.16)
actionview (= 4.1.16)
mail (~> 2.5, >= 2.5.4)
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)
PATH
remote: ..
specs:
devise (4.4.0)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0, < 5.2)
responders
warden (~> 1.2.3)
GEM
remote: https://rubygems.org/
specs:
actionpack (4.1.16)
actionview (= 4.1.16)
activesupport (= 4.1.16)
@@ -53,29 +29,55 @@ GEM
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.3)
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.11)
bson (3.2.6)
builder (3.2.3)
concurrent-ruby (1.0.5)
connection_pool (2.2.1)
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 (0.11.0)
faraday (1.0.1)
multipart-post (>= 1.2, < 3)
hashie (3.5.5)
i18n (0.8.1)
hashie (3.6.0)
i18n (0.9.5)
concurrent-ruby (~> 1.0)
json (1.8.6)
jwt (1.5.6)
mail (2.6.4)
mime-types (>= 1.16, < 4)
metaclass (0.0.4)
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_portile2 (2.1.0)
minitest (5.10.1)
mocha (1.2.1)
metaclass (~> 0.0.1)
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)
@@ -85,30 +87,30 @@ GEM
bson (~> 3.0)
connection_pool (~> 2.0)
optionable (~> 0.2.0)
multi_json (1.12.1)
multi_json (1.14.1)
multi_xml (0.6.0)
multipart-post (2.0.0)
nokogiri (1.7.0.1)
mini_portile2 (~> 2.1.0)
oauth2 (1.3.1)
faraday (>= 0.8, < 0.12)
jwt (~> 1.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 (4.0.0)
omniauth-facebook (6.0.0)
omniauth-oauth2 (~> 1.2)
omniauth-oauth2 (1.4.0)
oauth2 (~> 1.0)
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.0)
origin (2.3.1)
orm_adapter (0.5.0)
rack (1.5.5)
rack-openid (1.3.1)
@@ -116,17 +118,12 @@ GEM
ruby-openid (>= 2.1.8)
rack-test (0.6.3)
rack (>= 1.0)
railties (4.1.16)
actionpack (= 4.1.16)
activesupport (= 4.1.16)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (12.0.0)
rake (13.0.1)
rdoc (5.1.0)
responders (1.1.2)
railties (>= 3.2, < 4.2)
ruby-openid (2.7.0)
sprockets (3.7.1)
ruby-openid (2.9.2)
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (2.3.3)
@@ -134,11 +131,12 @@ GEM
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
sqlite3 (1.3.13)
test_after_commit (1.1.0)
activerecord (>= 3.2)
thor (0.19.4)
test_after_commit (1.2.2)
activerecord (>= 3.2, < 5.0)
thor (1.0.1)
thread_safe (0.3.6)
tzinfo (1.2.2)
timecop (0.9.1)
tzinfo (1.2.7)
thread_safe (~> 0.1)
warden (1.2.7)
rack (>= 1.0)
@@ -157,15 +155,17 @@ DEPENDENCIES
jruby-openssl
mocha (~> 1.1)
mongoid (~> 4.0)
nokogiri (= 1.9.1)
omniauth
omniauth-facebook
omniauth-oauth2
omniauth-openid
rails!
rdoc (~> 5.1)
sqlite3
sqlite3 (~> 1.3.6)
test_after_commit
timecop
webrat (= 0.7.3)
BUNDLED WITH
1.15.3
1.17.3

View File

@@ -8,10 +8,12 @@ gem "rails", github: "rails/rails", branch: "4-2-stable"
gem "omniauth"
gem "omniauth-oauth2"
gem "rdoc", "~> 5.1"
gem "nokogiri", "1.9.1"
group :test do
gem "omniauth-facebook"
gem "omniauth-openid"
gem "timecop"
gem "webrat", "0.7.3", require: false
gem "mocha", "~> 1.1", require: false
gem 'test_after_commit', require: false
@@ -24,7 +26,7 @@ platforms :jruby do
end
platforms :ruby do
gem "sqlite3"
gem "sqlite3", "~> 1.3.6"
end
group :mongoid do

View File

@@ -1,66 +1,66 @@
GIT
remote: git://github.com/rails/rails.git
revision: dc3ae21802c316e1639239d28202db7aa7fb7cac
remote: https://github.com/rails/rails.git
revision: c0cb0cbf976a3cf8ad1b0e2d0f813602a712e997
branch: 4-2-stable
specs:
actionmailer (4.2.8)
actionpack (= 4.2.8)
actionview (= 4.2.8)
activejob (= 4.2.8)
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.8)
actionview (= 4.2.8)
activesupport (= 4.2.8)
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.8)
activesupport (= 4.2.8)
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.8)
activesupport (= 4.2.8)
activejob (4.2.11.3)
activesupport (= 4.2.11.3)
globalid (>= 0.3.0)
activemodel (4.2.8)
activesupport (= 4.2.8)
activemodel (4.2.11.3)
activesupport (= 4.2.11.3)
builder (~> 3.1)
activerecord (4.2.8)
activemodel (= 4.2.8)
activesupport (= 4.2.8)
activerecord (4.2.11.3)
activemodel (= 4.2.11.3)
activesupport (= 4.2.11.3)
arel (~> 6.0)
activesupport (4.2.8)
activesupport (4.2.11.3)
i18n (~> 0.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
rails (4.2.8)
actionmailer (= 4.2.8)
actionpack (= 4.2.8)
actionview (= 4.2.8)
activejob (= 4.2.8)
activemodel (= 4.2.8)
activerecord (= 4.2.8)
activesupport (= 4.2.8)
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.8)
railties (= 4.2.11.3)
sprockets-rails
railties (4.2.8)
actionpack (= 4.2.8)
activesupport (= 4.2.8)
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.4.0)
devise (4.7.3)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0, < 5.2)
railties (>= 4.1.0)
responders
warden (~> 1.2.3)
@@ -68,31 +68,30 @@ GEM
remote: https://rubygems.org/
specs:
arel (6.0.4)
bcrypt (3.1.11)
bson (3.2.6)
builder (3.2.3)
concurrent-ruby (1.0.5)
connection_pool (2.2.1)
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 (0.11.0)
faraday (1.0.1)
multipart-post (>= 1.2, < 3)
globalid (0.3.7)
activesupport (>= 4.1.0)
hashie (3.5.5)
i18n (0.8.1)
jwt (1.5.6)
loofah (2.0.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.6.4)
mime-types (>= 1.16, < 4)
metaclass (0.0.4)
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_portile2 (2.1.0)
minitest (5.10.1)
mocha (1.2.1)
metaclass (~> 0.0.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)
@@ -102,32 +101,32 @@ GEM
bson (~> 3.0)
connection_pool (~> 2.0)
optionable (~> 0.2.0)
multi_json (1.12.1)
multi_json (1.14.1)
multi_xml (0.6.0)
multipart-post (2.0.0)
nokogiri (1.7.0.1)
mini_portile2 (~> 2.1.0)
oauth2 (1.3.1)
faraday (>= 0.8, < 0.12)
jwt (~> 1.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.6.1)
hashie (>= 3.4.6, < 3.6.0)
omniauth (1.9.1)
hashie (>= 3.4.6)
rack (>= 1.6.2, < 3)
omniauth-facebook (4.0.0)
omniauth-facebook (6.0.0)
omniauth-oauth2 (~> 1.2)
omniauth-oauth2 (1.4.0)
oauth2 (~> 1.0)
omniauth (~> 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.0)
origin (2.3.1)
orm_adapter (0.5.0)
rack (1.6.5)
rack (1.6.13)
rack-openid (1.3.1)
rack (>= 1.1.0)
ruby-openid (>= 2.1.8)
@@ -135,31 +134,32 @@ GEM
rack (>= 1.0)
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.8)
activesupport (>= 4.2.0.beta, < 5.0)
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.0.3)
loofah (~> 2.0)
rake (12.0.0)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
rake (13.0.1)
rdoc (5.1.0)
responders (2.4.0)
actionpack (>= 4.2.0, < 5.3)
railties (>= 4.2.0, < 5.3)
ruby-openid (2.7.0)
sprockets (3.7.1)
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.0)
sprockets-rails (3.2.1)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.3.13)
test_after_commit (1.1.0)
activerecord (>= 3.2)
thor (0.19.4)
test_after_commit (1.2.2)
activerecord (>= 3.2, < 5.0)
thor (1.0.1)
thread_safe (0.3.6)
tzinfo (1.2.2)
timecop (0.9.1)
tzinfo (1.2.7)
thread_safe (~> 0.1)
warden (1.2.7)
rack (>= 1.0)
@@ -178,15 +178,17 @@ DEPENDENCIES
jruby-openssl
mocha (~> 1.1)
mongoid (~> 4.0)
nokogiri (= 1.9.1)
omniauth
omniauth-facebook
omniauth-oauth2
omniauth-openid
rails!
rdoc (~> 5.1)
sqlite3
sqlite3 (~> 1.3.6)
test_after_commit
timecop
webrat (= 0.7.3)
BUNDLED WITH
1.15.3
1.17.3

View File

@@ -18,13 +18,13 @@ gem "responders", "~> 2.1"
group :test do
gem "omniauth-facebook"
gem "omniauth-openid"
gem "timecop"
gem "webrat", "0.7.3", require: false
gem "mocha", "~> 1.1", require: false
gem 'test_after_commit', require: false
end
platforms :ruby do
gem "sqlite3"
gem "sqlite3", "~> 1.3.6"
end
# TODO:

View File

@@ -1,173 +1,171 @@
GIT
remote: git://github.com/rails/activemodel-serializers-xml.git
revision: dd9c0acf26aab111ebc647cd8deb99ebc6946531
remote: https://github.com/rails/activemodel-serializers-xml.git
revision: 93689638c28525acc65afb638fce866826532641
specs:
activemodel-serializers-xml (1.0.1)
activemodel (> 5.x)
activesupport (> 5.x)
activemodel-serializers-xml (1.0.2)
activemodel (>= 5.0.0.a)
activesupport (>= 5.0.0.a)
builder (~> 3.1)
PATH
remote: ..
specs:
devise (4.4.0)
devise (4.7.3)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0, < 5.2)
railties (>= 4.1.0)
responders
warden (~> 1.2.3)
GEM
remote: https://rubygems.org/
specs:
actioncable (5.0.2)
actionpack (= 5.0.2)
actioncable (5.0.7.2)
actionpack (= 5.0.7.2)
nio4r (>= 1.2, < 3.0)
websocket-driver (~> 0.6.1)
actionmailer (5.0.2)
actionpack (= 5.0.2)
actionview (= 5.0.2)
activejob (= 5.0.2)
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.2)
actionview (= 5.0.2)
activesupport (= 5.0.2)
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.2)
activesupport (= 5.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.2)
activesupport (= 5.0.2)
activejob (5.0.7.2)
activesupport (= 5.0.7.2)
globalid (>= 0.3.6)
activemodel (5.0.2)
activesupport (= 5.0.2)
activerecord (5.0.2)
activemodel (= 5.0.2)
activesupport (= 5.0.2)
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.2)
activesupport (5.0.7.2)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
arel (7.1.4)
bcrypt (3.1.11)
builder (3.2.3)
concurrent-ruby (1.0.5)
bcrypt (3.1.13)
builder (3.2.4)
concurrent-ruby (1.1.6)
crass (1.0.6)
erubis (2.7.0)
faraday (0.11.0)
faraday (1.0.1)
multipart-post (>= 1.2, < 3)
globalid (0.4.0)
globalid (0.4.2)
activesupport (>= 4.2.0)
hashie (3.5.5)
i18n (0.8.1)
jwt (1.5.6)
loofah (2.0.3)
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.6.5)
mime-types (>= 1.16, < 4)
metaclass (0.0.4)
method_source (0.8.2)
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_portile2 (2.1.0)
minitest (5.10.1)
mocha (1.2.1)
metaclass (~> 0.0.1)
multi_json (1.12.1)
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.0.0)
nio4r (2.0.0)
nokogiri (1.7.2)
mini_portile2 (~> 2.1.0)
oauth2 (1.3.1)
faraday (>= 0.8, < 0.12)
jwt (~> 1.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.6.1)
hashie (>= 3.4.6, < 3.6.0)
omniauth (1.9.1)
hashie (>= 3.4.6)
rack (>= 1.6.2, < 3)
omniauth-facebook (4.0.0)
omniauth-facebook (6.0.0)
omniauth-oauth2 (~> 1.2)
omniauth-oauth2 (1.4.0)
oauth2 (~> 1.0)
omniauth (~> 1.2)
omniauth-oauth2 (1.6.0)
oauth2 (~> 1.1)
omniauth (~> 1.9)
omniauth-openid (1.0.1)
omniauth (~> 1.0)
rack-openid (~> 1.3.1)
orm_adapter (0.5.0)
rack (2.0.2)
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.2)
actioncable (= 5.0.2)
actionmailer (= 5.0.2)
actionpack (= 5.0.2)
actionview (= 5.0.2)
activejob (= 5.0.2)
activemodel (= 5.0.2)
activerecord (= 5.0.2)
activesupport (= 5.0.2)
bundler (>= 1.3.0, < 2.0)
railties (= 5.0.2)
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.1)
actionpack (~> 5.x)
actionview (~> 5.x)
activesupport (~> 5.x)
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.0.3)
loofah (~> 2.0)
railties (5.0.2)
actionpack (= 5.0.2)
activesupport (= 5.0.2)
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 (12.0.0)
rdoc (5.1.0)
responders (2.4.0)
actionpack (>= 4.2.0, < 5.3)
railties (>= 4.2.0, < 5.3)
ruby-openid (2.7.0)
sprockets (3.7.1)
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.0)
sprockets-rails (3.2.1)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.3.13)
test_after_commit (1.1.0)
activerecord (>= 3.2)
thor (0.19.4)
thor (1.0.1)
thread_safe (0.3.6)
tzinfo (1.2.3)
timecop (0.9.1)
tzinfo (1.2.7)
thread_safe (~> 0.1)
warden (1.2.7)
rack (>= 1.0)
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.2)
websocket-extensions (0.1.5)
PLATFORMS
ruby
@@ -184,9 +182,9 @@ DEPENDENCIES
rails-controller-testing
rdoc
responders (~> 2.1)
sqlite3
test_after_commit
sqlite3 (~> 1.3.6)
timecop
webrat (= 0.7.3)
BUNDLED WITH
1.15.3
1.17.3

View File

@@ -0,0 +1,26 @@
source "https://rubygems.org"
gemspec path: ".."
gem "rails", '~> 5.1.0'
gem "omniauth"
gem "omniauth-oauth2"
gem "rdoc"
gem "activemodel-serializers-xml", github: "rails/activemodel-serializers-xml"
gem "rails-controller-testing"
gem "responders", "~> 2.1"
group :test do
gem "omniauth-facebook"
gem "omniauth-openid"
gem "timecop"
gem "webrat", "0.7.3", require: false
gem "mocha", "~> 1.1", require: false
end
platforms :ruby do
gem "sqlite3", "~> 1.3.6"
end

View File

@@ -0,0 +1,190 @@
GIT
remote: https://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.3)
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

View File

@@ -0,0 +1,26 @@
source "https://rubygems.org"
gemspec path: ".."
gem "rails", '~> 5.2.0'
gem "omniauth"
gem "omniauth-oauth2"
gem "rdoc"
gem "activemodel-serializers-xml", github: "rails/activemodel-serializers-xml"
gem "rails-controller-testing"
gem "responders", "~> 2.1"
group :test do
gem "omniauth-facebook"
gem "omniauth-openid"
gem "timecop"
gem "webrat", "0.7.3", require: false
gem "mocha", "~> 1.1", require: false
end
platforms :ruby do
gem "sqlite3", "~> 1.3.6"
end

View File

@@ -0,0 +1,198 @@
GIT
remote: https://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.3)
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

View File

@@ -0,0 +1,26 @@
source "https://rubygems.org"
gemspec path: ".."
gem "rails", '~> 6.0.0'
gem "omniauth"
gem "omniauth-oauth2"
gem "rdoc"
gem "activemodel-serializers-xml", github: "rails/activemodel-serializers-xml"
gem "rails-controller-testing", github: "rails/rails-controller-testing"
gem "responders", "~> 3.0"
group :test do
gem "omniauth-facebook"
gem "omniauth-openid"
gem "timecop"
gem "webrat", "0.7.3", require: false
gem "mocha", "~> 1.1", require: false
end
platforms :ruby do
gem "sqlite3", "~> 1.4"
end

View File

@@ -0,0 +1,219 @@
GIT
remote: https://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: https://github.com/rails/rails-controller-testing.git
revision: 4b15c86e82ee380f2a7cc009e470368f7520560a
specs:
rails-controller-testing (1.0.5)
actionpack (>= 5.0.1.rc1)
actionview (>= 5.0.1.rc1)
activesupport (>= 5.0.1.rc1)
PATH
remote: ..
specs:
devise (4.7.3)
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.2)
actionpack (= 6.0.3.2)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (6.0.3.2)
actionpack (= 6.0.3.2)
activejob (= 6.0.3.2)
activerecord (= 6.0.3.2)
activestorage (= 6.0.3.2)
activesupport (= 6.0.3.2)
mail (>= 2.7.1)
actionmailer (6.0.3.2)
actionpack (= 6.0.3.2)
actionview (= 6.0.3.2)
activejob (= 6.0.3.2)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (6.0.3.2)
actionview (= 6.0.3.2)
activesupport (= 6.0.3.2)
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.2)
actionpack (= 6.0.3.2)
activerecord (= 6.0.3.2)
activestorage (= 6.0.3.2)
activesupport (= 6.0.3.2)
nokogiri (>= 1.8.5)
actionview (6.0.3.2)
activesupport (= 6.0.3.2)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (6.0.3.2)
activesupport (= 6.0.3.2)
globalid (>= 0.3.6)
activemodel (6.0.3.2)
activesupport (= 6.0.3.2)
activerecord (6.0.3.2)
activemodel (= 6.0.3.2)
activesupport (= 6.0.3.2)
activestorage (6.0.3.2)
actionpack (= 6.0.3.2)
activejob (= 6.0.3.2)
activerecord (= 6.0.3.2)
marcel (~> 0.3.1)
activesupport (6.0.3.2)
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.15)
builder (3.2.4)
concurrent-ruby (1.1.7)
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.5)
concurrent-ruby (~> 1.0)
jwt (2.2.1)
loofah (2.6.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.15.0)
multi_xml (0.6.0)
multipart-post (2.1.1)
nio4r (2.5.2)
nokogiri (1.10.10)
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.3)
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.2)
actioncable (= 6.0.3.2)
actionmailbox (= 6.0.3.2)
actionmailer (= 6.0.3.2)
actionpack (= 6.0.3.2)
actiontext (= 6.0.3.2)
actionview (= 6.0.3.2)
activejob (= 6.0.3.2)
activemodel (= 6.0.3.2)
activerecord (= 6.0.3.2)
activestorage (= 6.0.3.2)
activesupport (= 6.0.3.2)
bundler (>= 1.3.0)
railties (= 6.0.3.2)
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.2)
actionpack (= 6.0.3.2)
activesupport (= 6.0.3.2)
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.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.1)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.4.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.3)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
zeitwerk (2.4.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

View File

@@ -76,7 +76,7 @@ end
class TestController < ApplicationController
include Rails.application.routes.url_helpers
before_filter :authenticate_user!
before_action :authenticate_user!
def index
render plain: 'Home'

9
lib/devise.rb Executable file → Normal file
View File

@@ -18,6 +18,7 @@ module Devise
autoload :TestHelpers, 'devise/test_helpers'
autoload :TimeInflector, 'devise/time_inflector'
autoload :TokenGenerator, 'devise/token_generator'
autoload :SecretKeyFinder, 'devise/secret_key_finder'
module Controllers
autoload :Helpers, 'devise/controllers/helpers'
@@ -70,7 +71,7 @@ module Devise
# The number of times to hash the password.
mattr_accessor :stretches
@@stretches = 11
@@stretches = 12
# The default key used when authenticating over http auth.
mattr_accessor :http_authentication_key
@@ -292,9 +293,9 @@ module Devise
mattr_accessor :token_generator
@@token_generator = nil
def self.rails51? # :nodoc:
Rails.gem_version >= Gem::Version.new("5.1.x")
end
# When set to false, changing a password does not automatically sign in a user
mattr_accessor :sign_in_after_change_password
@@sign_in_after_change_password = true
def self.activerecord51? # :nodoc:
defined?(ActiveRecord) && ActiveRecord.gem_version >= Gem::Version.new("5.1.x")

View File

@@ -12,11 +12,6 @@ module Devise
if respond_to?(:helper_method)
helper_method :warden, :signed_in?, :devise_controller?
end
def append_info_to_payload(payload)
super
payload[:status] ||= 401 unless payload[:exception]
end
end
module ClassMethods
@@ -41,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)
@@ -62,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
@@ -83,6 +78,11 @@ module Devise
end
METHODS
end
def log_process_action(payload)
payload[:status] ||= 401 unless payload[:exception]
super
end
end
# Define authentication filters and accessor helpers based on mappings.
@@ -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
@@ -268,7 +268,7 @@ module Devise
# Check if flash messages should be emitted. Default is to do it on
# navigational formats
def is_flashing_format?
is_navigational_format?
request.respond_to?(:flash) && is_navigational_format?
end
private

View File

@@ -6,8 +6,11 @@ module Devise
# Included by default in all controllers.
module SignInOut
# Return true if the given scope is signed in session. If no scope given, return
# true if any scope is signed in. Does not run authentication hooks.
def signed_in?(scope=nil)
# true if any scope is signed in. This will run authentication hooks, which may
# 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)
[scope || Devise.mappings.keys].flatten.any? do |_scope|
warden.authenticate?(scope: _scope)
end
@@ -16,6 +19,9 @@ module Devise
# Sign in a user that already was authenticated. This helper is useful for logging
# users in after sign up. All options given to sign_in is passed forward
# to the set_user method in warden.
# If you are using a custom warden strategy and the timeoutable module, you have to
# set `env["devise.skip_timeout"] = true` in the request to use this method, like we do
# in the sessions controller: https://github.com/heartcombo/devise/blob/master/app/controllers/devise/sessions_controller.rb#L7
#
# Examples:
#
@@ -71,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
@@ -86,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

View File

@@ -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)

View File

@@ -71,7 +71,6 @@ 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)
end
@@ -107,7 +106,7 @@ module Devise
options[:authentication_keys] = keys.join(I18n.translate(:"support.array.words_connector"))
options = i18n_options(options)
I18n.t(:"#{scope}.#{message}", options)
I18n.t(:"#{scope}.#{message}", **options)
else
message.to_s
end
@@ -144,11 +143,20 @@ module Devise
opts[:format] = request_format unless skip_format?
opts[:script_name] = relative_url_root if relative_url_root?
router_name = Devise.mappings[scope].router_name || Devise.available_router_name
context = send(router_name)
if relative_url_root?
opts[:script_name] = relative_url_root
# We need to add the rootpath to `script_name` manually for applications that use a Rails
# version lower than 5.1. Otherwise, it is going to generate a wrong path for Engines
# that use Devise. Remove it when the support of Rails 5.0 is dropped.
elsif root_path_defined?(context) && !rails_51_and_up?
rootpath = context.routes.url_helpers.root_path
opts[:script_name] = rootpath.chomp('/') if rootpath.length > 1
end
if context.respond_to?(route)
context.send(route, opts)
elsif respond_to?(:root_url)
@@ -242,7 +250,7 @@ module Devise
# Check if flash messages should be emitted. Default is to do it on
# navigational formats
def is_flashing_format?
is_navigational_format?
request.respond_to?(:flash) && is_navigational_format?
end
def request_format
@@ -260,5 +268,17 @@ module Devise
def relative_url_root?
relative_url_root.present?
end
ActiveSupport.run_load_hooks(:devise_failure_app, self)
private
def root_path_defined?(context)
defined?(context.routes) && context.routes.url_helpers.respond_to?(:root_path)
end
def rails_51_and_up?
Rails.gem_version >= Gem::Version.new("5.1")
end
end
end

View File

@@ -21,8 +21,8 @@ Warden::Manager.after_set_user do |record, warden, options|
proxy = Devise::Hooks::Proxy.new(warden)
if record.timedout?(last_request_at) &&
!env['devise.skip_timeout'] &&
if !env['devise.skip_timeout'] &&
record.timedout?(last_request_at) &&
!proxy.remember_me_is_active?(record)
Devise.sign_out_all_scopes ? proxy.sign_out : proxy.sign_out(scope)
throw :warden, scope: scope, message: :timeout

View File

@@ -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

View File

@@ -1,6 +1,5 @@
# frozen_string_literal: true
require 'active_model/version'
require 'devise/hooks/activatable'
require 'devise/hooks/csrf_cleaner'
@@ -105,7 +104,7 @@ 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])
@@ -134,16 +133,18 @@ module Devise
# This is an internal method called every time Devise needs
# to send a notification/mail. This can be overridden if you
# need to customize the e-mail delivery logic. For instance,
# if you are using a queue to deliver e-mails (delayed job,
# sidekiq, resque, etc), you must add the delivery to the queue
# if you are using a queue to deliver e-mails (active job, delayed
# job, sidekiq, resque, etc), you must add the delivery to the queue
# just after the transaction was committed. To achieve this,
# you can override send_devise_notification to store the
# deliveries until the after_commit callback is triggered:
# deliveries until the after_commit callback is triggered.
#
# The following example uses Active Job's `deliver_later` :
#
# class User
# devise :database_authenticatable, :confirmable
#
# after_commit :send_pending_notifications
# after_commit :send_pending_devise_notifications
#
# protected
#
@@ -151,39 +152,45 @@ module Devise
# # If the record is new or changed then delay the
# # delivery until the after_commit callback otherwise
# # send now because after_commit will not be called.
# if new_record? || changed?
# pending_notifications << [notification, args]
# # For Rails < 6 use `changed?` instead of `saved_changes?`.
# if new_record? || saved_changes?
# pending_devise_notifications << [notification, args]
# else
# message = devise_mailer.send(notification, self, *args)
# Remove once we move to Rails 4.2+ only.
# if message.respond_to?(:deliver_now)
# message.deliver_now
# else
# message.deliver
# end
# render_and_send_devise_message(notification, *args)
# end
# end
#
# def send_pending_notifications
# pending_notifications.each do |notification, args|
# message = devise_mailer.send(notification, self, *args)
# Remove once we move to Rails 4.2+ only.
# if message.respond_to?(:deliver_now)
# message.deliver_now
# else
# message.deliver
# end
# private
#
# def send_pending_devise_notifications
# pending_devise_notifications.each do |notification, args|
# render_and_send_devise_message(notification, *args)
# end
#
# # Empty the pending notifications array because the
# # after_commit hook can be called multiple times which
# # could cause multiple emails to be sent.
# pending_notifications.clear
# pending_devise_notifications.clear
# end
#
# def pending_notifications
# @pending_notifications ||= []
# def pending_devise_notifications
# @pending_devise_notifications ||= []
# end
#
# def render_and_send_devise_message(notification, *args)
# message = devise_mailer.send(notification, self, *args)
#
# # Deliver later with Active Job's `deliver_later`
# if message.respond_to?(:deliver_later)
# message.deliver_later
# # Remove once we move to Rails 4.2+ only, as `deliver` is deprecated.
# elsif message.respond_to?(:deliver_now)
# message.deliver_now
# else
# message.deliver
# end
# end
#
# end
#
def send_devise_notification(notification, *args)
@@ -265,39 +272,31 @@ 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:
attributes = if attributes.respond_to? :permit!
attributes.slice(*required_attributes).permit!.to_h.with_indifferent_access
else
attributes.with_indifferent_access.slice(*required_attributes)
end
attributes.delete_if { |key, value| value.blank? }
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)
.delete_if { |key, value| value.blank? }
if attributes.size == required_attributes.size
record = find_first_by_auth_conditions(attributes)
record = find_first_by_auth_conditions(attributes) and return record
end
unless record
record = new
new(devise_parameter_filter.filter(attributes)).tap do |record|
required_attributes.each do |key|
value = attributes[key]
record.send("#{key}=", value)
record.errors.add(key, value.present? ? error : :blank)
record.errors.add(key, attributes[key].blank? ? :blank : error)
end
end
record
end
protected

View File

@@ -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.is_a?(ActiveRecord::Base) # ActiveRecord
if defined?(ActiveRecord) && self < ActiveRecord::Base # 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,
@@ -211,7 +211,10 @@ module Devise
# confirmation_period_valid? # will always return true
#
def confirmation_period_valid?
self.class.allow_unconfirmed_access_for.nil? || (confirmation_sent_at && confirmation_sent_at.utc >= self.class.allow_unconfirmed_access_for.ago)
return true if self.class.allow_unconfirmed_access_for.nil?
return false if self.class.allow_unconfirmed_access_for == 0.days
confirmation_sent_at && confirmation_sent_at.utc >= self.class.allow_unconfirmed_access_for.ago
end
# Checks if the user confirmation happens before the token becomes invalid
@@ -331,7 +334,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)
@@ -345,7 +348,19 @@ module Devise
# If the user is already confirmed, create an error for the user
# Options must have the confirmation_token
def confirm_by_token(confirmation_token)
# When the `confirmation_token` parameter is blank, if there are any users with a blank
# `confirmation_token` in the database, the first one would be confirmed here.
# The error is being manually added here to ensure no users are confirmed by mistake.
# This was done in the model for convenience, since validation errors are automatically
# displayed in the view.
if confirmation_token.blank?
confirmable = new
confirmable.errors.add(:confirmation_token, :blank)
return confirmable
end
confirmable = find_first_by_auth_conditions(confirmation_token: confirmation_token)
unless confirmable
confirmation_digest = Devise.token_generator.digest(self, :confirmation_token, confirmation_token)
confirmable = find_or_initialize_with_error_by(:confirmation_token, confirmation_digest)

View File

@@ -7,6 +7,10 @@ module Devise
# Authenticatable Module, responsible for hashing the password and
# validating the authenticity of a user while signing in.
#
# This module defines a `password=` method. This method will hash the argument
# and store it in the `encrypted_password` column, bypassing any pre-existing
# `password` column if it exists.
#
# == Options
#
# DatabaseAuthenticatable adds the following options to devise_for:
@@ -35,6 +39,22 @@ module Devise
attr_accessor :password_confirmation
end
def initialize(*args, &block)
@skip_email_changed_notification = false
@skip_password_change_notification = false
super
end
# Skips sending the email changed notification after_update
def skip_email_changed_notification!
@skip_email_changed_notification = true
end
# Skips sending the password change notification after_update
def skip_password_change_notification!
@skip_password_change_notification = true
end
def self.required_fields(klass)
[:encrypted_password] + klass.authentication_keys
end
@@ -65,6 +85,15 @@ module Devise
# their password). In case the password field is rejected, the confirmation
# is also rejected as long as it is also blank.
def update_with_password(params, *options)
if options.present?
ActiveSupport::Deprecation.warn <<-DEPRECATION.strip_heredoc
[Devise] The second argument of `DatabaseAuthenticatable#update_with_password`
(`options`) is deprecated and it will be removed in the next major version.
It was added to support a feature deprecated in Rails 4, so you can safely remove it
from your code.
DEPRECATION
end
current_password = params.delete(:current_password)
if params[:password].blank?
@@ -73,11 +102,11 @@ module Devise
end
result = if valid_password?(current_password)
update_attributes(params, *options)
update(params, *options)
else
self.assign_attributes(params, *options)
self.valid?
self.errors.add(:current_password, current_password.blank? ? :blank : :invalid)
assign_attributes(params, *options)
valid?
errors.add(:current_password, current_password.blank? ? :blank : :invalid)
false
end
@@ -98,10 +127,19 @@ module Devise
# end
#
def update_without_password(params, *options)
if options.present?
ActiveSupport::Deprecation.warn <<-DEPRECATION.strip_heredoc
[Devise] The second argument of `DatabaseAuthenticatable#update_without_password`
(`options`) is deprecated and it will be removed in the next major version.
It was added to support a feature deprecated in Rails 4, so you can safely remove it
from your code.
DEPRECATION
end
params.delete(:password)
params.delete(:password_confirmation)
result = update_attributes(params, *options)
result = update(params, *options)
clean_up_passwords
result
end
@@ -113,8 +151,8 @@ module Devise
result = if valid_password?(current_password)
destroy
else
self.valid?
self.errors.add(:current_password, current_password.blank? ? :blank : :invalid)
valid?
errors.add(:current_password, current_password.blank? ? :blank : :invalid)
false
end
@@ -161,7 +199,7 @@ module Devise
# Hashes the password using bcrypt. Custom hash functions should override
# this method to apply their own algorithm.
#
# See https://github.com/plataformatec/devise-encryptable for examples
# See https://github.com/heartcombo/devise-encryptable for examples
# of other hashing engines.
def password_digest(password)
Devise::Encryptor.digest(self.class, password)
@@ -169,21 +207,21 @@ module Devise
if Devise.activerecord51?
def send_email_changed_notification?
self.class.send_email_changed_notification && saved_change_to_email?
self.class.send_email_changed_notification && saved_change_to_email? && !@skip_email_changed_notification
end
else
def send_email_changed_notification?
self.class.send_email_changed_notification && email_changed?
self.class.send_email_changed_notification && email_changed? && !@skip_email_changed_notification
end
end
if Devise.activerecord51?
def send_password_change_notification?
self.class.send_password_change_notification && saved_change_to_encrypted_password?
self.class.send_password_change_notification && saved_change_to_encrypted_password? && !@skip_password_change_notification
end
else
def send_password_change_notification?
self.class.send_password_change_notification && encrypted_password_changed?
self.class.send_password_change_notification && encrypted_password_changed? && !@skip_password_change_notification
end
end

View File

@@ -112,8 +112,8 @@ module Devise
end
def increment_failed_attempts
self.failed_attempts ||= 0
self.failed_attempts += 1
self.class.increment_counter(:failed_attempts, id)
reload
end
def unauthenticated_message
@@ -168,7 +168,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

View File

@@ -131,7 +131,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 +142,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)

View File

@@ -21,6 +21,8 @@ module Devise
def new_with_session(params, session)
new(params)
end
Devise::Models.config(self, :sign_in_after_change_password)
end
end
end

View File

@@ -102,7 +102,7 @@ module Devise
def remember_me?(token, generated_at)
# TODO: Normalize the JSON type coercion along with the Timeoutable hook
# in a single place https://github.com/plataformatec/devise/blob/ffe9d6d406e79108cf32a2c6a1d0b3828849c40b/lib/devise/hooks/timeoutable.rb#L14-L18
# in a single place https://github.com/heartcombo/devise/blob/ffe9d6d406e79108cf32a2c6a1d0b3828849c40b/lib/devise/hooks/timeoutable.rb#L14-L18
if generated_at.is_a?(String)
generated_at = time_from_json(generated_at)
end

View File

@@ -22,7 +22,7 @@ module Devise
self.last_sign_in_at = old_current || new_current
self.current_sign_in_at = new_current
old_current, new_current = self.current_sign_in_ip, request.remote_ip
old_current, new_current = self.current_sign_in_ip, extract_ip_from(request)
self.last_sign_in_ip = old_current || new_current
self.current_sign_in_ip = new_current
@@ -31,9 +31,21 @@ module Devise
end
def update_tracked_fields!(request)
# We have to check if the user is already persisted before running
# `save` here because invalid users can be saved if we don't.
# See https://github.com/heartcombo/devise/issues/4673 for more details.
return if new_record?
update_tracked_fields(request)
save
save(validate: false)
end
protected
def extract_ip_from(request)
request.remote_ip
end
end
end
end

View File

@@ -30,7 +30,7 @@ module Devise
base.class_eval do
validates_presence_of :email, if: :email_required?
if Devise.activerecord51?
validates_uniqueness_of :email, allow_blank: true, if: :will_save_change_to_email?
validates_uniqueness_of :email, allow_blank: true, case_sensitive: true, if: :will_save_change_to_email?
validates_format_of :email, with: email_regexp, allow_blank: true, if: :will_save_change_to_email?
else
validates_uniqueness_of :email, allow_blank: true, if: :email_changed?

View File

@@ -18,6 +18,8 @@ module Devise
def filtered_hash_by_method_for_given_keys(conditions, method, condition_keys)
condition_keys.each do |k|
next unless conditions.key?(k)
value = conditions[k]
conditions[k] = value.send(method) if value.respond_to?(method)
end

View File

@@ -135,7 +135,19 @@ module Devise
end
def default_params
@params.fetch(@resource_name, {})
if hashable_resource_params?
@params.fetch(@resource_name)
else
empty_params
end
end
def hashable_resource_params?
@params[@resource_name].respond_to?(:permit)
end
def empty_params
ActionController::Parameters.new({})
end
def permit_keys(parameters, keys)

View File

@@ -34,11 +34,7 @@ module Devise
end
initializer "devise.secret_key" do |app|
if app.respond_to?(:secrets)
Devise.secret_key ||= app.secrets.secret_key_base
elsif app.config.respond_to?(:secret_key_base)
Devise.secret_key ||= app.config.secret_key_base
end
Devise.secret_key ||= Devise::SecretKeyFinder.new(app).find
Devise.token_generator ||=
if secret_key = Devise.secret_key

View File

@@ -135,10 +135,10 @@ module ActionDispatch::Routing
# * failure_app: a rack app which is invoked whenever there is a failure. Strings representing a given
# are also allowed as parameter.
#
# * sign_out_via: the HTTP method(s) accepted for the :sign_out action (default: :get),
# * sign_out_via: the HTTP method(s) accepted for the :sign_out action (default: :delete),
# if you wish to restrict this to accept only :post or :delete requests you should do:
#
# devise_for :users, sign_out_via: [:post, :delete]
# devise_for :users, sign_out_via: [:get, :post]
#
# You need to make sure that your sign_out controls trigger a request with a matching HTTP method.
#
@@ -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)))

View File

@@ -0,0 +1,27 @@
# frozen_string_literal: true
module Devise
class SecretKeyFinder
def initialize(application)
@application = application
end
def find
if @application.respond_to?(:credentials) && key_exists?(@application.credentials)
@application.credentials.secret_key_base
elsif @application.respond_to?(:secrets) && key_exists?(@application.secrets)
@application.secrets.secret_key_base
elsif @application.config.respond_to?(:secret_key_base) && key_exists?(@application.config)
@application.config.secret_key_base
elsif @application.respond_to?(:secret_key_base) && key_exists?(@application)
@application.secret_key_base
end
end
private
def key_exists?(object)
object.secret_key_base.present?
end
end
end

View File

@@ -28,7 +28,7 @@ module Devise
private
# Receives a resource and check if it is valid by calling valid_for_authentication?
# An optional block that will be triggered while validating can be optionally
# A block that will be triggered while validating can be optionally
# given as parameter. Check Devise::Models::Authenticatable.valid_for_authentication?
# for more information.
#

View File

@@ -16,8 +16,13 @@ module Devise
success!(resource)
end
# In paranoid mode, hash the password even when a resource doesn't exist for the given authentication key.
# This is necessary to prevent enumeration attacks - e.g. the request is faster when a resource doesn't
# exist in the database if the password hashing algorithm is not called.
mapping.to.new.password = password if !hashed && Devise.paranoid
fail(:not_found_in_database) unless resource
unless resource
Devise.paranoid ? fail(:invalid) : fail(:not_found_in_database)
end
end
end
end

View File

@@ -37,6 +37,8 @@ module Devise
@response
end
ruby2_keywords(:process) if respond_to?(:ruby2_keywords, true)
# We need to set up the environment variables and the response in the controller.
def setup_controller_for_warden #:nodoc:
@request.env['action_controller.instance'] = @controller
@@ -139,8 +141,9 @@ module Devise
status, headers, response = Devise.warden_config[:failure_app].call(env).to_a
@controller.response.headers.merge!(headers)
@controller.response.content_type = headers["Content-Type"] unless Rails::VERSION::MAJOR >= 5
@controller.status = status
@controller.response.body = response.body
@controller.response_body = response.body
nil # causes process return @response
end

View File

@@ -28,7 +28,7 @@ module Devise
end
end
# Signs in a specific resource, mimicking a successfull sign in
# Signs in a specific resource, mimicking a successful sign in
# operation through +Devise::SessionsController#create+.
#
# * +resource+ - The resource that should be authenticated

View File

@@ -1,5 +1,5 @@
# frozen_string_literal: true
module Devise
VERSION = "4.4.0".freeze
VERSION = "4.7.3".freeze
end

View File

@@ -54,11 +54,11 @@ module ActiveRecord
t.datetime :remember_created_at
## Trackable
t.integer :sign_in_count, default: 0, null: false
t.datetime :current_sign_in_at
t.datetime :last_sign_in_at
t.#{ip_column} :current_sign_in_ip
t.#{ip_column} :last_sign_in_ip
# t.integer :sign_in_count, default: 0, null: false
# t.datetime :current_sign_in_at
# t.datetime :last_sign_in_at
# t.#{ip_column} :current_sign_in_ip
# t.#{ip_column} :last_sign_in_ip
## Confirmable
# t.string :confirmation_token
@@ -82,8 +82,8 @@ RUBY
postgresql?
end
def rails5?
Rails.version.start_with? '5'
def rails5_and_up?
Rails::VERSION::MAJOR >= 5
end
def postgresql?
@@ -92,13 +92,13 @@ RUBY
end
def migration_version
if rails5?
if rails5_and_up?
"[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
end
end
def primary_key_type
primary_key_string if rails5?
primary_key_string if rails5_and_up?
end
def primary_key_string

View File

@@ -18,7 +18,7 @@ module Devise
This will create a controller class at app/controllers/users/sessions_controller.rb like this:
class Users::ConfirmationsController < Devise::ConfirmationsController
class Users::SessionsController < Devise::SessionsController
content...
end
DESC

View File

@@ -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
hook_for :orm, required: true
class_option :routes, desc: "Generate routes", type: :boolean, default: true

View File

@@ -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]
@@ -37,10 +37,6 @@ module Devise
def show_readme
readme "README" if behavior == :invoke
end
def rails_4?
Rails::VERSION::MAJOR == 4
end
end
end
end

View File

@@ -6,9 +6,9 @@ module Devise
def model_contents
buffer = <<-CONTENT
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
:recoverable, :rememberable, :validatable
CONTENT
buffer

View File

@@ -42,7 +42,7 @@ module Devise
def view_directory(name, _target_path = nil)
directory name.to_s, _target_path || "#{target_path}/#{name}" do |content|
if scope
content.gsub "devise/shared/links", "#{plural_scope}/shared/links"
content.gsub("devise/shared", "#{plural_scope}/shared")
else
content
end

View File

@@ -34,11 +34,11 @@ module Mongoid
field :remember_created_at, type: Time
## Trackable
field :sign_in_count, type: Integer, default: 0
field :current_sign_in_at, type: Time
field :last_sign_in_at, type: Time
field :current_sign_in_ip, type: String
field :last_sign_in_ip, type: String
# field :sign_in_count, type: Integer, default: 0
# field :current_sign_in_at, type: Time
# field :last_sign_in_at, type: Time
# field :current_sign_in_ip, type: String
# field :last_sign_in_ip, type: String
## Confirmable
# field :confirmation_token, type: String

View File

@@ -1,6 +1,6 @@
===============================================================================
Some setup you must do manually if you haven't yet:
Depending on your application's configuration some manual setup may be required:
1. Ensure you have defined default url options in your environments files. Here
is an example of default_url_options appropriate for a development environment
@@ -10,10 +10,14 @@ Some setup you must do manually if you haven't yet:
In production, :host should be set to the actual host of your application.
* Required for all applications. *
2. Ensure you have defined root_url to *something* in your config/routes.rb.
For example:
root to: "home#index"
* Not required for API-only Applications *
3. Ensure you have flash messages in app/views/layouts/application.html.erb.
For example:
@@ -21,8 +25,12 @@ Some setup you must do manually if you haven't yet:
<p class="notice"><%= notice %></p>
<p class="alert"><%= alert %></p>
* Not required for API-only Applications *
4. You can copy Devise views (for customization) to your app by running:
rails g devise:views
* Not required *
===============================================================================

View File

@@ -9,7 +9,7 @@ class <%= @scope_prefix %>OmniauthCallbacksController < Devise::OmniauthCallback
# end
# More info at:
# https://github.com/plataformatec/devise#omniauth
# https://github.com/heartcombo/devise#omniauth
# GET|POST /resource/auth/twitter
# def passthru

42
lib/generators/templates/devise.rb Executable file → Normal file
View File

@@ -1,5 +1,11 @@
# frozen_string_literal: true
# Assuming you have not yet modified this file, each configuration option below
# is set to its default value. Note that some are commented out while others
# are not: uncommented lines are intended to protect your configuration from
# breaking changes in upgrades (i.e., in the event that future versions of
# Devise change the default values for those options).
#
# Use this hook to configure devise mailer, warden hooks and so forth.
# Many of these configuration options can be set straight in your model.
Devise.setup do |config|
@@ -10,6 +16,10 @@ Devise.setup do |config|
# by default. You can change it below and use your own secret key.
# config.secret_key = '<%= SecureRandom.hex(64) %>'
# ==> Controller configuration
# Configure the parent class to the devise controllers.
# config.parent_controller = 'DeviseController'
# ==> Mailer Configuration
# Configure the e-mail address which will be shown in Devise::Mailer,
# note that it will be overwritten if you use your own mailer class
@@ -64,7 +74,10 @@ Devise.setup do |config|
# Tell if authentication through HTTP Auth is enabled. False by default.
# It can be set to an array that will enable http authentication only for the
# given strategies, for example, `config.http_authenticatable = [:database]` will
# enable it only for database authentication. The supported strategies are:
# enable it only for database authentication.
# For API-only applications to support authentication "out-of-the-box", you will likely want to
# enable this with :database unless you are using a custom strategy.
# The supported strategies are:
# :database = Support basic authentication with authentication key + password
# config.http_authenticatable = false
@@ -99,15 +112,18 @@ Devise.setup do |config|
# config.reload_routes = true
# ==> Configuration for :database_authenticatable
# For bcrypt, this is the cost for hashing the password and defaults to 11. If
# For bcrypt, this is the cost for hashing the password and defaults to 12. If
# using other algorithms, it sets how many times you want the password to be hashed.
# The number of stretches used for generating the hashed password are stored
# with the hashed password. This allows you to change the stretches without
# invalidating existing passwords.
#
# Limiting the stretches to just one in testing will increase the performance of
# your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
# a value less than 10 in other environments. Note that, for bcrypt (the default
# algorithm), the cost increases exponentially with the number of stretches (e.g.
# a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
config.stretches = Rails.env.test? ? 1 : 11
config.stretches = Rails.env.test? ? 1 : 12
# Set up a pepper to generate the hashed password.
# config.pepper = '<%= SecureRandom.hex(64) %>'
@@ -122,8 +138,11 @@ Devise.setup do |config|
# A period that the user is allowed to access the website even without
# confirming their account. For instance, if set to 2.days, the user will be
# able to access the website for two days without confirming their account,
# access will be blocked just in the third day. Default is 0.days, meaning
# the user cannot access the website without confirming their account.
# access will be blocked just in the third day.
# You can also set it to nil, which will allow the user to access the website
# without confirming their account.
# Default is 0.days, meaning the user cannot access the website without
# confirming their account.
# config.allow_unconfirmed_access_for = 2.days
# A period that the user is allowed to confirm their account before their
@@ -276,4 +295,17 @@ Devise.setup do |config|
# When using OmniAuth, Devise cannot automatically set OmniAuth path,
# so you need to do it manually. For the users scope, it would be:
# config.omniauth_path_prefix = '/my_engine/users/auth'
# ==> Turbolinks configuration
# If your app is using Turbolinks, Turbolinks::Controller needs to be included to make redirection work correctly:
#
# ActiveSupport.on_load(:devise_failure_app) do
# include Turbolinks::Controller
# end
# ==> Configuration for :registerable
# When set to false, does not sign a user in automatically after their password is
# changed. Defaults to true, so a user is signed in automatically after changing a password.
# config.sign_in_after_change_password = true
end

View File

@@ -5,7 +5,11 @@
<%= f.full_error :confirmation_token %>
<div class="form-inputs">
<%= f.input :email, required: true, autofocus: true %>
<%= f.input :email,
required: true,
autofocus: true,
value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email),
input_html: { autocomplete: "email" } %>
</div>
<div class="form-actions">

View File

@@ -7,8 +7,16 @@
<%= f.full_error :reset_password_token %>
<div class="form-inputs">
<%= f.input :password, label: "New password", required: true, autofocus: true, hint: ("#{@minimum_password_length} characters minimum" if @minimum_password_length) %>
<%= f.input :password_confirmation, label: "Confirm your new password", required: true %>
<%= f.input :password,
label: "New password",
required: true,
autofocus: true,
hint: ("#{@minimum_password_length} characters minimum" if @minimum_password_length),
input_html: { autocomplete: "new-password" } %>
<%= f.input :password_confirmation,
label: "Confirm your new password",
required: true,
input_html: { autocomplete: "new-password" } %>
</div>
<div class="form-actions">

View File

@@ -4,7 +4,10 @@
<%= f.error_notification %>
<div class="form-inputs">
<%= f.input :email, required: true, autofocus: true %>
<%= f.input :email,
required: true,
autofocus: true,
input_html: { autocomplete: "email" } %>
</div>
<div class="form-actions">

View File

@@ -10,9 +10,17 @@
<p>Currently waiting confirmation for: <%= resource.unconfirmed_email %></p>
<% end %>
<%= f.input :password, autocomplete: "off", hint: "leave it blank if you don't want to change it", required: false %>
<%= f.input :password_confirmation, required: false %>
<%= f.input :current_password, hint: "we need your current password to confirm your changes", required: true %>
<%= f.input :password,
hint: "leave it blank if you don't want to change it",
required: false,
input_html: { autocomplete: "new-password" } %>
<%= f.input :password_confirmation,
required: false,
input_html: { autocomplete: "new-password" } %>
<%= f.input :current_password,
hint: "we need your current password to confirm your changes",
required: true,
input_html: { autocomplete: "current-password" } %>
</div>
<div class="form-actions">

View File

@@ -4,9 +4,17 @@
<%= f.error_notification %>
<div class="form-inputs">
<%= f.input :email, required: true, autofocus: true %>
<%= f.input :password, required: true, hint: ("#{@minimum_password_length} characters minimum" if @minimum_password_length) %>
<%= f.input :password_confirmation, required: true %>
<%= f.input :email,
required: true,
autofocus: true,
input_html: { autocomplete: "email" }%>
<%= f.input :password,
required: true,
hint: ("#{@minimum_password_length} characters minimum" if @minimum_password_length),
input_html: { autocomplete: "new-password" } %>
<%= f.input :password_confirmation,
required: true,
input_html: { autocomplete: "new-password" } %>
</div>
<div class="form-actions">

View File

@@ -2,8 +2,13 @@
<%= simple_form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
<div class="form-inputs">
<%= f.input :email, required: false, autofocus: true %>
<%= f.input :password, required: false %>
<%= f.input :email,
required: false,
autofocus: true,
input_html: { autocomplete: "email" } %>
<%= f.input :password,
required: false,
input_html: { autocomplete: "current-password" } %>
<%= f.input :remember_me, as: :boolean if devise_mapping.rememberable? %>
</div>

View File

@@ -5,7 +5,10 @@
<%= f.full_error :unlock_token %>
<div class="form-inputs">
<%= f.input :email, required: true, autofocus: true %>
<%= f.input :email,
required: true,
autofocus: true,
input_html: { autocomplete: "email" } %>
</div>
<div class="form-actions">

View File

@@ -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

View File

@@ -312,6 +312,16 @@ class ControllerAuthenticatableTest < Devise::ControllerTestCase
end
end
test 'is_flashing_format? depends on is_navigation_format?' do
@controller.expects(:is_navigational_format?).returns(true)
assert @controller.is_flashing_format?
end
test 'is_flashing_format? is guarded against flash (middleware) not being loaded' do
@controller.request.expects(:respond_to?).with(:flash).returns(false)
refute @controller.is_flashing_format?
end
test 'is not a devise controller' do
refute @controller.devise_controller?
end

View File

@@ -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

View File

@@ -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

View File

@@ -31,4 +31,9 @@ class PasswordsControllerTest < Devise::ControllerTestCase
put_update_with_params
assert_redirected_to custom_path
end
test 'calls after_database_authentication callback after sign_in immediately after password update' do
User.any_instance.expects :after_database_authentication
put_update_with_params
end
end

View File

@@ -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

0
test/devise_test.rb Executable file → Normal file
View File

View File

@@ -28,6 +28,27 @@ class FailureTest < ActiveSupport::TestCase
end
end
class FailureWithoutRootPath < Devise::FailureApp
class FakeURLHelpers
end
class FakeRoutesWithoutRoot
def url_helpers
FakeURLHelpers.new
end
end
class FakeAppWithoutRootPath
def routes
FakeRoutesWithoutRoot.new
end
end
def main_app
FakeAppWithoutRootPath.new
end
end
class FakeEngineApp < Devise::FailureApp
class FakeEngine
def new_user_on_engine_session_url _
@@ -44,11 +65,15 @@ class FailureTest < ActiveSupport::TestCase
end
end
class RequestWithoutFlashSupport < ActionDispatch::Request
undef_method :flash
end
def self.context(name, &block)
instance_eval(&block)
end
def call_failure(env_params={})
def call_failure(env_params = {})
env = {
'REQUEST_URI' => 'http://test.host/',
'HTTP_HOST' => 'test.host',
@@ -66,7 +91,7 @@ class FailureTest < ActiveSupport::TestCase
end
@response = (env.delete(:app) || Devise::FailureApp).call(env).to_a
@request = ActionDispatch::Request.new(env)
@request = (env.delete(:request_klass) || ActionDispatch::Request).new(env)
end
context 'When redirecting' do
@@ -99,6 +124,13 @@ class FailureTest < ActiveSupport::TestCase
end
end
test 'returns to the root path even when it\'s not defined' do
call_failure app: FailureWithoutRootPath
assert_equal 302, @response.first
assert_equal 'You need to sign in or sign up before continuing.', @request.flash[:alert]
assert_equal 'http://test.host/', @response.second['Location']
end
test 'returns to the root path considering subdomain if no session path is available' do
swap Devise, router_name: :fake_app do
call_failure app: FailureWithSubdomain
@@ -294,8 +326,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
@@ -305,8 +337,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
@@ -316,8 +348,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)
@@ -329,12 +361,25 @@ 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
end
context "Lazy loading" do
test "loads" do
assert_equal "yes it does", Devise::FailureApp.new.lazy_loading_works?
end
end
context "Without Flash Support" do
test "returns to the default redirect location without a flash message" do
call_failure request_klass: RequestWithoutFlashSupport
assert_equal 302, @response.first
assert_equal 'http://test.host/users/sign_in', @response.second['Location']
end
end
end

View File

@@ -84,7 +84,7 @@ if DEVISE_ORM == :active_record
test "add primary key type with rails 5 when specified in rails generator" do
run_generator ["monster", "--primary_key_type=uuid"]
if Rails.version.start_with? '5'
if Devise::Test.rails5_and_up?
assert_migration "db/migrate/devise_create_monsters.rb", /create_table :monsters, id: :uuid do/
else
assert_migration "db/migrate/devise_create_monsters.rb", /create_table :monsters do/

View File

@@ -11,16 +11,19 @@ class ViewsGeneratorTest < Rails::Generators::TestCase
run_generator
assert_files
assert_shared_links
assert_error_messages
end
test "Assert all views are properly created with scope param" do
run_generator %w(users)
assert_files "users"
assert_shared_links "users"
assert_error_messages "users"
run_generator %w(admins)
assert_files "admins"
assert_shared_links "admins"
assert_error_messages "admins"
end
test "Assert views with simple form" do
@@ -74,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"
@@ -88,6 +91,7 @@ class ViewsGeneratorTest < Rails::Generators::TestCase
assert_file "app/views/#{scope}/registrations/edit.html.erb"
assert_file "app/views/#{scope}/sessions/new.html.erb"
assert_file "app/views/#{scope}/shared/_links.html.erb"
assert_file "app/views/#{scope}/shared/_error_messages.html.erb"
assert_file "app/views/#{scope}/unlocks/new.html.erb"
end
@@ -102,4 +106,16 @@ class ViewsGeneratorTest < Rails::Generators::TestCase
assert_file "app/views/#{scope}/sessions/new.html.erb", link
assert_file "app/views/#{scope}/unlocks/new.html.erb", link
end
def assert_error_messages(scope = nil)
scope = "devise" if scope.nil?
link = /<%= render \"#{scope}\/shared\/error_messages\", resource: resource %>/
assert_file "app/views/#{scope}/passwords/edit.html.erb", link
assert_file "app/views/#{scope}/passwords/new.html.erb", link
assert_file "app/views/#{scope}/confirmations/new.html.erb", link
assert_file "app/views/#{scope}/registrations/new.html.erb", link
assert_file "app/views/#{scope}/registrations/edit.html.erb", link
assert_file "app/views/#{scope}/unlocks/new.html.erb", link
end
end

View File

@@ -3,6 +3,12 @@
require 'test_helper'
class AuthenticationSanityTest < Devise::IntegrationTest
test 'sign in should not run model validations' do
sign_in_as_user
refute User.validations_performed
end
test 'home should be accessible without sign in' do
visit '/'
assert_response :success
@@ -315,7 +321,15 @@ 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 "You are already signed in as admin.", flash[:alert]
end
end
end
@@ -482,7 +496,7 @@ class AuthenticationOthersTest < Devise::IntegrationTest
create_user
post user_session_path(format: 'xml'), 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, %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<user>)
end
test 'sign in with xml format is idempotent' do
@@ -498,7 +512,7 @@ class AuthenticationOthersTest < Devise::IntegrationTest
post user_session_path(format: 'xml'), 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, %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<user>)
end
test 'sign out with html redirects' do
@@ -545,18 +559,6 @@ class AuthenticationOthersTest < Devise::IntegrationTest
refute warden.authenticated?(:user)
end
end
test 'not signed in should return notification payload with 401 status' do
begin
subscriber = ActiveSupport::Notifications.subscribe /process_action.action_controller/ do |_name, _start, _finish, _id, payload|
assert_equal 401, payload[:status]
end
get admins_path
ensure
ActiveSupport::Notifications.unsubscribe(subscriber)
end
end
end
class AuthenticationKeysTest < Devise::IntegrationTest

View File

@@ -175,6 +175,36 @@ class ConfirmationTest < Devise::IntegrationTest
assert_current_url '/users/sign_in'
end
test "should not be able to confirm an email with a blank confirmation token" do
visit_user_confirmation_with_token("")
assert_contain "Confirmation token can't be blank"
end
test "should not be able to confirm an email with a nil confirmation token" do
visit_user_confirmation_with_token(nil)
assert_contain "Confirmation token can't be blank"
end
test "should not be able to confirm user with blank confirmation token" do
user = create_user(confirm: false)
user.update_attribute(:confirmation_token, "")
visit_user_confirmation_with_token("")
assert_contain "Confirmation token can't be blank"
end
test "should not be able to confirm user with nil confirmation token" do
user = create_user(confirm: false)
user.update_attribute(:confirmation_token, nil)
visit_user_confirmation_with_token(nil)
assert_contain "Confirmation token can't be blank"
end
test 'error message is configurable by resource name' do
store_translations :en, devise: {
failure: { user: { unconfirmed: "Not confirmed user" } }
@@ -188,28 +218,28 @@ class ConfirmationTest < Devise::IntegrationTest
user = create_user(confirm: false)
post user_confirmation_path(format: 'xml'), params: { user: { email: user.email } }
assert_response :success
assert_equal response.body, {}.to_xml
assert_equal({}.to_xml, response.body)
end
test 'resent confirmation token with invalid E-Mail in XML format should return invalid response' do
create_user(confirm: false)
post user_confirmation_path(format: 'xml'), 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, %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<errors>)
end
test 'confirm account with valid confirmation token in XML format should return valid response' do
user = create_user(confirm: false)
get user_confirmation_path(confirmation_token: user.raw_confirmation_token, format: 'xml')
assert_response :success
assert response.body.include? %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<user>)
assert_includes response.body, %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<user>)
end
test 'confirm account with invalid confirmation token in XML format should return invalid response' do
create_user(confirm: false)
get user_confirmation_path(confirmation_token: 'invalid_confirmation', format: 'xml')
assert_response :unprocessable_entity
assert response.body.include? %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<errors>)
assert_includes response.body, %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<errors>)
end
test 'request an account confirmation account with JSON, should return an empty JSON' do
@@ -217,7 +247,7 @@ class ConfirmationTest < Devise::IntegrationTest
post user_confirmation_path, params: { user: { email: user.email }, format: :json }
assert_response :success
assert_equal response.body, {}.to_json
assert_equal({}.to_json, response.body)
end
test "when in paranoid mode and with a valid e-mail, should not say that the e-mail is valid" do
@@ -252,7 +282,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
@@ -263,7 +293,7 @@ class ConfirmationOnChangeTest < Devise::IntegrationTest
test 'admin should be able to request a new confirmation after email changed' do
admin = create_admin
admin.update_attributes(email: 'new_test@example.com')
admin.update(email: 'new_test@example.com')
visit new_admin_session_path
click_link "Didn't receive confirmation instructions?"
@@ -279,7 +309,7 @@ class ConfirmationOnChangeTest < Devise::IntegrationTest
test 'admin with valid confirmation token should be able to confirm email after email changed' do
admin = create_admin
admin.update_attributes(email: 'new_test@example.com')
admin.update(email: 'new_test@example.com')
assert_equal 'new_test@example.com', admin.unconfirmed_email
visit_admin_confirmation_with_token(admin.raw_confirmation_token)
@@ -291,13 +321,13 @@ class ConfirmationOnChangeTest < Devise::IntegrationTest
test 'admin with previously valid confirmation token should not be able to confirm email after email changed again' do
admin = create_admin
admin.update_attributes(email: 'first_test@example.com')
admin.update(email: 'first_test@example.com')
assert_equal 'first_test@example.com', admin.unconfirmed_email
raw_confirmation_token = admin.raw_confirmation_token
admin = Admin.find(admin.id)
admin.update_attributes(email: 'second_test@example.com')
admin.update(email: 'second_test@example.com')
assert_equal 'second_test@example.com', admin.unconfirmed_email
visit_admin_confirmation_with_token(raw_confirmation_token)
@@ -313,7 +343,7 @@ class ConfirmationOnChangeTest < Devise::IntegrationTest
test 'admin email should be unique also within unconfirmed_email' do
admin = create_admin
admin.update_attributes(email: 'new_admin_test@example.com')
admin.update(email: 'new_admin_test@example.com')
assert_equal 'new_admin_test@example.com', admin.unconfirmed_email
create_second_admin(email: "new_admin_test@example.com")

View File

@@ -65,7 +65,7 @@ class DatabaseAuthenticationTest < Devise::IntegrationTest
end
end
test 'sign in with invalid pasword should return to sign in form with error message' do
test 'sign in with invalid password should return to sign in form with error message' do
sign_in_as_admin do
fill_in 'password', with: 'abcdef'
end
@@ -74,6 +74,19 @@ class DatabaseAuthenticationTest < Devise::IntegrationTest
refute warden.authenticated?(:admin)
end
test 'when in paranoid mode and without a valid e-mail' do
swap Devise, paranoid: true do
store_translations :en, devise: { failure: { not_found_in_database: 'Not found in database' } } do
sign_in_as_user do
fill_in 'email', with: 'wrongemail@test.com'
end
assert_not_contain 'Not found in database'
assert_contain 'Invalid Email or password.'
end
end
end
test 'error message is configurable by resource name' do
store_translations :en, devise: { failure: { admin: { invalid: "Invalid credentials" } } } do
sign_in_as_admin do

View File

@@ -3,6 +3,12 @@
require 'test_helper'
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
end
test 'handles unverified requests gets rid of caches but continues signed in' do
swap ApplicationController, allow_forgery_protection: true do
create_user
@@ -93,7 +99,7 @@ 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}")}" }
user

View File

@@ -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
@@ -136,8 +136,7 @@ class LockTest < Devise::IntegrationTest
post user_unlock_path(format: 'xml'), params: { user: {email: user.email} }
assert_response :success
assert_equal response.body, {}.to_xml
assert_equal({}.to_xml, response.body)
assert_equal 1, ActionMailer::Base.deliveries.size
end
@@ -147,7 +146,7 @@ class LockTest < Devise::IntegrationTest
post user_unlock_path(format: 'xml'), 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, %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<errors>)
assert_equal 0, ActionMailer::Base.deliveries.size
end
@@ -157,21 +156,20 @@ class LockTest < Devise::IntegrationTest
assert user.access_locked?
get user_unlock_path(format: 'xml', unlock_token: raw)
assert_response :success
assert response.body.include? %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<user>)
assert_includes response.body, %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<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')
assert_response :unprocessable_entity
assert response.body.include? %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<errors>)
assert_includes response.body, %(<?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_equal({}.to_json, response.body)
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

View File

@@ -2,10 +2,23 @@
require 'test_helper'
class MyMountableEngine
def self.call(env)
['200', { 'Content-Type' => 'text/html' }, ['Rendered content of MyMountableEngine']]
module MyMountableEngine
class Engine < ::Rails::Engine
isolate_namespace MyMountableEngine
end
class TestsController < ActionController::Base
def index
render plain: 'Root test successful'
end
def inner_route
render plain: 'Inner route test successful'
end
end
end
MyMountableEngine::Engine.routes.draw do
get 'test', to: 'tests#inner_route'
root to: 'tests#index'
end
# If disable_clear_and_finalize is set to true, Rails will not clear other routes when calling
@@ -15,7 +28,7 @@ Rails.application.routes.disable_clear_and_finalize = true
Rails.application.routes.draw do
authenticate(:user) do
mount MyMountableEngine, at: '/mountable_engine'
mount MyMountableEngine::Engine, at: '/mountable_engine'
end
end
@@ -33,6 +46,23 @@ class AuthenticatedMountedEngineTest < Devise::IntegrationTest
get '/mountable_engine'
assert_response :success
assert_contain 'Rendered content of MyMountableEngine'
assert_contain 'Root test successful'
end
test 'renders a inner route of the mounted engine when authenticated' do
sign_in_as_user
get '/mountable_engine/test'
assert_response :success
assert_contain 'Inner route test successful'
end
test 'respond properly to a non existing route of the mounted engine' do
sign_in_as_user
assert_raise ActionController::RoutingError do
get '/mountable_engine/non-existing-route'
end
end
end

View File

@@ -42,6 +42,17 @@ class OmniauthableIntegrationTest < Devise::IntegrationTest
end
end
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"
assert warden.authenticated?(:user)
refute 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"

View File

@@ -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
@@ -33,6 +33,17 @@ class PasswordTest < Devise::IntegrationTest
click_button 'Change my password'
end
test 'reset password should send to user record email and avoid case mapping collisions' do
create_user(email: 'user@github.com')
request_forgot_password do
fill_in 'email', with: 'user@gıthub.com'
end
mail = ActionMailer::Base.deliveries.last
assert_equal ['user@github.com'], mail.to
end
test 'reset password with email of different case should succeed when email is in the list of case insensitive keys' do
create_user(email: 'Foo@Bar.com')
@@ -254,14 +265,14 @@ class PasswordTest < Devise::IntegrationTest
create_user
post user_password_path(format: 'xml'), params: { user: {email: "user@test.com"} }
assert_response :success
assert_equal response.body, { }.to_xml
assert_equal({}.to_xml, response.body)
end
test 'reset password request with invalid E-Mail in XML format should return valid response' do
create_user
post user_password_path(format: 'xml'), 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, %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<errors>)
end
test 'reset password request with invalid E-Mail in XML format should return empty and valid response' do
@@ -269,7 +280,7 @@ class PasswordTest < Devise::IntegrationTest
create_user
post user_password_path(format: 'xml'), params: { user: {email: "invalid@test.com"} }
assert_response :success
assert_equal response.body, { }.to_xml
assert_equal({}.to_xml, response.body)
end
end
@@ -289,7 +300,7 @@ class PasswordTest < Devise::IntegrationTest
request_forgot_password
put user_password_path(format: 'xml'), 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, %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<errors>)
end
test 'change password with invalid new password in XML format should return invalid response' do
@@ -297,7 +308,7 @@ class PasswordTest < Devise::IntegrationTest
request_forgot_password
put user_password_path(format: 'xml'), 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>)
assert_includes response.body, %(<?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
@@ -306,7 +317,7 @@ class PasswordTest < Devise::IntegrationTest
post user_password_path(format: :json), params: { user: { email: user.email } }
assert_response :success
assert_equal response.body, "{}"
assert_equal "{}", response.body
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

Some files were not shown because too many files have changed in this diff Show More