Compare commits

...

366 Commits

Author SHA1 Message Date
Carlos Antonio da Silva
731074bf09 Stop updating copyright every year [ci skip] 2026-01-05 10:02:56 -03:00
Carlos Antonio da Silva
35920d27e5 Exclude Rails main + Ruby 3.2
It dropped support to Ruby 3.2 which is expected to be EOL by
2026-03-31.
2026-01-05 09:55:48 -03:00
Carlos Antonio da Silva
00a97782cb Release v5.0.0.rc
Given a lot of time has passed since the last v4.x release, and there's
been many changes (including breaking ones) merged to main, let's go
with an "RC" version before doing a final release.

If we don't hear any major issues, I plan to release a final version in
a couple of weeks.
2025-12-31 15:46:05 -03:00
Carlos Antonio da Silva
119a40f9d3 Fix gemspec and readme, Devise v5 will support Rails >= 7, not 6
As per our test matrix.
2025-12-31 15:35:31 -03:00
Carlos Antonio da Silva
1096b60967 Remove deprecated Devise.activerecord51? method 2025-12-31 15:35:31 -03:00
Carlos Antonio da Silva
fc466316df Ensure auth keys at the start of the i18n msg are properly cased
Otherwise if we humanized the whole string, it could cause us to change
the output of strings with periods and maybe other side-effects, since
we're changing the whole string from i18n.

This is safer as it only changes the first char of the translated
message, and only if it is a match with the first translated auth key,
so we can more safely humanize & downcase all auth keys to interpolate
in the message whenever needed.

Also add changelog for the change.
2025-12-31 14:46:34 -03:00
Julius Graakjær Grantzau
356b094312 Downcase authentication keys and humanize error message (#4834)
"Invalid Email or password." is grammatically incorrect, a change
introduced a while ago by #4014.

Signed-off-by: Carlos Antonio da Silva <carlosantoniodasilva@gmail.com>
2025-12-31 14:40:36 -03:00
Adan Amarillas
9a149ff139 Return 401 for sessions#destroy action with no user signed in (#4878)
It's an unauthenticated request, so return 401 Unauthorized like most
other similar requests.

Signed-off-by: Carlos Antonio da Silva <carlosantoniodasilva@gmail.com>
2025-12-31 13:56:01 -03:00
Shriram
05bbc71446 Make secure_compare handle empty strings comparison correctly
Used Rails' secure_compare method inside the definition of
secure_compare. This will handle the empty strings comparison and
return true when both the parameters are empty strings.

Fixes #4441, #4829
2025-12-31 11:51:20 -03:00
Taketo Takashima
8054ad55c3 Use :unprocessable_content in generated Devise config for Rack 3.1+, avoid Rack warnings (#5797)
In Rack v3.1.0, the symbol for HTTP status code 422 was changed from `:unprocessable_entity` to `:unprocessable_content`.

As a result, when using rack 3.2 with the following configuration in `config/initializers/devise.rb`, a warning is shown on login failure:

```ruby
# config/initializers/devise.rb
Devise.setup do |config|
  ...
  config.responder.error_status = :unprocessable_entity
```

Warning message:

```sh
/path-to-app/vendor/bundle/ruby/3.4.0/gems/devise-4.9.4/lib/devise/failure_app.rb:80: warning: Status code :unprocessable_entity is deprecated and will be removed in a future version of Rack. Please use :unprocessable_content instead.
```

This warning can be resolved by updating the config as follows:
```diff
# config/initializers/devise.rb
Devise.setup do |config|
  ...
+  config.responder.error_status = :unprocessable_content
-  config.responder.error_status = :unprocessable_entity
```

This fixes the root cause of the warning for new apps by adjusting the generated config during `$ rails generate devise:install` depending on the rack version, so new apps using newer Rack versions generate `error_status = :unprocessable_content` instead of `:unprocessable_entity`.

Existing apps are handled by [latest versions of Rails, which will now transparently convert the code under the hood to avoid the Rack warning](https://github.com/rails/rails/pull/53383), and Devise will use that translation layer when available in the failure app to prevent the warning there as well (since that isn't covered by Rails automatic conversion).

Signed-off-by: Carlos Antonio da Silva <carlosantoniodasilva@gmail.com>
2025-12-31 10:45:09 -03:00
Carlos Antonio da Silva
d13ef89afb Replace [data-turbo-cache=false] with [data-turbo-temporary]
The default `_error_messages.html.erb` partial uses a deprecated Turbo
attribute `data-turbo-cache=false`, which was deprecated on Feb 15 2023
in [this pull request](https://github.com/hotwired/turbo/pull/871).

Use more up-to-date attribute name called
[data-turbo-temporary](https://github.com/hotwired/turbo/pull/871) to
avoid deprecation issues and reduce developer confusion as
`data-turbo-temporary` is the only attributed mentioned in
[Turbo Drive's documentation](https://turbo.hotwired.dev/handbook/building#preparing-the-page-to-be-cached)

Closes #5664
Closes #5662

Signed-off-by: Carlos Antonio da Silva <carlosantoniodasilva@gmail.com>
2025-12-31 09:26:09 -03:00
Carlos Antonio da Silva
051f94a498 Pass locale with activatable / timeoutable hooks (#5815)
We need to explicitly pass the `locale` around from the options (passed
to `warden.authenticate!` for instance) or the `I18n.locale` when
logging out and redirecting the user via `throw :warden`, otherwise in a
multi-locale app we'd lose the locale previously set / passed around and
fallback to the default for that flash message.

This is a follow-up of the fixes in #5567 where we implemented the
locale passing logic down to the failure app, but it missed these places
where we were using `throw :warden`.

Closes #5812
2025-12-31 09:12:25 -03:00
nkroker
cd9c21a067 Fix message in controllers generator
Closes #5814

Signed-off-by: Carlos Antonio da Silva <carlosantoniodasilva@gmail.com>
2025-12-29 17:41:54 -03:00
Carlos Antonio da Silva
6f8f38d795 Update dependencies and test with Ruby 4.0
https://www.ruby-lang.org/en/news/2025/12/25/ruby-4-0-0-released/

We need to add `ostruct` as a dev dependency because it doesn't come
as a default gem with Ruby 4.0 anymore.

Lock minitest < 6 since v6 has some incompatibilities with released
versions of Rails that will be fixed in future versions.

This is something I didn't run into a few other gems, but SimpleForm
did, presumabily because it touches additional areas like AV tests.
2025-12-29 17:37:19 -03:00
dependabot[bot]
c8a64b549c Bump actions/checkout from 5 to 6 (#5809)
* Bump actions/checkout from 5 to 6

Bumps [actions/checkout](https://github.com/actions/checkout) from 5 to 6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...


* Bump supercharge/mongodb-github-action from 1.12.0 to 1.12.1 (#5808)

Bumps [supercharge/mongodb-github-action](https://github.com/supercharge/mongodb-github-action) from 1.12.0 to 1.12.1.
- [Release notes](https://github.com/supercharge/mongodb-github-action/releases)
- [Changelog](https://github.com/supercharge/mongodb-github-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/supercharge/mongodb-github-action/compare/1.12.0...1.12.1)

---
updated-dependencies:
- dependency-name: supercharge/mongodb-github-action
  dependency-version: 1.12.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...


Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-11-24 15:39:11 -03:00
Carlos Antonio da Silva
95618806c4 Remove no longer relevant test for mass assignment sanitization
This is no longer in Rails since v5, it's been extracted to
`protected_attributes`, and we're dropping support to older versions of
Rails in main.

https://github.com/rails/protected_attributes
2025-11-14 11:24:30 -03:00
Carlos Antonio da Silva
47e8716493 Remove post-install message
Hopefully by now everyone should've upgraded and figured this out.

[ci skip]
2025-11-14 10:38:10 -03:00
Carlos Antonio da Silva
c6b08ae7e1 Bump actions/checkout and mongodb-github-action
Bump actions/checkout from 3 to 5 (#5805)

Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 5.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3...v5)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Bump supercharge/mongodb-github-action from 1.11.0 to 1.12.0 (#5804)

Bumps [supercharge/mongodb-github-action](https://github.com/supercharge/mongodb-github-action) from 1.11.0 to 1.12.0.
- [Release notes](https://github.com/supercharge/mongodb-github-action/releases)
- [Changelog](https://github.com/supercharge/mongodb-github-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/supercharge/mongodb-github-action/compare/1.11.0...1.12.0)

---
updated-dependencies:
- dependency-name: supercharge/mongodb-github-action
  dependency-version: 1.12.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-11-03 18:52:57 -03:00
Carlos Antonio da Silva
ef2d4831ef Add missing frozen string literal comment to file [ci skip] 2025-10-31 15:14:34 -03:00
Carlos Antonio da Silva
97cf37eb56 Expand changelog [ci skip] 2025-10-31 15:03:46 -03:00
Carlos Antonio da Silva
b0867c998c Remove deprecated stuff (#5803)
All of these have been deprecated for years, if we're releasing a new
major version, let's take the opportunity to do some cleanup.

* Remove deprecated `:bypass` option from `sign_in` helper,
  use `bypass_sign_in` instead.
* Remove deprecated `devise_error_messages!` helper,
  use `render "devise/shared/error_messages", resource: resource` instead.
* Remove deprecated `scope` second argument from `sign_in(resource, :admin)`
  controller test helper, use `sign_in(resource, scope: :admin)` instead.
* Remove deprecated `Devise::TestHelpers`,
  use `Devise::Test::ControllerHelpers` instead.

Closes #5739
2025-10-31 13:52:34 -03:00
Carlos Antonio da Silva
fa052e5064 Remove some mongoid version checks from test suite
We no longer run against or support old Mongoid versions.
2025-10-31 11:26:19 -03:00
Carlos Antonio da Silva
dd7ee27f74 Bring back Mongoid official support (#5568)
Devise hasn't been tested with Mongoid since Rails version 5, only 4.x was still running those tests.

This enables the tests again on all currently supported Rails versions, with their respective mongoid supported versions. There were a couple of minor tweaks to make it happen, namely:

* The way we were dropping the session before doesn't work in later versions so I changed back to calling `purge!` which appears to work fine. We used to call `Mongoid.purge!` but that changed in #4686.
* Some of the configs in the Rails test app were setting Active Record values when outside of the AR ORM tests, updated those to make sure they are not set when running mongoid ORM tests.
* The validations added to the shared admin code in tests were only checking for Rails version 5.1, but we need to use the same check for AR 5.1 that is used in code, otherwise it will try to use methods not available in mongoid there.
2025-10-31 11:16:02 -03:00
Fuyutsubaki
b76d18d277 Fixed inconsistency between description and example in 'Running tests' section (#5802)
Expand test run examples to show running a specific line number or a matching regex.

[ci skip]
2025-10-31 09:44:11 -03:00
Carlos Antonio da Silva
f150357c1c Test with the released version of v7.0
Rails just released v7.0.10 which contains the fixes for Ruby 3.4 we
needed to get the build green, so no need to point to GH anymore.

https://rubyonrails.org/2025/10/29/new-rails-releases-and-end-of-support-announcement

Note that v7.0 has reached EOL for a while now.
2025-10-29 10:31:23 -03:00
Carlos Antonio da Silva
d60f810086 Use currently released version of rails-controller-testing
We pointed to github to fix issues with Ruby 2.7 and kwargs, but since
then a version 1.0.5 was released which includes those fixes.

There's a few more things in their main, but nothing we need if all is
green.
2025-10-24 11:36:46 -03:00
Carlos Antonio da Silva
5a82ad5740 Fix nokogiri deprecation warning
./devise/test/support/webrat/matchers.rb:6: warning:
    Nokogiri::CSS.parse is deprecated and will be removed in a future
    version of Nokogiri. Use Nokogiri::CSS::Parser#parse instead.
2025-10-24 11:33:57 -03:00
Carlos Antonio da Silva
1cf31d45eb Update to test with Rails v8.1.0 final 2025-10-24 11:23:10 -03:00
Carlos Antonio da Silva
141ef37339 Add Ruby 3.4 & build updates (#5801)
Update bundle to avoid 3.4 mutex_m require error.

Test against Rails 7.0 branch which contains Ruby 3.4 fixes.

Update changelog to mention Rails < 7.0 support being dropped.

Builds on top of https://github.com/heartcombo/devise/pull/5770
Closes https://github.com/heartcombo/devise/pull/5776
Closes https://github.com/heartcombo/devise/pull/5761
2025-10-21 17:28:05 -03:00
Greg Molnar
dbc8e77ea0 Make test suite work (#5770)
* Drop support for Rails < 7 and Ruby < 2.7
* Add tests to support to Rails 8+
* Fix test suite across all supported versions
2025-10-21 16:52:04 -03:00
Carlos Antonio da Silva
9c5e4d3c4e Update to new email, copyright, supported Ruby/Rails versions
Also remove contributors section and add supported ruby/rails versions
to the readme.

[ci skip]
2025-10-17 14:22:02 -03:00
soma-git-practice
fa4749dddc Expand reconfirmable comment on generator to match the module doc (#5748)
Explain the combined usage of `reconfirmable` with `send_email_changed_notification`.
[ci skip]
2025-10-17 13:41:42 -03:00
Carlos Antonio da Silva
b02bb5b75a Merge pull request #5746 from c960657/config-warden
Update argument name for config.warden [ci skip]

The argument for the block passed to `config.warden` is no a `Warden::Manager` instance but a `Warden::Config` instance, but it is confusingly named `manager` in the generated file.

Renaming this to `warden_config` for clarity.
2025-10-17 12:06:43 -03:00
Carlos Antonio da Silva
23058dcc62 Merge pull request #5738 from soma-git-practice/is_this_typo_models_in_lockable
Fix typo in comments [ci skip]
2025-10-16 10:17:40 -03:00
Carlos Antonio da Silva
cf93de390a Fix links to RubyDoc
Closes #5778
[ci skip]
2025-05-28 08:51:42 -03:00
Christian Schmidt
46cae66baf Update argument name for config.warden 2024-12-17 13:31:17 +01:00
soma
a78ad3f20c Fix typo in comments 2024-12-04 23:04:03 +09:00
Vasiliy Ermolovich
fec67f98f2 Merge pull request #5734 from heartcombo/password-length-dynamic
Use proc to set password length validator so it's possible to override it dynamically.
2024-11-29 13:15:22 +00:00
Vasiliy Ermolovich
560a1cb16f Use proc to set password length validation so it's possible to override it dynamically.
Co-authored-by: Manoj M J <manojmj92@gmail.com>
2024-11-29 14:10:07 +01:00
Vasiliy Ermolovich
dce20b78f5 Merge pull request #5732 from heartcombo/fix-format
Fix passing of format option to devise_for call.
2024-11-25 14:47:44 +00:00
Vasiliy Ermolovich
46c2c3913e Fix passing of format option to devise_for call. 2024-11-25 15:40:37 +01:00
Vasiliy Ermolovich
7eccc91f61 Merge pull request #5731 from heartcombo/fix-without-mailer-load
Fix Zeitwerk autoloading when ActionMailer is not present.
2024-11-25 12:57:51 +00:00
Vasiliy Ermolovich
af112a2f65 Fix Zeitwerk autoloading when ActionMailer is not present.
When ActionMailer is not defined we have empty app/mailers/devise/mailer.rb file and Zeitwerk doesn't
like that and errors with

```
expected file app/mailers/devise/mailer.rb to define constant Devise::Mailer
```

The fix is to tell Zeitwerk to ignore that file if ActionMailer constant if not defined.

I tried to write a spec for it but since specs are run in the same process it's hard to have two
Rails applications where one of them has ActionMailer define and the seconds one doesn't.
2024-11-25 13:57:07 +01:00
Vasiliy Ermolovich
90a3fa8599 Merge pull request #5730 from jeromedalbert/fix-ci
Fix Rails main CI
2024-11-25 07:37:25 +00:00
Jerome Dalbert
950721d6de Fix Rails 8 CI 2024-11-24 18:28:09 -08:00
Vasiliy Ermolovich
591b03a6c0 Merge pull request #5728 from heartcombo/lazy-routes-fix
Make Devise.mappings work with lazy loaded routes.
2024-11-24 15:27:27 +00:00
Vasiliy Ermolovich
24c47140e5 Make Devise.mappings work with lazy loaded routes.
Starting from Rails 8.0, routes are lazy-loaded by default in test and development environments.
However, Devise's mappings are built during the routes loading phase.
To ensure it works correctly, we need to load the routes first before accessing @@mappings.
2024-11-24 16:20:26 +01:00
Vasiliy Ermolovich
0f514f1413 Merge pull request #5514 from itay-grudev/master
Bug Fix: Devise Checkbox TRUE VALUES not compatible with HTML specs (missing "on" value)
2024-11-08 16:40:12 +00:00
Itay Grudev
12f0dd1608 Bug Fix: Devise Checkbox TRUE VALUES not compatible with HTML specs (missing "on" value)
See:
* https://html.spec.whatwg.org/multipage/input.html#checkbox-state-(type%3Dcheckbox)
* https://html.spec.whatwg.org/multipage/input.html#dom-input-value-default-on

This issue causes the remember me functionality not to work correctly, especially when overriding the default styles as check boxes by default in all major browsers send the value `on` as required by the HTML specifications.

See also:

https://stackoverflow.com/questions/5987075/devise-remember-me-not-working-localhost-issue
2024-11-08 18:13:05 +02:00
Vasiliy Ermolovich
12c796e499 Merge pull request #5719 from kazuyainoue0124/fix_typos_in_readme
Remove unnecessary closing parenthesis in README [ci skip]
2024-10-22 18:49:08 +00:00
Vasiliy Ermolovich
baf0d8eff2 Update CHANGELOG.md 2024-10-22 20:45:41 +02:00
Vasiliy Ermolovich
5b15bbee7a Merge pull request #5645 from BroiSatse/main
Removed now obsolete SecretKeyFinder
2024-10-22 18:33:18 +00:00
Kazuya INOUE
25f806e270 Remove unnecessary closing parenthesis in README 2024-10-06 23:14:48 +09:00
Vasiliy Ermolovich
72884642f5 Merge pull request #5706 from abr-storm/main
Rails 8: Update route registration to use keyword arguments
2024-08-18 09:20:19 +00:00
Alex Brook
54e4b267a5 splat keyword arguments when registering routes 2024-08-17 17:34:36 +01:00
Vasiliy Ermolovich
0a2505ee23 Merge pull request #5708 from jeromedalbert/fix-ci-rails-main
Rails 8: Fix CI sqlite3 error for Gemfile-rails-main
2024-08-17 09:58:10 +00:00
Jerome Dalbert
1d859b5db0 Fix CI sqlite3 error for Gemfile-rails-main 2024-08-17 01:25:06 -07:00
Carlos Antonio da Silva
a259ff3c28 Make it clearer that we're targeting a v5 going forward
Use a "beta" version to make that even more explicit.
2024-04-10 09:45:08 -03:00
Carlos Antonio da Silva
9a7176f727 Cleanup changelog, point to 4-stable branch for previous changes
main is targetting a v5 with some possible breaking changes, for main
it's mainly dropping support for older Ruby/Rails versions, but more
might come.

[ci skip]
2024-04-10 09:43:27 -03:00
Carlos Antonio da Silva
21deb5c145 Bump year [ci skip] 2024-04-09 16:58:24 -03:00
Carlos Antonio da Silva
6ee12d1521 Merge pull request #5668 from berkos/update-ci
Adds Ruby 3.3 to CI
2024-04-09 14:20:06 -03:00
Antonis Berkakis
c80026d955 Update CI to run to include Ruby 3.3
- Exclude Rubies >=3.1 from latest main Gemfile as it runs on 7.2
2024-04-09 14:56:07 +01:00
Artin Boghosian
bb18f4d380 Update mapping.rb (#5673)
Fix grammar on comment for .find_scope! [ci skip]
2024-02-13 09:22:46 -03:00
Stanislaw Klajn
b6d64ba525 Removed now obsolete SecretKeyFinder 2023-10-26 10:41:52 +01:00
Carlos Antonio da Silva
e2242a95f3 Merge pull request #5641 from henryaj/patch-1
Fix README anchor link
2023-10-13 11:56:48 -03:00
Henry Stanley
c4578d3240 Fix README anchor link
Fixes link to Active Job Integration in README.
2023-10-13 15:54:36 +01:00
Carlos Antonio da Silva
5667ceaa1e Merge pull request #5600 from heartcombo/rm-drop-support-to-old-rubies-and-rails
Drop support to EOL rubies and Rails
2023-10-13 11:23:18 -03:00
Carlos Antonio da Silva
4d18d81311 Respect locale set by controller in the failure app (#5567)
A common usage of I18n with different locales is to create some around
callback in the application controller that sets the locale for the
entire action, via params/url/user/etc., which ensure the locale is
respected for the duration of that action, and resets at the end.

Devise was not respecting the locale when the authenticate failed and
triggered the failure app, because that happens in a warden middleware
right up in the change, by that time the controller around callback had
already reset the locale back to its default, and the failure app would
just translate flash messages using the default locale.

Now we are passing the current locale down to the failure app via warden
options, and wrapping it with an around callback, which makes the
failure app respect the set I18n locale by the controller at the time
the authentication failure is triggered, working as expected. (much more
like a normal controller would.)

I chose to introduce a callback in the failure app so we could wrap the
whole `respond` action processing rather than adding individual `locale`
options to the `I18n.t` calls, because that should ensure other possible
`I18n.t` calls from overridden failure apps would respect the set locale
as well, and makes it more like one would implement in a controller. I
don't recommend people using callbacks in their own failure apps though,
as this is not going to be documented as a "feature" of failures apps,
it's considered "internal" and could be refactored at any point.

It is possible to override the locale with the new `i18n_locale` method,
which simply defaults to the passed locale from the controller.

Closes #5247
Closes #5246

Related to: #3052, #4823, and possible others already closed.
Related to warden: (may be closed there afterwards)
https://github.com/wardencommunity/warden/issues/180
https://github.com/wardencommunity/warden/issues/170
2023-10-13 11:20:29 -03:00
Carlos Antonio da Silva
63939c121e Remove deprecated options argument from update methods
They were added to support an old/deprecated feature of Rails, as the
message was saying, we can now remove them from the code as well.
2023-10-13 11:02:45 -03:00
Carlos Antonio da Silva
49e4a991cf Remove some more code added to support older versions
Also change back to run CI on ubuntu-latest which should work with all
Ruby versions supported now.
2023-10-13 11:02:45 -03:00
Carlos Antonio da Silva
72b421e571 Update gemfile readme references 2023-10-13 10:44:06 -03:00
Carlos Antonio da Silva
23633b70f0 Bring back Ruby 2.7 support
It's EOL but the current versions of Rails are still supporting it, so
it makes sense for us to keep supporting it as well. And it doesn't give
us any extra maintenance burden as older versions have been doing.
2023-10-13 10:44:05 -03:00
Rafael Mendonça França
c8207373ea Drop support to all EOL rails versions 2023-10-12 16:52:01 -03:00
Rafael Mendonça França
c4701866ae Drop support to EOL Rubies
All Ruby 2.x are EOL now.
2023-10-12 16:49:10 -03:00
Carlos Antonio da Silva
e688b2f256 Merge branch '4-stable' 2023-10-11 19:12:53 -03:00
Carlos Antonio da Silva
1d6658097e Release v4.9.3 2023-10-11 19:08:36 -03:00
Carlos Antonio da Silva
dcbfb32e66 Merge pull request #5640 from nmaggioni/nm_config_template_typo
Fix typo in config template
2023-10-11 11:41:16 -03:00
Carlos Antonio da Silva
9064ecbf15 Merge pull request #5640 from nmaggioni/nm_config_template_typo
Fix typo in config template
2023-10-11 11:40:50 -03:00
Niccolò Maggioni
4484eddc52 Fix caret placement typo 2023-10-11 16:35:35 +02:00
Carlos Antonio da Silva
c146b25f31 Better clarify need to override internal_methods
Co-authored-by: Eebs Kobeissi <ebrahim.kobeissi@gmail.com>
2023-10-10 19:51:06 -03:00
Carlos Antonio da Silva
9a08620378 Update changelog with Rails 7.1 mention [ci skip] 2023-10-10 19:51:04 -03:00
Carlos Antonio da Silva
407f223c65 Fix test warning about deprecated cache format in Rails 7.1 2023-10-10 11:39:30 -03:00
Carlos Antonio da Silva
f2a42abbf4 Ensure _prefixes is not available as an action method on controllers
There was a change introduced in Rails 7.1 that causes all public
actions of non-abstract controllers to become action methods, even if
they happen to match the name of an internal method defined by abstract
`ActionController::Base` and such, which is the case with `_prefixes`.

This change was intentional, it allows for example to have an action
called `status`, which is an internal method, and that is properly
managed as an action method now. However, it broke Devise due to
overriding `_prefixes`, which is a public method of Action Controller.

To fix, we are simply ensuring we keep `_prefixes` as an internal method
rather than action method, which matches previous behavior for this
particular method/implementation in Devise.

Ref: https://github.com/rails/rails/pull/48699
2023-10-10 11:29:29 -03:00
Carlos Antonio da Silva
218d14a227 Lock ubuntu version to 20.04 to workaround older Ruby build issues
Trying to get the build fully green for now.
2023-10-10 11:29:29 -03:00
Carlos Antonio da Silva
501ae58a25 Lock loofah on Rails <= 5.2
There's some incompatibility issue with loofah there since it uses an
older version of nokogiri, so I'm locking it on those older versions to
try to get a green build again there.
2023-10-10 11:29:29 -03:00
Carlos Antonio da Silva
373d83cc9d Use Bundler 1.x with Ruby <= 2.2
Here we go again.
2023-10-10 11:29:29 -03:00
Carlos Antonio da Silva
fb7faf7466 Fix code to support older versions of Ruby
We still support super old versions, yes, and it doesn't like `ensure`
without a `begin..end` unfortunately.

I plan to remove this support soon, but for now I don't want to stop
supporting it yet.
2023-10-10 11:29:29 -03:00
Carlos Antonio da Silva
9784555304 Merge pull request #5628 from soartec-lab/fix/dedicated_active_support_deprecation
Fixed missing migration to dedicated deprecator
2023-10-10 11:29:29 -03:00
Rafael Mendonça França
13cb6e269d Merge pull request #5599 from etiennebarrie/rails-edge-deprecations
Fix Rails main deprecations
2023-10-10 11:29:29 -03:00
Rafael Mendonça França
a7d64ae313 Merge pull request #5583 from etiennebarrie/deprecator
Use a dedicated ActiveSupport::Deprecation
2023-10-10 11:29:29 -03:00
Carlos Antonio da Silva
34cb23ed9c Fix mocha warnings with hash vs kwargs 2023-10-10 11:29:27 -03:00
Carlos Antonio da Silva
14aa380d80 Update mocha to fix issue with Minitest compatibility layer
There's a number of deprecation warnings to work through related to
mocha updates in v2+, we'll get through those on a separate change.
https://github.com/freerange/mocha/blob/main/RELEASE.md#200

The main issue is with Minitest, fixed in v2.1:
https://github.com/freerange/mocha/blob/main/RELEASE.md#210

Also run `bundle update` on the main Gemfile to update all dependencies
there to latest.
2023-10-10 10:51:46 -03:00
Carlos Antonio da Silva
c4c8fad66c Use Rails 7.1 on main Gemfile and create a new one for 7.0 2023-10-10 10:51:46 -03:00
Carlos Antonio da Silva
f6e73e5b5c Merge pull request #5628 from soartec-lab/fix/dedicated_active_support_deprecation
Fixed missing migration to dedicated deprecator
2023-09-12 21:39:56 -03:00
soartec-lab
f8f035155b Fixed missing migration to dedicated deprecator 2023-09-12 11:10:32 +09:00
Carlos Antonio da Silva
9f80dc2562 Merge pull request #5621 from santu-essence/code-improvement/minor-changes
Inherit from only base.
2023-08-17 10:16:42 -03:00
santu essence
5b22538ae5 Inherit from only base. 2023-08-17 10:25:06 +05:30
Rafael Mendonça França
ec0674523e Merge pull request #5416 from DerekCrosson/main
Make copying and pasting terminal commands easier
2023-06-09 19:58:00 -04:00
Rafael Mendonça França
1b0ef1d2fe Merge pull request #5508 from Edouard-chin/ec-omniauth-allowed-methods
Use Omniauth.allowed_methods' as routing verbs for the auth path:
2023-06-09 19:50:07 -04:00
Edouard CHIN
4f82235630 Use Omniauth.allowed_methods' as routing verbs for the auth path:
- ### Context

  Since version 2.0.0, Omniauth no longer recognizes `GET` request
  on the auth path (`/users/auth/<provider>`). `POST` is the only
  verb that is by default recognized in order to mitigate CSRF
  attack. 66110da85e/lib/omniauth/strategy.rb (L205)

  Ultimatelly, when a user try to access `GET /users/auth/facebook`,
  Devise [passthru action](6d32d2447c/app/controllers/devise/omniauth_callbacks_controller.rb (L6))
  will be called which just return a raw 404 page.

  ### Problem

  There is no problem per se and everything work. However the
  advantage of not matching GET request at the router layer allows
  to get that same 404 page stylized for "free" (Rails ending up
  rendering the 404 page of the app).

  I believe it's also more consistent and less surprising for users
  if this passthru action don't get called.

  ### Drawback

  An application can no longer override the `passthru` to perform
  the logic it wants (i.e. redirect the user).

  If this is a dealbreaker, feel free to close this PR :).
2023-06-09 23:46:12 +00:00
Rafael Mendonça França
8bb41ad98e Merge pull request #5601 from heartcombo/dependabot/github_actions/supercharge/mongodb-github-action-1.9.0
Bump supercharge/mongodb-github-action from 1.3.0 to 1.9.0
2023-06-09 19:43:28 -04:00
Rafael Mendonça França
e81ec9c436 Merge pull request #5595 from louim/bugfix/mailer-defaults-lambda-arity
Make sure Mailer defaults :from and :reply_to are handled correctly
2023-06-09 19:42:53 -04:00
Louis-Michel Couture
ed1c2a1adb Make sure Mailer defaults :from and :reply_to are handled correctly
Rails allow procs and lambda with either zero or more argument. Devise
however always tried to call instance_eval on those values, which does
always pass one argument: self.

There was a PR to fix this specific problem in Devise https://github.com/heartcombo/devise/pull/4627,
before the arity check was fixed in rails itself: https://github.com/rails/rails/pull/30391.

But even if the problem was fixed in Rails, Devise was still calling
the proc/lambas with instance_eval. That meant the fix added to Rails
did not apply to Devise.

The fix is to let Rails handle the :from and :reply_to defaults. We do
that by unsetting the headers instead of trying to replicate Rails handling
in Devise. This lets Rails handle it when setting up the mailer.
2023-06-09 23:30:51 +00:00
Rafael Mendonça França
9be24c0ae4 Merge pull request #5598 from soartec-lab/task/removed-older-deprecation-warning
Removed deprecations warning output for `Devise::Models::Authenticatable::BLACKLIST_FOR_SERIALIZATION`
2023-06-09 19:24:40 -04:00
Rafael Mendonça França
19d9dabc80 Merge pull request #5480 from glaucocustodio/patch-1
Use bundle add instead
2023-06-09 19:23:39 -04:00
dependabot[bot]
285dc5d2fc Bump supercharge/mongodb-github-action from 1.3.0 to 1.9.0
Bumps [supercharge/mongodb-github-action](https://github.com/supercharge/mongodb-github-action) from 1.3.0 to 1.9.0.
- [Release notes](https://github.com/supercharge/mongodb-github-action/releases)
- [Changelog](https://github.com/supercharge/mongodb-github-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/supercharge/mongodb-github-action/compare/1.3.0...1.9.0)

---
updated-dependencies:
- dependency-name: supercharge/mongodb-github-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-09 23:23:28 +00:00
Rafael Mendonça França
aeb24bf804 Merge pull request #5504 from petergoldstein/feature/add_dependabot_for_github_actions
Add Dependabot for GitHub Actions
2023-06-09 19:23:08 -04:00
Rafael Mendonça França
aca0b24118 Merge pull request #5494 from iainbeeston/br-has-no-closing-slash
Replaced `<br/>` with `<br>`
2023-06-09 19:22:46 -04:00
soartec-lab
e524a3d22d Removed deprecations warning output for Devise::Models::Authenticatable::BLACKLIST_FOR_SERIALIZATION 2023-06-09 23:20:47 +00:00
Iain Beeston
1a3d1ae350 Replaced <br/> with paragraph tags
In regular HTML `<br>` is a void element, so it

Many of the shared templates used by devise use `<br/>`
to separate lines, which is invalid html because `<br>`
doesn't need a closing tag or a closing slash. See the
WhatWG spec here:
https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-br-element

Also, the WhatWG spec uses `<p>` tags to separate
`<label>` and `<input>` tags rather than `<br>`, see
here:
https://html.spec.whatwg.org/multipage/input.html

To clean this up I've replaced `<br/>` with paragraph
tags throughout all of the templates.

This reverts b86c1c241b
2023-06-09 22:36:51 +00:00
Rafael Mendonça França
fc731a88bb Add devcontainer configuration
This will allow contributors to setup their environment using VS Code
container or Codebases.
2023-06-09 22:34:44 +00:00
Rafael Mendonça França
6d058bfde8 Fix tests after #5515 2023-06-09 22:34:19 +00:00
Rafael Mendonça França
ad172bd547 Merge pull request #5599 from etiennebarrie/rails-edge-deprecations
Fix Rails main deprecations
2023-06-09 18:16:49 -04:00
Rafael Mendonça França
1195c6f0d6 Merge pull request #5515 from okyanusoz/patch-1
Fix a grammatical error
2023-06-09 18:16:38 -04:00
Rafael Mendonça França
54a624a34b Merge pull request #5583 from etiennebarrie/deprecator
Use a dedicated ActiveSupport::Deprecation
2023-06-09 18:12:01 -04:00
Étienne Barrié
48e115334b Remove MigrationContext deprecation in 7.1
DEPRECATION WARNING: SchemaMigration no longer inherits from
ActiveRecord::Base. If you want to use the default connection, remove
this argument. If you want to use a specific connection, instantiate
MigrationContext with the connection's schema migration, for example
`MigrationContext.new(path, Dog.connection.schema_migration)`.
2023-06-08 11:49:34 +02:00
Étienne Barrié
c809adeeed Use show_exceptions = :none in Rails 7.1
DEPRECATION WARNING: Setting action_dispatch.show_exceptions to false is
deprecated. Set to :none instead.
2023-06-08 11:49:19 +02:00
Étienne Barrié
e1298c87d7 Add deprecator to the application's deprecators 2023-06-08 11:30:38 +02:00
Étienne Barrié
882dd70a9f Use a dedicated ActiveSupport::Deprecation
Rails 7.1 will deprecate using the singleton ActiveSupport::Deprecation
instance. This defines one for the gem and uses it.
2023-04-07 00:15:10 +02:00
Carlos Antonio da Silva
4b72064bfc Add missing changelog version [ci skip] 2023-04-03 09:25:06 -03:00
Carlos Antonio da Silva
8b0b849a67 Release v4.9.2 2023-04-03 09:23:02 -03:00
Carlos Antonio da Silva
4f849f4fa9 Bring back `Devise.activerecord51? and deprecate it
Even though this is considered an internal / non-public / nodoc method,
it seems some libraries relied on it internally, causing some breakage.

Known libraries so far are `devise-security` and
`devise-pwned_password`.

Closes #5580
2023-04-03 09:21:56 -03:00
Carlos Antonio da Silva
3926e6d9eb Release v4.9.1 2023-03-31 09:39:17 -03:00
Carlos Antonio da Silva
506eaf495d Merge pull request #5576 from heartcombo/ca-multiple-orms
Improve support for Devise in apps with multiple ORMs loaded
2023-03-30 17:54:30 -03:00
Carlos Antonio da Silva
8dbe5b2fe8 Merge pull request #5573 from heartcombo/ca/failure-app-respect-redirect
Respect redirect status code when recalling the action
2023-03-30 17:29:35 -03:00
Carlos Antonio da Silva
207ddc5127 Improve support for Devise in apps with multiple ORMs loaded
Devise is able to work with a specific ORM, either Active Record or
Mongoid, but nothing stops apps from using multiple ORMs within the same
application -- they just need to pick one to use with Devise. That's
generally determined by the require that is added to the Devise
initializer, that will load up either ORM's extensions so you can call
things like `devise` on your model to set it up.

However, some conditional logic in Devise, more specifically around
dirty tracking, was only considering having Active Record loaded up
after a certain version, to determine which methods to call in parts of
the implementation. In a previous change we refactored all that dirty
tracking code into this `OrmDirtyTracking` module to make it easier to
view all the methods that were being conditionally called, and now we're
repurposing this into a more generic `Orm` module (that's nodoc'ed by
default) so that upon including it, we can conditionally include the
proper dirty tracking extensions but also check whether the including
model is really Active Record or not, so we can trigger the correct
dirty tracking behavior for Mongoid as well if both are loaded on the
same app, whereas previously the Mongoid behavior would always use the
new Active Record behavior, but support may differ.

While we are also working to ensure the latest versions of Mongoid are
fully running with Devise, this should improve the situation by giving
apps with multiple ORMs loaded a chance to rely on some of these Devise
bits of functionality better now that weren't working properly before
without some monkey-patching on their end.

Closes #5539
Closes #4542
2023-03-23 19:16:23 -03:00
Carlos Antonio da Silva
367ea42762 Refactor dirty tracking conditionals for different versions (#5575)
We have an number of conditions due to how dirty tracking changed around
Rails 5.1, that implement methods using one or another method call. I
might need more of this for mongo upgrades based on an initial
investigation, plus this makes the code really hard to reason about
sometimes with these many conditionals.

While I want to drop support for older versions of Rails soon, this
centralization of dirty methods that are used by devise conditionally
simplifies the usage considerably across the board, moves the version
condition to a single place, and will make it easier to refactor later
once we drop older Rails version by simply removing the `devise_*`
versions of the methods, alongside the prefix on the method calls for
the most part, since those methods follow the naming of the newer Rails
versions.
2023-03-23 19:11:11 -03:00
Carlos Antonio da Silva
89a08357d6 Uses the responder redirect_status when recall returns a redirect
It appears some people use the recall functionality with a redirect
response, and Devise starting on version 4.9 was overriding that status
code to the configured `error_status` for better Turbo support, which
broke the redirect functionality / expectation.

While I don't think it's really great usage of the recall functionality,
or at least it was unexpected usage, it's been working like that
basically forever where recalling would use the status code of the
recalled action, so this at least keeps it more consistent with that
behavior by respecting redirects and keeping that response as a redirect
based on the configured status, which should also work with Turbo I
believe, and makes this less of a breaking change.

Closes #5570
Closes #5561 (it was closed previously, but related / closes with an
actual change now.)
2023-03-20 18:18:54 -03:00
Carlos Antonio da Silva
eed51179c7 Add explicit test for respecting the error_status responder config
While introducing this on turbo, looks like no specific test was added,
so this at least covers that a bit.

It needs some conditional checks since not all supported Rails +
Responders version work with the customization, so there's one test for
the hardcoded status version too, which can be removed in the future.
2023-03-20 17:58:48 -03:00
Peter Goldstein
11b6a99e88 Add Dependabot for GitHub Actions 2023-03-19 12:55:13 -04:00
Carlos Antonio da Silva
232c855c54 Fix tests with Rails main
Rails main / 7.1.0.alpha introduced a change to improve typography by
default, by converting all apostrophes to be single quotation marks.
https://github.com/rails/rails/pull/45463

The change caused all our text based matching to fail, this updates the
tests to ensure compatibility.

Model tests were changed to test against the error type & information
rather than the translated string, which I think is an improvement
overall that should make them a little less brittle. I thought of using
[of_kind?] but that isn't available on all Rails versions we currently
support, while `added?` is. The drawback is that `added?` require full
details like the `:confirmation` example which requires the related
attribute that is being confirmed, but that's a small price to pay.

Integration tests were changed to match on a regexp that accepts both
quotes. I could've used a simple `.` to match anything there, but
thought I'd just keep it specific for clarity on what it is really
expected to match there. Plus, since it's integration testing against a
rendered response body, it's better to match the actual text rather than
resort on other ways. (like using I18n directly, etc.)

[of_kind?] https://api.rubyonrails.org/classes/ActiveModel/Errors.html#method-i-of_kind-3F
2023-03-17 10:59:55 -03:00
Carlos Antonio da Silva
afec6655c7 Update bundle 2023-03-17 10:59:51 -03:00
Carlos Antonio da Silva
7d1dc56fdb Merge branch 'ca-replace-refute-assert-not'
Prefer `assert_not*` helpers.

Closes #5158
2023-03-02 19:15:18 -03:00
Carlos Antonio da Silva
890bd9e3b5 Replace usage of assert ! with actual assert_not helper 2023-03-02 18:41:44 -03:00
Carlos Antonio da Silva
1e63c640c0 Update a few other instances that were using refute methods
Prefer assert_not* in general.
2023-03-02 18:40:35 -03:00
tabakazu
8acbdd6d93 Replace matcher refute to assert_not 2023-03-02 18:38:04 -03:00
Carlos Antonio da Silva
400eaf7fbe Remove not used constant
It's only been almost ~10 years since we removed it's usage. :D
dff7891b97
2023-03-01 22:50:56 -03:00
Carlos Antonio da Silva
df8b79a53f Fix added tests for sign_in_after_reset_password per resource class
We can't just "swap" those model properties, as that sets instance vars
on the classes that get reverted to their "previous" value, which ends
up leaving the instance vars set as `nil`. However, our logic for those
model/class properties actually checks for `defined?` as a way to
override them, and delegates up to `Devise` global config if they are
not defined, so leaving instance vars back with `nil` values isn't
enough, we need to actually remove them.

This introduces a new test helper specifically for overriding those
model configs so that we can do proper cleanup.
2023-03-01 22:50:03 -03:00
Carlos Antonio da Silva
ef6c73b221 Merge branch 'feature/password-reset-configuration'
Closes #5429
2023-03-01 22:20:54 -03:00
Carlos Antonio da Silva
c7a719a979 Add changelog for #5429
[ci skip]
2023-03-01 22:20:37 -03:00
Matt Redmond
60c5774ff4 Delegate sign_in_after_reset_password to resource class
Allows resource class scopes to overrides the global configuration for sign in after reset password behaviour.
2023-03-01 22:18:16 -03:00
Peter Goldstein
90f46bac37 Monkeypatch webrat for Nokogiri compatibility
This is an attempt to address the Webrat / Nokogiri compatibility issue
[discussed here]. It monkeypatches Webrat to explicitly add the old
default arguments to the invocation of to_xpath.

Move monkey patch to its own file under test/support/webrat.
I really need to get rid of webrat.

Closes #5475

[discussed here] https://github.com/sparklemotion/nokogiri/issues/2469
2023-03-01 22:06:40 -03:00
Carlos Antonio da Silva
ee8f0f8e83 Fix frozen string in validatable, use multiline string instead. (#5563)
Expand tests to check for the actual validatable exception message

This was raising a `FrozenError` on Ruby < 3 where interpolated strings
were considered frozen. This [changed in Ruby 3], since such strings are
dynamic there's no point in freezing them by default.

The test wasn't catching this because `FrozenError` actually inherits
from `RuntimeError`:

>> FrozenError.ancestors
=> [FrozenError, RuntimeError, StandardError, Exception, Object ...]

So the exception check passed. Now we're also checking for the error
message to ensure it raised the exception we really expected there.

Closes #5465

[changed in Ruby 3] https://bugs.ruby-lang.org/issues/17104

Co-authored-by: Martin <martin@edv-beratung-meier.de>
2023-03-01 19:56:25 -03:00
Carlos Antonio da Silva
41e2db2120 It is not required to copy the views when customizing controllers
It is indeed recommended for consistency, but Rails will be able to find
the views under `devise/` due to inheritance still, so make that a bit
clearer in the readme docs about customizing controllers, explaining
that copying or moving the views is an optional step.

Closes #5526
[ci skip]
2023-02-20 10:26:59 -03:00
Carlos Antonio da Silva
7f419bf99a Release Devise v4.9.0 2023-02-17 11:14:03 -03:00
Carlos Antonio da Silva
44f0fd741f Update copyright year [ci skip]
Closes #5556
2023-02-16 09:10:59 -03:00
Carlos Antonio da Silva
2d655ea46e Merge pull request #5554 from JunichiIto/fix-unhappy-markup
Remove p tag since p tags cannot contain other block elements
2023-02-14 08:58:23 -03:00
Junichi Ito
49ed129c40 Replce p tag with div since p tags cannot contain other block elements 2023-02-14 08:34:26 +09:00
Carlos Antonio da Silva
8e2e3f6fda Merge pull request #5548 from heartcombo/ca-turbo
Integrate with Hotwire/Turbo by configuring error and response statuses
2023-02-09 18:14:01 -03:00
Carlos Antonio da Silva
31c4f31ef4 Tweak comment about overriding Devise.responder
Albeit it's not super recommended, it's possible and even mentioned in
the changelog/wiki in case the app has some additional responder logic
that needs to be applied to Devise across the board.
2023-02-09 08:51:42 -03:00
Carlos Antonio da Silva
8606e1e671 Expand changelog/readme with info about Turbo vs rails-ujs behavior
Explain a bit more about how `data-confirm` and `data-method` need to be
updated to the turbo versions `data-turbo-confirm` and
`data-turbo-method`, respectively. (and depending on its usage.)

[ci skip]
2023-02-07 11:05:53 -03:00
Carlos Antonio da Silva
2df5efcece Add post install message pointing to the changelog and new upgrade guide
There's some additional information in the wiki upgrade guide for those
interested, but most of it is covered in the changelog and should
suffice.

The post install message should help guide people upgrading to make sure
they know what to do in this new version, since some may be using Turbo
out there with custom responders and failure apps and those would have
to be removed in order to use these new changes fully. Hopefully that's
enough of a nudge for them.
2023-02-03 15:41:30 -03:00
Carlos Antonio da Silva
43c349a2fc Point version to v4.9.0.alpha for now
Just want to have something different than the currently released
version to test out more easily. Plus, this is probably going to become
v4.9.0 final soon anyway.
2023-02-03 15:26:24 -03:00
Carlos Antonio da Silva
0d392fa49f Use the released version of responders v3.1.0
Unfortunately we can't enforce the version in the gemspec because
responders only supports Rails 5.2 now, and Devise still supports
previous versions.

We'll drop support for those in a future major release, so for now I'm
not adding any version.

This also adds a warning in case someone is using an older version of
responders and tries to set the error/redirect statuses via Devise, so
that they know what to do (upgrade responders) in that case.
2023-02-03 14:09:42 -03:00
Carlos Antonio da Silva
d0f0853c75 Remove CodeClimate badge
It's not working right now, and we haven't used it in like forever
to drive anything.

Closes #5549

[ci skip]
2023-02-03 11:50:42 -03:00
Carlos Antonio da Silva
88625d488f Use button_to to generate a POST form, disable turbo with OmniAuth
This changes the OmniAuth "sign in" links to use buttons, which can be
wrapped in an actual HTML form with a method POST, making them work
better with and without Turbo in the app. It doesn't require rails/ujs
anymore in case of a non-Turbo app, as it previously did with links +
method=POST.

Turbo is disabled for those OmniAuth buttons, as they simply don't work
trying to follow the redirect to the OmniAuth provider via fetch,
causing CORS issues/errors.
2023-02-01 11:29:17 -03:00
Carlos Antonio da Silva
f08e0ad24a Integrate with Hotwire/Turbo by configuring error and response statuses
Treat `:turbo_stream` request format as a navigational format, much like
HTML, so Devise/responders can work properly.

Allow configuring the `error_status` and `redirect_status` using the
latest responders features, via a new custom Devise responder, so we can
customize the both responses to match Hotwire/Turbo behavior, for
example with `422 Unprocessable Entity` and `303 See Other`,
respectively. The defaults aren't changing in Devise itself (yet), so it
still responds on errors cases with `200 OK`, and redirects on non-GET
requests with `302 Found`, but new apps are generated with the new
statuses and existing apps can opt-in. Please note that these defaults
might change in a future release of Devise.

PRs/Issues references:

https://github.com/heartcombo/devise/pull/5545
https://github.com/heartcombo/devise/pull/5529
https://github.com/heartcombo/devise/pull/5516
https://github.com/heartcombo/devise/pull/5499
https://github.com/heartcombo/devise/pull/5487
https://github.com/heartcombo/devise/pull/5467
https://github.com/heartcombo/devise/pull/5440
https://github.com/heartcombo/devise/pull/5410
https://github.com/heartcombo/devise/pull/5340

https://github.com/heartcombo/devise/issues/5542
https://github.com/heartcombo/devise/issues/5530
https://github.com/heartcombo/devise/issues/5519
https://github.com/heartcombo/devise/issues/5513
https://github.com/heartcombo/devise/issues/5478
https://github.com/heartcombo/devise/issues/5468
https://github.com/heartcombo/devise/issues/5463
https://github.com/heartcombo/devise/issues/5458
https://github.com/heartcombo/devise/issues/5448
https://github.com/heartcombo/devise/issues/5446
https://github.com/heartcombo/devise/issues/5439
2023-01-31 11:02:01 -03:00
Carlos Antonio da Silva
3632ddf674 Remove XML serializer from a couple gemfiles missed previously
It looks like I missed removing it when XMl was replaced with JSON
across our test suite in a793472a3e.
2023-01-31 10:12:24 -03:00
Carlos Antonio da Silva
cddba28945 Bundle update 2023-01-27 17:15:20 -03:00
Carlos Antonio da Silva
032c4476ae Merge branch 'ca-build' 2023-01-19 11:44:25 -03:00
Carlos Antonio da Silva
319d9fa648 Run with the latest rubygems on newer Ruby versions
Rails master on Ruby 2.7/3.0 is failing with the following error:

    Resolving dependencies...
    Could not find compatible versions
    Because every version of rails depends on RubyGems >= 3.3.13
      and Gemfile-rails-main depends on rails >= 0,
      RubyGems >= 3.3.13 is required.
    So, because current RubyGems version is = 3.1.6,
      version solving has failed.

Trying to run with the latest available rubygems to see if that can fix
the problem, but sticking to the "default" rubygems version on older
Ruby versions to avoid build issues there.
2023-01-19 09:58:53 -03:00
Carlos Antonio da Silva
59bedaa1e7 Attempt to get the build running on Ruby 2.2
It appears we're getting a newer version of this multipart-post
dependency, which doesn't work well with Ruby 2.2 by using
`Object.deprecate_constant`, resulting in the following error:

    .../multipart-post-2.2.0/lib/multipart/post/parts.rb:152:in `<top (required)>':
    undefined method `deprecate_constant' for Object:Class (NoMethodError)

Hopefully by locking on a previous version we can just get the build
back to green for now.
2023-01-17 14:47:26 -03:00
Carlos Antonio da Silva
fc1ac76ddf Add support to Ruby 3.2 (no changes needed) 2023-01-17 14:29:38 -03:00
okyanusoz
41003bf5de Update new.html.erb 2022-08-30 17:06:16 +03:00
Carlos Antonio da Silva
6d32d2447c Merge pull request #5503 from ak15/main
Fix typo in lockable documentation
2022-06-27 10:37:35 -03:00
Atul Kanswal
d4bf52bdfd Update lockable.rb
Documentation Confusion
2022-06-27 16:28:03 +05:30
Carlos Antonio da Silva
f8d1ea90bc Merge pull request #5484 from heartcombo/ca-build
Fix build
2022-04-22 13:29:19 -03:00
Carlos Antonio da Silva
2fa9303ab3 Use new method to reset CSRF exposed via the request object
This simplifies the logic considerably, as we don't need to reach out to
what seems more internal-ish implementation of Rails with the
interaction between the request and controller objects.

b925880914
2022-04-22 12:56:10 -03:00
Carlos Antonio da Silva
b5172a0cdb Fix csrf cleanup for Rails 7.1 (main)
Rails implemented a CSRF token storage strategy to allow storing the
CSRF tokens outside of the sessios (for example, in an encrypted
cookie), and changed how the value is kept around during the request
cycle, by using a request.env value.

We still want to ensure the final session value is cleaned correctly in
the test, but the implementation needed to change since we can't simply
delete from the session anymore, we need to make sure we call the Rails
methods for resetting the current storage strategy so it works with all
of them.

https://github.com/rails/rails/pull/44283
2022-04-22 11:08:44 -03:00
Carlos Antonio da Silva
e1c53d6580 Check for empty response body on redirect with Rails main (future 7.1)
Rails is no longer returning a message with the response body on
redirects, just an empty body.

https://github.com/rails/rails/pull/44554
2022-04-22 09:30:58 -03:00
Carlos Antonio da Silva
875217d8c1 Only set property for Rails 7, it has been removed on master
https://github.com/rails/rails/pull/44827
2022-04-22 09:17:46 -03:00
Carlos Antonio da Silva
55eabee800 Use https source for github repos with Bundler 1.x
GitHub no longer supports the git:// protocol, which was the default in
Bundler 1.x.

From the build:

    The unauthenticated git protocol on port 9418 is no longer supported.
    Please see https://github.blog/2021-09-01-improving-git-protocol-security-github/
    for more information.
2022-04-22 09:17:46 -03:00
Carlos Antonio da Silva
8d4c3647a7 Update bundle 2022-04-22 09:17:46 -03:00
Carlos Antonio da Silva
700284fc67 Merge pull request #5483 from yysaki/feature/main_branch_url
Update the urls which refer nonexistent master branch name in documentations
2022-04-21 15:22:11 -03:00
yysaki
1542b7da29 Update the urls which refer nonexistent master branch name in documentations 2022-04-21 23:29:30 +09:00
Glauco Custódio
a78948f53c Use bundle add instead
As per https://github.com/rubygems/rubygems/pull/5337, we can simplify the steps of adding a gem.
2022-03-21 12:10:43 +00:00
Carlos Antonio da Silva
451ff6d49c Reorganize test matrix & use latest bundler
* Rails and Ruby versions follow the most recent to oldest, except for
  Rails main, so we can keep the Gemfile the first one.
* Excluding specific matrix combinations based on the Gemfile first,
  Ruby version next, and keep the same order (most recent -> oldest)
* Quote all Ruby versions to keep things consistent. It's required for
  the '3.0' version to avoid the float issue where it'd use the latest
  3.x instead.
2022-02-25 14:50:01 -03:00
Carlos Antonio da Silva
542df3634b Merge pull request #5450 from petergoldstein/feature/add_ruby_3_1
Add Ruby 3.1 to CI matrix
2022-02-25 14:39:14 -03:00
Peter Goldstein
3c5acaf531 Add Ruby 3.1 to CI matrix. Lock to Nokogiri < 1.13 for webrat compatibility 2022-02-23 08:37:31 -08:00
Carlos Antonio da Silva
025b1c8734 Add date to v4.8.1 changelog [ci skip] 2021-12-16 08:08:57 -03:00
Carlos Antonio da Silva
43800b4b85 Bump to 4.8.1 with Rails 7 support
Also note in the Changelog that Turbo is not fully supported yet.
2021-12-16 08:04:21 -03:00
Carlos Antonio da Silva
baf5e00544 Merge pull request #5435 from dixpac/dix/rails_7
Add support for Rails 7
2021-12-16 08:02:18 -03:00
Dino Maric
289dd5f221 Add support for Rails 7
This commit adds support for latest Rails release.
2021-12-16 10:12:05 +01:00
Carlos Antonio da Silva
9f5b83750e Bundle update to Rails 7.0 rc1 2021-12-08 08:26:05 -03:00
Derek Crosson
1ac16b15e3 Merge pull request #1 from DerekCrosson/DerekCrosson-fix-change-commands-copied-to-clipboard
chore: remove dollar symbol from some commands
2021-11-01 02:48:16 +02:00
Derek Crosson
353d86e01c chore: remove dollar symbol from some commands
When you copy the commands that have the terminal beginning of line symbol in front of them you now no longer need to first delete this before running the command
2021-11-01 02:44:35 +02:00
Carlos Antonio da Silva
8593801130 Keep the constantize behavior consistent for versions prior to Rails 7
Use `AS::Dependencies` as before if we still can, otherwise use the new
direct `constantize` call for Rails 7+.

Leave a TODO to help remind us this can be removed once we drop support
to Rails versions prior to 7 in the future.
2021-10-08 08:33:47 -03:00
Carlos Antonio da Silva
bb879f7154 Merge branch 'ca-rails-main'
Add Rails 7 / main support
2021-10-07 20:23:21 -03:00
Carlos Antonio da Silva
772b74a657 Update Changelog adding Rails 7 support 2021-10-07 20:15:44 -03:00
Carlos Antonio da Silva
51bf327017 Refactor using helper to swap config 2021-10-07 19:06:33 -03:00
Carlos Antonio da Silva
14eb1362e3 Eliminate Rails 7 warning about Active Record legacy connection handling
DEPRECATION WARNING: Using legacy connection handling is deprecated.
    Please set `legacy_connection_handling` to `false` in your application.
2021-10-07 18:46:40 -03:00
Carlos Antonio da Silva
f3e8fd3baa Move the Gemfile to test with Rails 7.0 alpha2, fix session test issue
It appears setting the `rack.session` to a simple hash doesn't work
anymore as it now has a few additional methods Rails is relying on to
determine whether it's enabled or not:
https://github.com/rails/rails/pull/42231

Failure:
    NoMethodError: undefined method `enabled?' for {}:Hash
    rails (f55cdafe4b82) actionpack/lib/action_dispatch/middleware/flash.rb:62:in `commit_flash'

Turns we we don't seem to need to set `rack.session` for the tests here.
2021-10-07 18:08:16 -03:00
strobilomyces
a0ccc1cf96 Fix deprecated ActiveSupport::Dependencies.constantize (#5397)
Changes deprecated `ActiveSupport::Dependencies.constantize(model_name)` to `model_name.constantize`

Co-authored-by: Carlos Antonio da Silva <carlosantoniodasilva@gmail.com>
2021-10-07 17:27:37 -03:00
Alex Ghiculescu
b39faffde4 Test against Rails main and remove ActiveSupport::Dependencies.reference (#5357)
Remove `ActiveSupport::Dependencies.reference`

This was deleted from Rails: 14d4edd7c3

As far as I can tell, it was meant to add a performance boost at some point in the past but doesn't seem to do anything useful these days.
2021-10-07 17:18:37 -03:00
Carlos Antonio da Silva
366a428b2c Revise docs from #5405
Update a couple other modules that still referred to `devise_for` to
point to `devise`, and make all of them more consistent. We can only
mention `devise`, that should be clear enough about it being options
for the model method.
2021-10-06 19:20:07 -03:00
Carlos Antonio da Silva
7d103bc627 Merge pull request #5405 from chihaso/fix_comment_in_some_modules
Fix comment in some modules [ci skip]
2021-10-06 19:17:21 -03:00
chihaso
bdd2e7e24f Fix comment in some modules
- It says that the option is added to devise_for, but it is actually added to the devise method in the model.
2021-09-17 14:37:28 +09:00
Carlos Antonio da Silva
c82e4cf47b Merge pull request #5378 from nickhammond/patch-1
Add metadata for RubyGems
2021-05-08 10:19:35 -03:00
Nick Hammond
63ccdfb34a Add metadata for RubyGems 2021-05-06 16:33:39 -07:00
Carlos Antonio da Silva
2ee0068d77 Bundle update 2021-05-05 18:20:38 -03:00
Carlos Antonio da Silva
57d1a1d381 Release v4.8.0 2021-04-29 08:52:33 -03:00
Carlos Antonio da Silva
5d5636f03a Merge pull request #5369 from heartcombo/ca-lockable-reset-attempts
Create a model hook around the lockable warden hook to reset attempts
2021-04-02 15:52:43 -03:00
Carlos Antonio da Silva
a3ae35e9c9 Create a model hook around the lockable warden hook to reset attempts
Resetting failed attempts after sign in happened inside a warden hook
specific for the lockable module, but that was hidden inside the hook
implementation and didn't allow any user customization.

One such customization needed for example is to direct these updates to
a write DB when using a multi-DB setup. With the logic hidden in the
warden hook this wasn't possible, now that it's exposed in a model
method much like trackable, we can override the model method to wrap it
in a connection switch block for example, point to a write DB, and
simply call `super`.

Closes #5310
Related to #5264 and #5133
2021-04-02 15:45:25 -03:00
Carlos Antonio da Silva
e8e0c27599 Revert "Lock bundler to 2.2.9 instead of latest"
This reverts commit 1ba53dc369.

Let's give the latest bundler (2.2.15 as of today) a try again.
2021-03-30 21:53:57 -03:00
Carlos Antonio da Silva
429afcbe8a Bundle update 2021-03-30 21:53:56 -03:00
Carlos Antonio da Silva
ef9a2f4104 Use minitest helpers to check if objects respond to certain methods 2021-03-22 18:43:19 -03:00
Carlos Antonio da Silva
0cd72a56f9 Merge pull request #5347 from heartcombo/ca-build
Support Ruby 3+ officially, remove final Rails 6.1 deprecations, drop test dependency for XML serialization
2021-02-16 17:35:19 -03:00
Carlos Antonio da Silva
1ba53dc369 Lock bundler to 2.2.9 instead of latest
2.2.10 is causing the dependency resolution on Rails 6-0-stable to fail:

```
  Bundler could not find compatible versions for gem "railties":
    In Gemfile-rails-6-0:
      devise was resolved to 4.7.3, which depends on
        railties (>= 4.1.0)

      rails was resolved to 6.0.3.5, which depends on
        railties (= 6.0.3.5)

      responders (~> 3.0) was resolved to 3.0.1, which depends on
        railties (>= 5.0)
  Took  27.49 seconds
```

https://github.com/heartcombo/devise/runs/1905780158?check_suite_focus=true#step:5:23

The `railties` version 6.0.3.5 should work, given the other two are
using >= declarations, but it fails in 2.2.10.

Downgrading to 2.2.9 works.
2021-02-15 16:33:14 -03:00
Carlos Antonio da Silva
faef12cf2b Use the 6-0-stable version of Rails to fix issue with JSON responses
The test suite was failing on Rails 6.0 + Ruby 3 with errors like:

    Expected "{\"errors\":\"#<ActiveModel::Errors:0x000055f2e6cb8188>\"}"
    to include "{\"errors\":{".

The ActiveModel::Errors object wasn't being serialized to JSON as
expected, and this only happened with that combination of Ruby/Rails.

Upon further investigation, this was caused by a change in Ruby and
fixed in Rails in this PR: https://github.com/rails/rails/pull/39697
(which describes in more details the exact same problem and links to the
Ruby bug tracker with more information).

That fix was backported to 6-0-stable in June 2020, but hasn't been
officially released in a stable version yet: (there have been only
security fixes since then for 6.0)
75f6539d0e

Since the branch contains the fix, I'm pointing directly to it to get
the tests passing. We can't tell if there'll be a new stable 6.0 release
at this point, but hopefully yes, in which case we can go back at
pointing to it.
2021-02-15 16:33:03 -03:00
Carlos Antonio da Silva
c82a381f29 Bundle update 2021-02-15 14:45:04 -03:00
Carlos Antonio da Silva
a793472a3e Replace XML with JSON serialization across the test suite
This allows us to remove the dependency on the XML serializer provided
by the external `activemodel-serializers-xml` gem, and eliminates the
following deprecation warning:

    DEPRECATION WARNING: ActiveModel::Errors#to_xml is deprecated and
    will be removed in Rails 6.2.

Please note: this does not mean Devise doesn't support XML, it simply
means our test suite will use JSON to test non-navigatable formats
instead of XML, for simplicity. Devise's job is not to test object
serialization, so as long as your objects properly serialize to
XML/JSON/any other format, it should work out of the box.
2021-02-15 14:40:05 -03:00
Carlos Antonio da Silva
ad91686b62 Test on Ruby 3+ with Rails 6+
And remove dupe entry in the exclude matrix.

In order to get Ruby 3 working we needed to install `rexml` as part of
the test dependencies, only done on the main Gemfile (Rails 6.1) and the
6.0 versions. (which are the only ones supported by Ruby 3.)

Devise itself doesn't require `rexml` as it does nothing with it, but a
dependency we use during tests seem to require it. I was able to track
it down to omniauth-openid -> rack-openid -> ruby-openid requiring it:

    13a88ad644/lib/openid/yadis/xrds.rb (L1)

So while we have tests using omniauth-openid, we'll need this require in
place as well. Ideally that upstream version of ruby-openid should have
it, but it seems that one isn't updated in a while.
2021-02-15 14:34:36 -03:00
Carlos Antonio da Silva
1bb5fcbbec Merge pull request #5339 from ghiculescu/rails-deprecation
Fix deprecation warning on Rails 6.1

Related changes in Rails:
https://github.com/rails/rails/pull/38256
https://github.com/rails/rails/pull/38536
2021-02-02 21:27:31 -03:00
Alex Ghiculescu
80423c8f01 Fix deprecation warning on Rails 6.1 2021-02-02 15:37:45 -07:00
Carlos Antonio da Silva
743b6937e2 Merge pull request #5327 from heartcombo/ca-omniauth-2
Improve OmniAuth version check to allow anything from 1.0 forward
2021-02-01 17:30:37 -03:00
Carlos Antonio da Silva
e16d60d0fe Expand the release notes with more info about the OmniAuth v2 upgrade
I'm sure more people will hit issues so I'm trying to add more guidance
here about how to upgrade... maybe that should be in its own wiki but
I'll keep it all in the changelog for now.
2021-02-01 12:01:24 -03:00
Carlos Antonio da Silva
9d16f33c7b Revert "Explicitly set OmniAuth to 1.x in the Gemfiles for now"
This reverts commit 628f2fb2be.

We should be run green on OmniAuth 2.x now.
2021-02-01 11:51:23 -03:00
Carlos Antonio da Silva
c9a0f896cc Merge branch 'master' into ca-omniauth-2 2021-02-01 11:50:38 -03:00
Carlos Antonio da Silva
aa8d89579a Merge pull request #5338 from heartcombo/ca-build
Move build to GitHub Actions
2021-02-01 11:49:36 -03:00
Carlos Antonio da Silva
210c62af38 Add changelog about moving to GitHub Actions 2021-02-01 11:44:42 -03:00
Carlos Antonio da Silva
3048fe0960 Prevent Bundler 2.x. with Rails 4.x versions 2021-02-01 10:10:26 -03:00
Carlos Antonio da Silva
628f2fb2be Explicitly set OmniAuth to 1.x in the Gemfiles for now
The build is breaking with 2.x (which is expected), so this is a step to
get it to green on GA.
2021-01-31 10:19:06 -03:00
Carlos Antonio da Silva
13ba27497b Use the latest 2.x patch version for each Ruby, remove ruby-head
ruby-head was always in allowed failures with travis anyway, and we
never really paid much attention to it, so let's just remove it entirely
for now.
2021-01-31 10:08:57 -03:00
Carlos Antonio da Silva
7386f419e3 Use latest bundler on Gemfile.lock
Bundler 1.x uses git instead of https by default and we don't have that
github source setting in the Gemfile, but this should work.
2021-01-31 10:05:03 -03:00
Carlos Antonio da Silva
e07932c181 Rename gemfiles to keep consistency 2021-01-31 09:54:47 -03:00
Carlos Antonio da Silva
d0eafe70dc Remove the lock gemfiles from the previous versions
Keep only the lock for the main Gemfile to keep Devise consistent with
the other heartcombo libs.
2021-01-31 09:51:20 -03:00
Carlos Antonio da Silva
7e6da424e2 Move from Travis to GitHub Actions 2021-01-29 16:59:14 -03:00
AsbahIshaq
81bf3ad8c1 changed support to supports (#5334)
Co-authored-by: Asbah Ishaq <asbahishaq>
2021-01-24 08:51:09 -03:00
Carlos Antonio da Silva
51c05a5b21 Add changelog entry for OmniAuth 2 support
And a note/warning about how it might break apps that don't update their
integration accordingly as OmniAuth now expects.
2021-01-22 09:28:05 -03:00
Carlos Antonio da Silva
1d138dd40c Simplify OmniAuth version check by trying to load the gem with the necessary version 2021-01-22 09:16:58 -03:00
Carlos Antonio da Silva
c43ae8cb47 Merge branch 'master' into ca-omniauth-2 2021-01-19 15:22:57 -03:00
Carlos Antonio da Silva
cd60c747cc Update to latest released omniauth* gems
omniauth-openid v2.0.1 was just released opening support for omniauth
v2, so we can bundle update everything from the released gems now.
2021-01-19 15:21:26 -03:00
Jordan Owens
837baaf2e1 Update omniauthable tests for OmniAuth 2.0 (#5331) 2021-01-19 15:19:55 -03:00
Carlos Antonio da Silva
e0395367e4 Merge pull request #5333 from ghiculescu/patch-1
Fix Rails default log level in Readme
2021-01-18 21:53:46 -03:00
Carlos Antonio da Silva
fb17e2755f Move Rails 6.1 to the main Gemfile instead of an extra one
We have the gemfiles/* to test other versions of Rails, but keep the
most recent one in the main Gemfile.
2021-01-18 21:52:07 -03:00
Alex Ghiculescu
f4462cd85e Fix Rails default log level
This changed in 229fd2a02f - the advice about changing your log level still stands though.
2021-01-18 16:51:23 -06:00
Carlos Antonio da Silva
8bb358cf80 Improve OmniAuth version check to allow anything from 1.0 forward
This should enable people to try OmniAuth 2 currently in pre-release.
2021-01-07 09:21:15 -03:00
Ryunosuke Sato
98fc5e8e39 Test on rails 6.1 (#5323)
* Make test for validation to be Rails 6.1 compatible

The `ActiveModel::Errors` has been changed in Rails 6.1.
https://github.com/rails/rails/pull/32313

* Add gemfile for Rails 6.1

* Add CI matrix for Rails 6.1
2021-01-04 20:17:58 -03:00
Carlos Antonio da Silva
dfbed22cee Merge pull request #5315 from bipashant/master
Add missing period to devise.registrations.updated_but_not_signed_in
2020-11-23 08:10:22 -03:00
Bibek Sharma Chapagain
fd03f9e353 Added missing full stop "." on registrations.updated_but_not_signed_in. 2020-11-23 12:21:22 +11:00
Carlos Antonio da Silva
a19e78cdb4 Merge pull request #5306 from janz93/cleanup
Add to-do to cleanup rack/rails session bug fix when supporting Rails 5.2+ only
2020-11-22 21:42:48 -03:00
Jan Zaydowicz
b88af5d65e chore: add expiry note for old rack/rails session bug fix
Seven year ago rails `session.keys` could be empty if the session was
not loaded yet.

To prevent an error the removed code was introduced
https://github.com/heartcombo/devise/issues/2660

Since then rails changed the behaviour and makes sure that the session
is loaded before someone wants to access any session keys
3498aacbbe

Which means the `session.empty?` is not needed anymore once Rails 5.2+
and upwards only supported.
2020-11-22 12:33:30 +01:00
Carlos Antonio da Silva
45b831c4ea Release 4.7.3 2020-09-20 21:24:01 -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
164 changed files with 2135 additions and 3071 deletions

View File

@@ -0,0 +1,25 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/ruby
{
"name": "Ruby",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/ruby:0-3-bullseye",
"features": {
"ghcr.io/devcontainers/features/github-cli:1": {}
},
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "bundle install",
// Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}

6
.github/dependabot.yml vendored Normal file
View File

@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"

63
.github/workflows/test.yml vendored Normal file
View File

@@ -0,0 +1,63 @@
name: Test
on: [push, pull_request]
jobs:
test:
strategy:
fail-fast: false
matrix:
gemfile:
- Gemfile
- gemfiles/Gemfile-rails-main
- gemfiles/Gemfile-rails-7-0
- gemfiles/Gemfile-rails-7-1
- gemfiles/Gemfile-rails-7-2
- gemfiles/Gemfile-rails-8-0
ruby:
- '4.0'
- '3.4'
- '3.3'
- '3.2'
- '3.1'
- '3.0'
- '2.7'
orm:
- active_record
- mongoid
exclude:
- gemfile: Gemfile
ruby: '3.1'
- gemfile: Gemfile
ruby: '3.0'
- gemfile: Gemfile
ruby: '2.7'
- gemfile: gemfiles/Gemfile-rails-main
ruby: '3.2'
- gemfile: gemfiles/Gemfile-rails-main
ruby: '3.1'
- gemfile: gemfiles/Gemfile-rails-main
ruby: '3.0'
- gemfile: gemfiles/Gemfile-rails-main
ruby: '2.7'
- gemfile: gemfiles/Gemfile-rails-8-0
ruby: '3.1'
- gemfile: gemfiles/Gemfile-rails-8-0
ruby: '3.0'
- gemfile: gemfiles/Gemfile-rails-8-0
ruby: '2.7'
- gemfile: gemfiles/Gemfile-rails-7-2
ruby: '3.0'
- gemfile: gemfiles/Gemfile-rails-7-2
ruby: '2.7'
runs-on: ubuntu-latest
env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
DEVISE_ORM: ${{ matrix.orm }}
steps:
- uses: actions/checkout@v6
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true # runs bundle install and caches installed gems automatically
- uses: supercharge/mongodb-github-action@1.12.1
if: ${{ matrix.orm == 'mongoid' }}
- run: bundle exec rake

1
.gitignore vendored
View File

@@ -8,3 +8,4 @@ rdoc/*
pkg
log
test/tmp/*
gemfiles/*.lock

View File

@@ -1,91 +0,0 @@
language: ruby
rvm:
- 2.1.10
- 2.2.10
- 2.3.8
- 2.4.5
- 2.5.3
- 2.6.0
- ruby-head
gemfile:
- Gemfile
- gemfiles/Gemfile.rails-6.0-beta
- gemfiles/Gemfile.rails-5.2-stable
- gemfiles/Gemfile.rails-5.0-stable
- gemfiles/Gemfile.rails-4.2-stable
- gemfiles/Gemfile.rails-4.1-stable
matrix:
exclude:
- rvm: 2.1.10
gemfile: Gemfile
- rvm: 2.1.10
gemfile: gemfiles/Gemfile.rails-6.0-beta
- rvm: 2.1.10
gemfile: gemfiles/Gemfile.rails-5.2-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-beta
- rvm: 2.2.10
gemfile: gemfiles/Gemfile.rails-5.2-stable
- rvm: 2.3.8
gemfile: gemfiles/Gemfile.rails-6.0-beta
- rvm: 2.4.5
gemfile: gemfiles/Gemfile.rails-4.1-stable
- rvm: 2.4.5
gemfile: gemfiles/Gemfile.rails-6.0-beta
- rvm: 2.5.3
gemfile: gemfiles/Gemfile.rails-4.1-stable
- rvm: 2.6.0
gemfile: gemfiles/Gemfile.rails-4.1-stable
- rvm: 2.6.0
gemfile: gemfiles/Gemfile.rails-4.2-stable
- rvm: ruby-head
gemfile: gemfiles/Gemfile.rails-4.1-stable
- rvm: ruby-head
gemfile: gemfiles/Gemfile.rails-4.2-stable
- env: DEVISE_ORM=mongoid
gemfile: Gemfile
- env: DEVISE_ORM=mongoid
gemfile: gemfiles/Gemfile.rails-5.0-stable
- env: DEVISE_ORM=mongoid
gemfile: gemfiles/Gemfile.rails-5.2-stable
- env: DEVISE_ORM=mongoid
gemfile: gemfiles/Gemfile.rails-6.0-beta
allow_failures:
- rvm: ruby-head
- gemfile: gemfiles/Gemfile.rails-6.0-beta
services:
- mongodb
sudo: false
cache: bundler
env:
matrix:
- DEVISE_ORM=active_record
- DEVISE_ORM=mongoid
before_install:
- gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
- gem install bundler -v '< 2'
- "rm ${BUNDLE_GEMFILE}.lock"
before_script: "bundle update"
script: "bin/test"
notifications:
email: false
slack:
on_pull_requests: false
on_success: change
on_failure: always
secure: Q3M+kmude3FjisibEeeGe0wSMXgvwLH+vL7Zrx9//q4QtkfnrQ/BBMvY9KXxPEsNF+eys4YopYjTkJ8uRmeboUATW/oQ4Jrv3+u3zkIHK2sFn/Q2cQWpK5w+CbgEnHPjKYnUu34b09njXTgDlr/mqtbPqrKeZ1dLlpKXCB/q4GY=

View File

@@ -1,301 +1,62 @@
### Unreleased
### 5.0.0.rc - 2025-12-31
### 4.6.2 - 2019-03-26
* breaking changes
* Drop support to Ruby < 2.7
* Drop support to Rails < 7.0
* Remove deprecated `:bypass` option from `sign_in` helper, use `bypass_sign_in` instead. [#5803](https://github.com/heartcombo/devise/pull/5803)
* Remove deprecated `devise_error_messages!` helper, use `render "devise/shared/error_messages", resource: resource` instead. [#5803](https://github.com/heartcombo/devise/pull/5803)
* Remove deprecated `scope` second argument from `sign_in(resource, :admin)` controller test helper, use `sign_in(resource, scope: :admin)` instead. [#5803](https://github.com/heartcombo/devise/pull/5803)
* Remove deprecated `Devise::TestHelpers`, use `Devise::Test::ControllerHelpers` instead. [#5803](https://github.com/heartcombo/devise/pull/5803)
* Remove deprecated `Devise::Models::Authenticatable::BLACKLIST_FOR_SERIALIZATION` [#5598](https://github.com/heartcombo/devise/pull/5598)
* Remove deprecated `Devise.activerecord51?` method.
* Remove `SecretKeyFinder` and use `app.secret_key_base` as the default secret key for `Devise.secret_key` if a custom `Devise.secret_key` is not provided.
* bug fixes
* Revert "Set `encrypted_password` to `nil` when `password` is set to `nil`" since it broke backward compatibility with existing applications. See more on https://github.com/plataformatec/devise/issues/5033#issuecomment-476386275 (by @mracos)
This is potentially a breaking change because Devise previously used the following order to find a secret key:
### 4.6.1 - 2019-02-11
* bug fixes
* Check if `root_path` is defined with `#respond_to?` instead of `#present` (by @tegon)
### 4.6.0 - 2019-02-07
* enhancements
* Allow to skip email and password change notifications (by @iorme1)
* Include the use of `nil` for `allow_unconfirmed_access_for` in the docs (by @joaumg)
* Ignore useless files into the `.gem` file (by @huacnlee)
* Explain the code that prevents enumeration attacks inside `Devise::Strategies::DatabaseAuthenticatable` (by @tegon)
* Refactor the `devise_error_messages!` helper to render a partial (by @prograhamer)
* Add an option (`Devise.sign_in_after_change_password`) to not automatically sign in a user after changing a password (by @knjko)
* bug fixes
* Fix missing comma in Simple Form generator (by @colinross)
* Fix error with migration generator in Rails 6 (by @oystersauce8)
* Set `encrypted_password` to `nil` when `password` is set to `nil` (by @sivagollapalli)
* Consider whether the request supports flash messages inside `Devise::Controllers::Helpers#is_flashing_format?` (by @colinross)
* Fix typo inside `Devise::Generators::ControllersGenerator` (by @kopylovvlad)
* Sanitize parameters inside `Devise::Models::Authenticatable#find_or_initialize_with_errors` (by @rlue)
* `#after_database_authentication` callback was not called after authentication on password reset (by @kanmaniselvan)
* Fix corner case when `#confirmation_period_valid?` was called at the same second as `confirmation_sent_at` was set. Mostly true for date types that only have second precisions. (by @stanhu)
* Fix unclosed `li` tag in `error_messages` partial (by @mracos)
* Fix Routes issue when devise engine is mounted in another engine on Rails versions lower than 5.1 (by @a-barbieri)
* Make `#increment_failed_attempts` concurrency safe (by @tegon)
* Apply Test Helper fix to Rails 6.0 as well as 5.x (by @matthewrudy)
* deprecations
* The second argument of `DatabaseAuthenticatable`'s `#update_with_password` and `#update_without_password` is deprecated and will be removed in the next major version. It was added to support a feature deprecated in Rails 4, so you can safely remove it from your code. (by @ihatov08)
* The `DeviseHelper.devise_error_messages!` is deprecated and will be removed in the next major version. Use the `devise/shared/error_messages` partial instead. (by @mracos)
### 4.5.0 - 2018-08-15
* enhancements
* Use `before_action` instead of `before_filter` (by @edenthecat)
* Allow people to extend devise failure app, through invoking `ActiveSupport.run_load_hooks` once `Devise::FailureApp` is loaded (by @wnm)
* Use `update` instead of `update_attributes` (by @koic)
* Split IP resolution from `update_tracked_fields` (by @mckramer)
* upgrade dependencies for rails and responders (by @lancecarlson)
* Add `autocomplete="new-password"` to new password fields (by @gssbzn)
* Add `autocomplete="current-password"` to current password fields (by @gssbzn)
* Remove redundant `self` from `database_authenticatable` module (by @abhishekkanojia)
* Update `simple_form` templates with changes from https://github.com/plataformatec/devise/commit/16b3d6d67c7e017d461ea17ed29ea9738dc77e83 and https://github.com/plataformatec/devise/commit/6260c29a867b9a656f1e1557abe347a523178fab (by @gssbzn)
* Remove `:trackable` from the default modules in the generators, to be more GDPR-friendly (by @fakenine)
* bug fixes
* Use same string on failed login regardless of whether account exists when in paranoid mode (by @TonyMK9068)
* Fix error when params is not a hash inside `Devise::ParameterSanitizer` (by @b0nn1e)
* Look for `secret_key_base` inside `Rails.application` (by @gencer)
* Ensure `Devise::ParameterFilter` does not add missing keys when called with a hash that has a `default` / `default_proc`
configured (by @joshpencheon)
* Adds `is_navigational_format?` check to `after_sign_up_path_for` to keep consistency (by @iorme1)
### 4.4.3 - 2018-03-17
* 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
* enhancements
* Add `frozen_string_literal` pragma comment to all Ruby files. (by @pat)
* Use `set_flash_method!` instead of `set_flash_method` in `Devise::OmniauthCallbacksController#failure`. (by @saichander17)
* Clarify how `store_location_for` modifies URIs. (by @olivierlacan)
* Move `failed_attempts` increment into its own function. by (@mobilutz)
* Add `autocomplete="email"` to email fields. by (@MikeRogers0)
* Add the ability to change the default migrations path introduced in Rails 5.0.3. (by @alexhifer)
* Delete unnecessary condition for helper method. (by @davydovanton)
* Support `id: :uuid` option for migrations. (by @filip373)
* bug fixes
* Fix syntax for MRI 2.5.0. (by @pat)
* 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
* Dependency support added for Rails 5.1.x.
### 4.2.1 - 2017-03-15
* removals
* `Devise::Mailer#scope_name` and `Devise::Mailer#resource` are now protected
methods instead of public.
* bug fixes
* Attempt to reset password without the password field in the request now results in a `:blank` validation error.
Before this change, Devise would accept the reset password request and log the user in, without validating/changing
the password. (by @victor-am)
* Confirmation links now expire based on UTC time, working properly when using different timezones. (by @jjuliano)
* enhancements
* Notify the original email when it is changed with a new `Devise.send_email_changed_notification` setting.
When using `reconfirmable`, the notification will be sent right away instead of when the unconfirmed email is confirmed.
(original change by @ethirajsrinivasan)
### 4.2.0 - 2016-07-01
* removals
* Remove the deprecated `Devise::ParameterSanitizer` API from Devise 3.
Please use the `#permit` and `#sanitize` methods over `#for`.
* Remove the deprecated OmniAuth URL helpers. Use the fully qualified helpers
(`user_facebook_omniauth_authorize_path`) over the scope based helpers
( `user_omniauth_authorize_path(:facebook)`).
* Remove the `Devise.bcrypt` method, use `Devise::Encryptor.digest` instead.
* Remove the `Devise::Models::Confirmable#confirm!` method, use `confirm` instead.
* Remove the `Devise::Models::Recoverable#reset_password!` method, use `reset_password` instead.
* Remove the `Devise::Models::Recoverable#after_password_reset` method.
* bug fixes
* Fix an `ActionDispatch::IllegalStateError` when testing controllers with Rails 5 rc 2(by @hamadata).
* Use `ActiveSupport.on_load` hooks to include Devise on `ActiveRecord` and `Mongoid`,
avoiding autoloading these constants too soon (by @lucasmazza, @rafaelfranca).
* enhancements
* Display the minimum password length on `registrations/edit` view (by @Yanchek99).
* You can disable Devise's routes reloading on boot by through the `reload_routes = false` config.
This can reduce the time taken to boot the application but it might trigger
some errors if you application (mostly your controllers) requires that
Devise mappings be loaded during boot time (by @sidonath).
* Added `Devise::Test::IntegrationHelpers` to bypass the sign in process using
Warden test API (by @lucasmazza).
* Define `inspect` in `Devise::Models::Authenticatable` to help ensure password hashes
aren't included in exceptions or otherwise accidentally serialized (by @tkrajcar).
* Add missing support of `Rails.application.config.action_controller.relative_url_root` (by @kosdiamantis).
* deprecations
* `Devise::TestHelpers` is deprecated in favor of `Devise::Test::ControllerHelpers`
(by @lucasmazza).
* The `sign_in` test helper has changed to use keyword arguments when passing
a scope. `sign_in :admin, users(:alice)` should be rewritten as
`sign_in users(:alice), scope: :admin` (by @lucasmazza).
* The option `bypass` of `Devise::Controllers::SignInOut#sign_in` method is
deprecated in favor of `Devise::Controllers::SignInOut#bypass_sign_in`
method (by @ulissesalmeida).
### 4.1.1 - 2016-05-15
* bug fixes
* Fix overwriting the remember_token when a valid one already exists (by @ralinchimev).
### 4.1.0
* bug fixes
* Fix race condition of sending the confirmation instructions e-mail using background jobs.
Using the previous `after_create` callback, the e-mail can be sent before
the record be committed on database, generating a `ActiveRecord::NotFound` error.
Now the confirmation e-mail will be only sent after the database commit,
using the `after_commit` callback.
It may break your test suite on Rails 4 if you are testing the sent e-mails
or enqueued jobs using transactional fixtures enabled or `DatabaseCleaner` with `transaction` strategy.
You can easily fix your test suite using the gem
[test_after_commit](https://github.com/grosser/test_after_commit). For example, put in your Gemfile:
```ruby
gem 'test_after_commit', :group => :test
```
app.credentials.secret_key_base > app.secrets.secret_key_base > application.config.secret_key_base > application.secret_key_base
```
On Rails 5 `after_commit` callbacks are triggered even using transactional
fixtures, then this fix will not break your test suite. If you are using `DatabaseCleaner` with the `deletion` or `truncation` strategies it may not break your tests. (by @allenwq)
* Fix strategy checking in `Lockable#unlock_strategy_enabled?` for `:none` and
`:undefined` strategies. (by @f3ndot)
* features
* Humanize authentication keys in failure flash message (by @byzg)
When you are configuring the translations of `devise.failure.invalid`, the
`authentication_keys` is translated now.
* deprecations
* Remove code supporting old session serialization format (by @fphilipe).
* Now the `email_regexp` default uses a more permissive regex:
`/\A[^@\s]+@[^@\s]+\z/` (by @kimgb)
* Now the `strip_whitespace_keys` default is `[:email]` (by @ulissesalmeida)
* Now the `reconfirmable` default is `true` (by @ulissesalmeida)
* Now the `skip_session_storage` default is `[:http_auth]` (by @ulissesalmeida)
* Now the `sign_out_via` default is `:delete` (by @ulissesalmeida)
* improvements
* Avoids extra computation of friendly token for confirmation token (by @sbc100)
Now, it always uses `application.secret_key_base`. Make sure you're using the same secret key after the upgrade; otherwise, previously generated tokens for `recoverable`, `lockable`, and `confirmable` will be invalid.
[#5645](https://github.com/heartcombo/devise/pull/5645)
* Change password instructions button label on devise view from `Send me reset password instructions` to `Send me password reset instructions` [#5515](https://github.com/heartcombo/devise/pull/5515)
* Change `<br>` tags separating form elements to wrapping them in `<p>` tags [#5494](https://github.com/heartcombo/devise/pull/5494)
* Replace `[data-turbo-cache=false]` with `[data-turbo-temporary]` on `devise/shared/error_messages` partial. This has been [deprecated by Turbo since v7.3.0 (released on Mar 1, 2023)](https://github.com/hotwired/turbo/releases/tag/v7.3.0).
### 4.0.3 - 2016-05-15
* bug fixes
* Fix overwriting the remember_token when a valid one already exists (by @ralinchimev).
### 4.0.2 - 2016-05-02
* bug fixes
* Fix strategy checking in `Lockable#unlock_strategy_enabled?` for `:none`
and `:undefined` strategies. (by @f3ndot)
### 4.0.1 - 2016-04-25
* bug fixes
* Fix the e-mail confirmation instructions send when a user updates the email
address from nil. (by @lmduc)
* Remove unnecessary `attribute_will_change!` call. (by @cadejscroggins)
* Consistent `permit!` check. (by @ulissesalmeida)
### 4.0.0 - 2016-04-18
* bug fixes
* Fix the `extend_remember_period` configuration. When set to `false` it does
not update the cookie expiration anymore.(by @ulissesalmeida)
* deprecations
* Added a warning of default value change in Devise 4.1 for users that uses
the the default configuration of the following configurations: (by @ulissesalmeida)
* `strip_whitespace_keys` - The default will be `[:email]`.
* `skip_session_storage` - The default will be `[:http_auth]`.
* `sign_out_via` - The default will be `:delete`.
* `reconfirmable` - The default will be `true`.
* `email_regexp` - The default will be `/\A[^@\s]+@[^@\s]+\z/`.
* Removed deprecated argument of `Devise::Models::Rememberable#remember_me!` (by @ulissesalmeida)
* Removed deprecated private method Devise::Controllers::Helpers#expire_session_data_after_sign_in!
(by @bogdanvlviv)
### 4.0.0.rc2 - 2016-03-09
If you are using an older version of Turbo and the default devise template, you'll need to copy it over to your app and change that back to `[data-turbo-cache=false]`.
* enhancements
* Introduced `DeviseController#set_flash_message!` for conditional flash
messages setting to reduce complexity.
* `rails g devise:install` will fail if the app does not have a ORM configured
(by @arjunsharma)
* Support to Rails 5 versioned migrations added.
* Add Rails 8 support.
- Routes are lazy-loaded by default in test and development environments now so Devise loads them before `Devise.mappings` call. [#5728](https://github.com/heartcombo/devise/pull/5728)
* New apps using Rack 3.1+ will be generated using `config.responder.error_status = :unprocessable_content`, since [`:unprocessable_entity` has been deprecated by Rack](https://github.com/rack/rack/pull/2137).
* deprecations
* omniauth routes are no longer defined with a wildcard `:provider` parameter,
and provider specific routes are defined instead, so route helpers like `user_omniauth_authorize_path(:github)` are deprecated in favor of `user_github_omniauth_authorize_path`.
You can still use `omniauth_authorize_path(:user, :github)` if you need to
call the helpers dynamically.
Latest versions of [Rails transparently convert `:unprocessable_entity` -> `:unprocessable_content`](https://github.com/rails/rails/pull/53383), and Devise will use that in the failure app to avoid Rack deprecation warnings for apps that are configured with `:unprocessable_entity`. They can also simply change their `error_status` to `:unprocessable_content` in latest Rack versions to avoid the warning.
* Add Ruby 3.4 and 4.0 support.
* Reenable Mongoid test suite across all Rails 7+ versions, to ensure we continue supporting it. Changes to dirty tracking to support Mongoid 8.0+. [#5568](https://github.com/heartcombo/devise/pull/5568)
* Password length validator is changed from
### 4.0.0.rc1 - 2016-02-01
* Support added to Rails 5 (by @twalpole).
* Devise no longer supports Rails 3.2 and 4.0.
* Devise no longer supports Ruby 1.9 and 2.0.
* deprecations
* The `devise_parameter_sanitize` API has changed:
The `for` method was deprecated in favor of `permit`:
```ruby
def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_up) << :subscribe_newsletter
# Should become the following.
devise_parameter_sanitizer.permit(:sign_up, keys: [:subscribe_newsletter])
end
```
validates_length_of :password, within: password_length, allow_blank: true`
```
The customization through instance methods on the sanitizer implementation
should be done through it's `initialize` method:
to
```ruby
class User::ParameterSanitizer < Devise::ParameterSanitizer
def sign_up
default_params.permit(:username, :email)
end
end
# The `sign_up` method can be a `permit` call on the sanitizer `initialize`.
class User::ParameterSanitizer < Devise::ParameterSanitizer
def initialize(*)
super
permit(:sign_up, keys: [:username, :email])
end
end
```
validates_length_of :password, minimum: proc { password_length.min }, maximum: proc { password_length.max }, allow_blank: true
```
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).
so it's possible to override `password_length` at runtime. [#5734](https://github.com/heartcombo/devise/pull/5734)
Please check [3-stable](https://github.com/plataformatec/devise/blob/3-stable/CHANGELOG.md)
* bug fixes
* Make `Devise` work without `ActionMailer` when `Zeitwerk` autoloader is used. [#5731](https://github.com/heartcombo/devise/pull/5731)
* Handle defaults `:from` and `:reply_to` as procs correctly by delegating to Rails [#5595](https://github.com/heartcombo/devise/pull/5595)
* Use `OmniAuth.config.allowed_request_methods` as routing verbs for the auth path [#5508](https://github.com/heartcombo/devise/pull/5508)
* Handle `on` and `ON` as true values to check params [#5514](https://github.com/heartcombo/devise/pull/5514)
* Fix passing `format` option to `devise_for` [#5732](https://github.com/heartcombo/devise/pull/5732)
* Use `ActiveRecord::SecurityUtils.secure_compare` in `Devise.secure_compare` to match two empty strings correctly. [#4829](https://github.com/heartcombo/devise/pull/4829)
* Respond with `401 Unauthorized` for non-navigational requests to destroy the session when there is no authenticated resource. [#4878](https://github.com/heartcombo/devise/pull/4878)
* Fix incorrect grammar of invalid authentication message with capitalized attributes, e.g.: "Invalid Email or password" => "Invalid email or password". (originally introduced by [#4014](https://github.com/heartcombo/devise/pull/4014), released on v4.1.0) [#4834](https://github.com/heartcombo/devise/pull/4834)
Please check [4-stable](https://github.com/heartcombo/devise/blob/4-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.oss@gmail.com](heartcombo.oss@gmail.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.oss@gmail.com](mailto:heartcombo.oss@gmail.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
@@ -66,7 +66,7 @@ you can do:
* Help ensure that existing issues follows the recommendations from the
_[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

31
Gemfile
View File

@@ -4,37 +4,30 @@ source "https://rubygems.org"
gemspec
gem "rails", "~> 5.2"
gem "omniauth", "~> 1.3"
gem "oauth2"
gem "omniauth"
gem "omniauth-oauth2"
gem "rails", "~> 8.1.0"
gem "rdoc"
gem "activemodel-serializers-xml", github: "rails/activemodel-serializers-xml"
gem "rails-controller-testing"
gem "responders", "~> 2.4"
gem "responders", "~> 3.1"
group :test do
gem "minitest", "< 6"
gem "mocha", "~> 2.1", require: false
gem "omniauth-facebook"
gem "omniauth-openid"
gem "rexml"
gem "timecop"
gem "webrat", "0.7.3", require: false
gem "mocha", "~> 1.1", require: false
end
platforms :jruby do
gem "activerecord-jdbc-adapter"
gem "activerecord-jdbcsqlite3-adapter"
gem "jruby-openssl"
gem "webrat"
gem "ostruct"
end
platforms :ruby do
gem "sqlite3", "~> 1.3.6"
gem "sqlite3"
end
# TODO:
# group :mongoid do
# gem "mongoid", "~> 4.0.0"
# end
group :mongoid do
gem "mongoid", "~> 9.0", github: "mongodb/mongoid", branch: "9.0-stable"
end

View File

@@ -1,204 +1,312 @@
GIT
remote: git://github.com/rails/activemodel-serializers-xml.git
revision: dd9c0acf26aab111ebc647cd8deb99ebc6946531
remote: https://github.com/mongodb/mongoid.git
revision: 4dcdaddea5d88a819c7c0d98ea0e994e13f515fe
branch: 9.0-stable
specs:
activemodel-serializers-xml (1.0.1)
activemodel (> 5.x)
activesupport (> 5.x)
builder (~> 3.1)
mongoid (9.0.9)
activemodel (>= 5.1, < 8.2, != 7.0.0)
concurrent-ruby (>= 1.0.5, < 2.0)
mongo (>= 2.18.0, < 3.0.0)
PATH
remote: .
specs:
devise (4.6.2)
devise (5.0.0.rc)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0, < 6.0)
railties (>= 7.0)
responders
warden (~> 1.2.3)
GEM
remote: https://rubygems.org/
specs:
actioncable (5.2.0)
actionpack (= 5.2.0)
action_text-trix (2.1.15)
railties
actioncable (8.1.1)
actionpack (= 8.1.1)
activesupport (= 8.1.1)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailer (5.2.0)
actionpack (= 5.2.0)
actionview (= 5.2.0)
activejob (= 5.2.0)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.2.0)
actionview (= 5.2.0)
activesupport (= 5.2.0)
rack (~> 2.0)
zeitwerk (~> 2.6)
actionmailbox (8.1.1)
actionpack (= 8.1.1)
activejob (= 8.1.1)
activerecord (= 8.1.1)
activestorage (= 8.1.1)
activesupport (= 8.1.1)
mail (>= 2.8.0)
actionmailer (8.1.1)
actionpack (= 8.1.1)
actionview (= 8.1.1)
activejob (= 8.1.1)
activesupport (= 8.1.1)
mail (>= 2.8.0)
rails-dom-testing (~> 2.2)
actionpack (8.1.1)
actionview (= 8.1.1)
activesupport (= 8.1.1)
nokogiri (>= 1.8.5)
rack (>= 2.2.4)
rack-session (>= 1.0.1)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.2.0)
activesupport (= 5.2.0)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
useragent (~> 0.16)
actiontext (8.1.1)
action_text-trix (~> 2.1.15)
actionpack (= 8.1.1)
activerecord (= 8.1.1)
activestorage (= 8.1.1)
activesupport (= 8.1.1)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (8.1.1)
activesupport (= 8.1.1)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.2.0)
activesupport (= 5.2.0)
erubi (~> 1.11)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
activejob (8.1.1)
activesupport (= 8.1.1)
globalid (>= 0.3.6)
activemodel (5.2.0)
activesupport (= 5.2.0)
activerecord (5.2.0)
activemodel (= 5.2.0)
activesupport (= 5.2.0)
arel (>= 9.0)
activestorage (5.2.0)
actionpack (= 5.2.0)
activerecord (= 5.2.0)
marcel (~> 0.3.1)
activesupport (5.2.0)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
arel (9.0.0)
bcrypt (3.1.12)
builder (3.2.3)
concurrent-ruby (1.0.5)
crass (1.0.4)
erubi (1.7.1)
faraday (0.11.0)
multipart-post (>= 1.2, < 3)
globalid (0.4.1)
activesupport (>= 4.2.0)
hashie (3.5.7)
i18n (1.0.0)
activemodel (8.1.1)
activesupport (= 8.1.1)
activerecord (8.1.1)
activemodel (= 8.1.1)
activesupport (= 8.1.1)
timeout (>= 0.4.0)
activestorage (8.1.1)
actionpack (= 8.1.1)
activejob (= 8.1.1)
activerecord (= 8.1.1)
activesupport (= 8.1.1)
marcel (~> 1.0)
activesupport (8.1.1)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.3.1)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
json
logger (>= 1.4.2)
minitest (>= 5.1)
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
uri (>= 0.13.1)
base64 (0.3.0)
bcrypt (3.1.20)
bigdecimal (4.0.1)
bson (5.2.0)
builder (3.3.0)
concurrent-ruby (1.3.6)
connection_pool (3.0.2)
crass (1.0.6)
date (3.5.1)
drb (2.2.3)
erb (6.0.1)
erubi (1.13.1)
faraday (2.14.0)
faraday-net_http (>= 2.0, < 3.5)
json
logger
faraday-net_http (3.4.2)
net-http (~> 0.5)
globalid (1.3.0)
activesupport (>= 6.1)
hashie (5.1.0)
logger
i18n (1.14.8)
concurrent-ruby (~> 1.0)
jwt (1.5.6)
loofah (2.2.2)
io-console (0.8.2)
irb (1.16.0)
pp (>= 0.6.0)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
json (2.18.0)
jwt (3.1.2)
base64
logger (1.7.0)
loofah (2.25.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.0)
nokogiri (>= 1.12.0)
mail (2.9.0)
logger
mini_mime (>= 0.1.1)
marcel (0.3.2)
mimemagic (~> 0.3.2)
metaclass (0.0.4)
method_source (0.9.0)
mimemagic (0.3.2)
mini_mime (1.0.0)
mini_portile2 (2.3.0)
minitest (5.11.3)
mocha (1.2.1)
metaclass (~> 0.0.1)
multi_json (1.12.1)
multi_xml (0.6.0)
multipart-post (2.0.0)
nio4r (2.3.0)
nokogiri (1.8.2)
mini_portile2 (~> 2.3.0)
oauth2 (1.3.1)
faraday (>= 0.8, < 0.12)
jwt (~> 1.0)
multi_json (~> 1.3)
net-imap
net-pop
net-smtp
marcel (1.1.0)
mini_mime (1.1.5)
mini_portile2 (2.8.9)
minitest (5.27.0)
mocha (2.8.2)
ruby2_keywords (>= 0.0.5)
mongo (2.22.0)
base64
bson (>= 4.14.1, < 6.0.0)
multi_xml (0.8.0)
bigdecimal (>= 3.1, < 5)
net-http (0.9.1)
uri (>= 0.11.1)
net-imap (0.6.2)
date
net-protocol
net-pop (0.1.2)
net-protocol
net-protocol (0.2.2)
timeout
net-smtp (0.5.1)
net-protocol
nio4r (2.7.5)
nokogiri (1.19.0)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
oauth2 (2.0.18)
faraday (>= 0.17.3, < 4.0)
jwt (>= 1.0, < 4.0)
logger (~> 1.2)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
omniauth (1.8.1)
hashie (>= 3.4.6, < 3.6.0)
rack (>= 1.6.2, < 3)
omniauth-facebook (4.0.0)
omniauth-oauth2 (~> 1.2)
omniauth-oauth2 (1.4.0)
oauth2 (~> 1.0)
omniauth (~> 1.2)
omniauth-openid (1.0.1)
omniauth (~> 1.0)
rack-openid (~> 1.3.1)
rack (>= 1.2, < 4)
snaky_hash (~> 2.0, >= 2.0.3)
version_gem (~> 1.1, >= 1.1.9)
omniauth (2.1.4)
hashie (>= 3.4.6)
logger
rack (>= 2.2.3)
rack-protection
omniauth-facebook (10.0.0)
bigdecimal
omniauth-oauth2 (>= 1.2, < 3)
omniauth-oauth2 (1.9.0)
oauth2 (>= 2.0.2, < 3)
omniauth (~> 2.0)
omniauth-openid (2.0.2)
omniauth (>= 1.1)
rack-openid (~> 1.4)
ruby-openid (~> 2.1, >= 2.1.8)
version_gem (~> 1.1, >= 1.1.8)
orm_adapter (0.5.0)
rack (2.0.4)
rack-openid (1.3.1)
ostruct (0.6.3)
pp (0.6.3)
prettyprint
prettyprint (0.2.0)
psych (5.3.1)
date
stringio
racc (1.8.1)
rack (3.2.4)
rack-openid (1.4.2)
rack (>= 1.1.0)
ruby-openid (>= 2.1.8)
rack-test (1.0.0)
rack (>= 1.0, < 3)
rails (5.2.0)
actioncable (= 5.2.0)
actionmailer (= 5.2.0)
actionpack (= 5.2.0)
actionview (= 5.2.0)
activejob (= 5.2.0)
activemodel (= 5.2.0)
activerecord (= 5.2.0)
activestorage (= 5.2.0)
activesupport (= 5.2.0)
bundler (>= 1.3.0)
railties (= 5.2.0)
sprockets-rails (>= 2.0.0)
rails-controller-testing (1.0.1)
actionpack (~> 5.x)
actionview (~> 5.x)
activesupport (~> 5.x)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
rack-protection (4.2.1)
base64 (>= 0.1.0)
logger (>= 1.6.0)
rack (>= 3.0.0, < 4)
rack-session (2.1.1)
base64 (>= 0.1.0)
rack (>= 3.0.0)
rack-test (2.2.0)
rack (>= 1.3)
rackup (2.3.1)
rack (>= 3)
rails (8.1.1)
actioncable (= 8.1.1)
actionmailbox (= 8.1.1)
actionmailer (= 8.1.1)
actionpack (= 8.1.1)
actiontext (= 8.1.1)
actionview (= 8.1.1)
activejob (= 8.1.1)
activemodel (= 8.1.1)
activerecord (= 8.1.1)
activestorage (= 8.1.1)
activesupport (= 8.1.1)
bundler (>= 1.15.0)
railties (= 8.1.1)
rails-controller-testing (1.0.5)
actionpack (>= 5.0.1.rc1)
actionview (>= 5.0.1.rc1)
activesupport (>= 5.0.1.rc1)
rails-dom-testing (2.3.0)
activesupport (>= 5.0.0)
minitest
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.4)
loofah (~> 2.2, >= 2.2.2)
railties (5.2.0)
actionpack (= 5.2.0)
activesupport (= 5.2.0)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (12.3.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)
rails-html-sanitizer (1.6.2)
loofah (~> 2.21)
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
railties (8.1.1)
actionpack (= 8.1.1)
activesupport (= 8.1.1)
irb (~> 1.13)
rackup (>= 1.0.0)
rake (>= 12.2)
thor (~> 1.0, >= 1.2.2)
tsort (>= 0.2)
zeitwerk (~> 2.6)
rake (13.3.1)
rdoc (7.0.3)
erb
psych (>= 4.0.0)
tsort
reline (0.6.3)
io-console (~> 0.5)
responders (3.2.0)
actionpack (>= 7.0)
railties (>= 7.0)
rexml (3.4.4)
ruby-openid (2.9.2)
ruby2_keywords (0.0.5)
securerandom (0.4.1)
snaky_hash (2.0.3)
hashie (>= 0.1.0, < 6)
version_gem (>= 1.1.8, < 3)
sqlite3 (2.9.0)
mini_portile2 (~> 2.8.0)
stringio (3.2.0)
thor (1.4.0)
timecop (0.9.10)
timeout (0.6.0)
tsort (0.2.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.1)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.3.13)
thor (0.20.0)
thread_safe (0.3.6)
timecop (0.8.1)
tzinfo (1.2.5)
thread_safe (~> 0.1)
warden (1.2.7)
rack (>= 1.0)
uri (1.1.1)
useragent (0.16.11)
version_gem (1.1.9)
warden (1.2.9)
rack (>= 2.0.9)
webrat (0.7.3)
nokogiri (>= 1.2.0)
rack (>= 1.0)
rack-test (>= 0.5.3)
websocket-driver (0.7.0)
websocket-driver (0.8.0)
base64
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.3)
websocket-extensions (0.1.5)
zeitwerk (2.7.4)
PLATFORMS
ruby
DEPENDENCIES
activemodel-serializers-xml!
activerecord-jdbc-adapter
activerecord-jdbcsqlite3-adapter
devise!
jruby-openssl
mocha (~> 1.1)
oauth2
omniauth (~> 1.3)
minitest (< 6)
mocha (~> 2.1)
mongoid (~> 9.0)!
omniauth
omniauth-facebook
omniauth-oauth2
omniauth-openid
rails (~> 5.2)
ostruct
rails (~> 8.1.0)
rails-controller-testing
rdoc
responders (~> 2.4)
sqlite3 (~> 1.3.6)
responders (~> 3.1)
rexml
sqlite3
timecop
webrat (= 0.7.3)
webrat
BUNDLED WITH
1.17.1
4.0.3

View File

@@ -2,7 +2,7 @@
- Do not use the issues tracker for help or support, try Stack Overflow.
- For bugs, do a quick search and make sure the bug has not yet been reported
- If you found a security bug, do not report it through GitHub. Please send an e-mail to opensource@plataformatec.com.br instead.
- If you found a security bug, do not report it through GitHub. Please send an e-mail to heartcombo.oss@gmail.com instead.
- Finally, be nice and have fun!
## Environment

View File

@@ -1,4 +1,5 @@
Copyright 2009-2019 Plataformatec. http://plataformatec.com.br
Copyright (c) 2020-CURRENT Rafael França, Carlos Antonio da Silva
Copyright (c) 2009-2019 Plataformatec
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the

235
README.md
View File

@@ -1,11 +1,4 @@
![Devise Logo](https://raw.github.com/plataformatec/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/).
![Devise Logo](https://raw.github.com/heartcombo/devise/main/devise.png)
Devise is a flexible authentication solution for Rails based on Warden. It:
@@ -16,16 +9,16 @@ Devise is a flexible authentication solution for Rails based on Warden. It:
It's composed of 10 modules:
* [Database Authenticatable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/DatabaseAuthenticatable): hashes and stores a password in the database to validate the authenticity of a user while signing in. The authentication can be done both through POST requests or HTTP Basic Authentication.
* [Omniauthable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Omniauthable): adds OmniAuth (https://github.com/omniauth/omniauth) support.
* [Confirmable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Confirmable): sends emails with confirmation instructions and verifies whether an account is already confirmed during sign in.
* [Recoverable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Recoverable): resets the user password and sends reset instructions.
* [Registerable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Registerable): handles signing up users through a registration process, also allowing them to edit and destroy their account.
* [Rememberable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Rememberable): manages generating and clearing a token for remembering the user from a saved cookie.
* [Trackable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Trackable): tracks sign in count, timestamps and IP address.
* [Timeoutable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Timeoutable): expires sessions that have not been active in a specified period of time.
* [Validatable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Validatable): provides validations of email and password. It's optional and can be customized, so you're able to define your own validations.
* [Lockable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Lockable): locks an account after a specified number of failed sign-in attempts. Can unlock via email or after a specified time period.
* [Database Authenticatable](https://www.rubydoc.info/gems/devise/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](https://www.rubydoc.info/gems/devise/Devise/Models/Omniauthable): adds OmniAuth (https://github.com/omniauth/omniauth) support.
* [Confirmable](https://www.rubydoc.info/gems/devise/Devise/Models/Confirmable): sends emails with confirmation instructions and verifies whether an account is already confirmed during sign in.
* [Recoverable](https://www.rubydoc.info/gems/devise/Devise/Models/Recoverable): resets the user password and sends reset instructions.
* [Registerable](https://www.rubydoc.info/gems/devise/Devise/Models/Registerable): handles signing up users through a registration process, also allowing them to edit and destroy their account.
* [Rememberable](https://www.rubydoc.info/gems/devise/Devise/Models/Rememberable): manages generating and clearing a token for remembering the user from a saved cookie.
* [Trackable](https://www.rubydoc.info/gems/devise/Devise/Models/Trackable): tracks sign in count, timestamps and IP address.
* [Timeoutable](https://www.rubydoc.info/gems/devise/Devise/Models/Timeoutable): expires sessions that have not been active in a specified period of time.
* [Validatable](https://www.rubydoc.info/gems/devise/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](https://www.rubydoc.info/gems/devise/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
@@ -38,6 +31,7 @@ It's composed of 10 modules:
- [RDocs](#rdocs)
- [Example applications](#example-applications)
- [Extensions](#extensions)
- [Supported Ruby / Rails versions](#supported-ruby--rails-versions)
- [Contributing](#contributing)
- [Starting with Rails?](#starting-with-rails)
- [Getting started](#getting-started)
@@ -53,14 +47,12 @@ It's composed of 10 modules:
- [Integration tests](#integration-tests)
- [OmniAuth](#omniauth)
- [Configuring multiple models](#configuring-multiple-models)
- [ActiveJob Integration](#activejob-integration)
- [Active Job Integration](#active-job-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)
<!-- /TOC -->
@@ -73,15 +65,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.oss@gmail.com.
### StackOverflow and Mailing List
@@ -89,15 +81,16 @@ If you have any questions, comments, or concerns, please use StackOverflow inste
http://stackoverflow.com/questions/tagged/devise
The deprecated mailing list can still be read on
The deprecated mailing lists can still be read on:
https://groups.google.com/group/plataformatec-devise
https://groups.google.com/group/heartcombo
### RDocs
You can view the Devise documentation in RDoc format here:
http://rubydoc.info/github/plataformatec/devise/master/frames
http://rubydoc.info/github/heartcombo/devise/main/frames
If you need to use Devise with previous versions of Rails, you can always run "gem server" from the command line after you install the gem to access the old documentation.
@@ -105,26 +98,33 @@ 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
### Supported Ruby / Rails versions
We intend to maintain support for all Ruby / Rails versions that haven't reached end-of-life.
For more information about specific versions please check [Ruby](https://www.ruby-lang.org/en/downloads/branches/)
and [Rails](https://guides.rubyonrails.org/maintenance_policy.html) maintenance policies, and our test matrix.
### 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 `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
Since Devise supports both Mongoid and ActiveRecord, we rely on this variable to run specific code for each ORM.
The default value of `DEVISE_ORM` is `active_record`. To run the tests for Mongoid, you can pass `mongoid`:
```
DEVISE_ORM=mongoid bin/test
@@ -134,20 +134,20 @@ When running the tests for Mongoid, you will need to have a MongoDB server (vers
Please note that the command output will show the variable value being used.
### BUNDLE_GEMFILE
#### BUNDLE_GEMFILE
We can use this variable to tell bundler what Gemfile it should use (instead of the one in the current directory).
Inside the [gemfiles](https://github.com/plataformatec/devise/tree/master/gemfiles) directory, we have one for each version of Rails we support. When you send us a pull request, it may happen that the test suite 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:
Inside the [gemfiles](https://github.com/heartcombo/devise/tree/main/gemfiles) directory, we have one for each version of Rails we support. When you send us a pull request, it may happen that the test suite breaks using some of them. If that's the case, you can simulate the same environment using the `BUNDLE_GEMFILE` variable.
For example, if the tests broke using Ruby 3.4 and Rails 8.0, you can do the following:
```bash
rbenv shell 2.4.2 # or rvm use 2.4.2
BUNDLE_GEMFILE=gemfiles/Gemfile.rails-4.1-stable bundle install
BUNDLE_GEMFILE=gemfiles/Gemfile.rails-4.1-stable bin/test
chruby 3.4.0 # or rbenv shell 3.4.0, or rvm use 3.4.0, etc.
BUNDLE_GEMFILE=gemfiles/Gemfile-rails-8-0 bundle install
BUNDLE_GEMFILE=gemfiles/Gemfile-rails-8-0 bin/test
```
You can also combine both of them if the tests broke for Mongoid:
```bash
BUNDLE_GEMFILE=gemfiles/Gemfile.rails-4.1-stable bundle install
BUNDLE_GEMFILE=gemfiles/Gemfile.rails-4.1-stable DEVISE_ORM=mongoid bin/test
BUNDLE_GEMFILE=gemfiles/Gemfile-rails-8-0 bundle install
BUNDLE_GEMFILE=gemfiles/Gemfile-rails-8-0 DEVISE_ORM=mongoid bin/test
```
### Running tests
@@ -163,35 +163,34 @@ bin/test
bin/test test/models/trackable_test.rb
```
* Running a specific test given a regex:
* Running a specific test given a line number or a regex:
```bash
bin/test test/models/trackable_test.rb:16
bin/test test/models/trackable_test.rb -n '/update.*record/'
```
## 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. Add the following line to your Gemfile:
Devise 5 works with Rails 7 onwards. Run:
```ruby
gem 'devise'
```sh
bundle add devise
```
Then run `bundle install`
Next, you need to run the generator:
```console
$ rails generate devise:install
rails generate devise:install
```
At this point, a number of instructions will appear in the console. Among these instructions, you'll need to set up the default URL options for the Devise mailer in each environment. Here is a possible configuration for `config/environments/development.rb`:
@@ -206,7 +205,7 @@ The generator will install an initializer which describes ALL of Devise's config
In the following command you will replace `MODEL` with the class name used for the applications users (its frequently `User` but could also be `Admin`). This will create a model (if one does not exist) and configure it with the default Devise modules. The generator also configures your `config/routes.rb` file to point to the Devise controller.
```console
$ rails generate devise MODEL
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.
@@ -270,16 +269,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.
@@ -289,7 +288,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
@@ -317,7 +316,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
@@ -378,7 +377,7 @@ We built Devise to help you quickly develop an application that uses authenticat
Since Devise is an engine, all its views are packaged inside the gem. These views will help you get started, but after some time you may want to change them. If this is the case, you just need to invoke the following generator, and it will copy all views to your application:
```console
$ rails generate devise:views
rails generate devise:views
```
If you have more than one Devise model in your application (such as `User` and `Admin`), you will notice that Devise uses the same views for all models. Fortunately, Devise offers an easy way to customize views. All you need to do is set `config.scoped_views = true` inside the `config/initializers/devise.rb` file.
@@ -386,14 +385,14 @@ If you have more than one Devise model in your application (such as `User` and `
After doing so, you will be able to have views based on the role like `users/sessions/new` and `admins/sessions/new`. If no view is found within the scope, Devise will use the default view at `devise/sessions/new`. You can also use the generator to generate scoped views:
```console
$ rails generate devise:views users
rails generate devise:views users
```
If you would like to generate only a few sets of views, like the ones for the `registerable` and `confirmable` module,
you can pass a list of modules to the generator with the `-v` flag.
you can pass a list of views to the generator with the `-v` flag.
```console
$ rails generate devise:views -v registrations confirmations
rails generate devise:views -v registrations confirmations
```
### Configuring controllers
@@ -403,7 +402,7 @@ If the customization at the views level is not enough, you can customize each co
1. Create your custom controllers using the generator which requires a scope:
```console
$ rails generate devise:controllers [scope]
rails generate devise:controllers [scope]
```
If you specify `users` as the scope, controllers will be created in `app/controllers/users/`.
@@ -418,7 +417,7 @@ If the customization at the views level is not enough, you can customize each co
...
end
```
(Use the -c flag to specify a controller, for example: `rails generate devise:controllers users -c=sessions`)
Use the `-c` flag to specify one or more controllers, for example: `rails generate devise:controllers users -c sessions`
2. Tell the router to use this controller:
@@ -426,7 +425,7 @@ If the customization at the views level is not enough, you can customize each co
devise_for :users, controllers: { sessions: 'users/sessions' }
```
3. Copy the views from `devise/sessions` to `users/sessions`. Since the controller was changed, it won't use the default views located in `devise/sessions`.
3. Recommended but not required: copy (or move) the views from `devise/sessions` to `users/sessions`. Rails will continue using the views from `devise/sessions` due to inheritance if you skip this step, but having the views matching the controller(s) keeps things consistent.
4. Finally, change or extend the desired controller actions.
@@ -440,7 +439,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
@@ -464,7 +463,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](https://www.rubydoc.info/gems/devise/ActionDispatch/Routing/Mapper#devise_for-instance_method) 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:
@@ -482,6 +481,37 @@ Please note: You will still need to add `devise_for` in your routes in order to
devise_for :users, skip: :all
```
### Hotwire/Turbo
Devise integrates with Hotwire/Turbo by treating such requests as navigational, and configuring certain responses for errors and redirects to match the expected behavior. New apps are generated with the following response configuration by default, and existing apps may opt-in by adding the config to their Devise initializers:
```ruby
Devise.setup do |config|
# ...
# When using Devise with Hotwire/Turbo, the http status for error responses
# and some redirects must match the following. The default in Devise for existing
# apps is `200 OK` and `302 Found` respectively, but new apps are generated with
# these new defaults that match Hotwire/Turbo behavior.
# Note: These might become the new default in future versions of Devise.
config.responder.error_status = :unprocessable_content # for Rack 3.1 or higher
# config.responder.error_status = :unprocessable_entity # for Rack 3.0 or lower
config.responder.redirect_status = :see_other
end
```
**Important**: these custom responses require the `responders` gem version to be `3.1.0` or higher, please make sure you update it if you're going to use this configuration. Check [this upgrade guide](https://github.com/heartcombo/devise/wiki/How-To:-Upgrade-to-Devise-4.9.0-[Hotwire-Turbo-integration]) for more info.
_Note_: the above statuses configuration may become the default for Devise in a future release.
There are a couple other changes you might need to make in your app to work with Hotwire/Turbo, if you're migrating from rails-ujs:
* The `data-confirm` option that adds a confirmation modal to buttons/forms before submission needs to change to `data-turbo-confirm`, so that Turbo handles those appropriately.
* The `data-method` option that sets the request method for link submissions needs to change to `data-turbo-method`. This is not necessary for `button_to` or `form`s since Turbo can handle those.
If you're setting up Devise to sign out via `:delete`, and you're using links (instead of buttons wrapped in a form) to sign out with the `method: :delete` option, they will need to be updated as described above. (Devise does not provide sign out links/buttons in its shared views.)
Make sure to inspect your views looking for those, and change appropriately.
### I18n
Devise uses flash messages with I18n, in conjunction with the flash keys :notice and :alert. To customize your app, you can set up your locale file:
@@ -520,7 +550,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.
@@ -532,15 +562,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 5, include `Devise::Test::IntegrationHelpers` instead, since the superclass
for controller tests has been changed to ActionDispatch::IntegrationTest
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
```
@@ -618,9 +654,9 @@ Unlike controller tests, integration tests do not need to supply the
`devise.mapping` `env` value, as the mapping can be inferred by the routes that
are executed in your tests.
You can read more about testing your Rails 3 - Rails 4 controllers with RSpec in the wiki:
You can read more about testing your Rails controllers with RSpec in the wiki:
* https://github.com/plataformatec/devise/wiki/How-To:-Test-controllers-with-Rails-(and-RSpec)
* https://github.com/heartcombo/devise/wiki/How-To:-Test-controllers-with-Rails-(and-RSpec)
### OmniAuth
@@ -632,7 +668,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
@@ -665,9 +701,9 @@ Alternatively, you can simply run the Devise generator.
Keep in mind that those models will have completely different routes. They **do not** and **cannot** share the same controller for sign in, sign out and so on. In case you want to have different roles sharing the same actions, we recommend that you use a role-based approach, by either providing a role column or using a dedicated gem for authorization.
### ActiveJob Integration
### Active Job Integration
If you are using Rails 4.2 and ActiveJob to deliver ActionMailer messages in the
If you are using Active Job to deliver Action Mailer messages in the
background through a queuing back-end, you can send Devise emails through your
existing queue by overriding the `send_devise_notification` method in your model.
@@ -679,12 +715,12 @@ 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](https://www.rubydoc.info/gems/devise/Devise/Models/Recoverable) module, note that a stolen password reset token could give an attacker access to your application. Devise takes effort to generate random, secure tokens, and stores only token digests in the database, never plaintext. However the default logging behavior in Rails can cause plaintext tokens to leak into log files:
1. Action Mailer logs the entire contents of all outgoing emails to the DEBUG level. Password reset tokens delivered to users in email will be leaked.
2. Active Job logs all arguments to every enqueued job at the INFO level. If you configure Devise to use `deliver_later` to send password reset emails, password reset tokens will be leaked.
Rails sets the production logger level to DEBUG by default. Consider changing your production logger level to WARN if you wish to prevent tokens from being leaked into your logs. In `config/environments/production.rb`:
Rails sets the production logger level to INFO by default. Consider changing your production logger level to WARN if you wish to prevent tokens from being leaked into your logs. In `config/environments/production.rb`:
```ruby
config.log_level = :warn
@@ -697,41 +733,44 @@ Devise supports ActiveRecord (default) and Mongoid. To select another ORM, simpl
### Rails API Mode
Rails 5+ has a built-in [API Mode](https://edgeguides.rubyonrails.org/api_app.html) which optimizes Rails for use as an API (only). One of the side effects is that it changes the order of the middleware stack, and this can cause problems for `Devise::Test::IntegrationHelpers`. This problem usually surfaces as an ```undefined method `[]=' for nil:NilClass``` error when using integration test helpers, such as `#sign_in`. The solution is simply to reorder the middlewares by adding the following to test.rb:
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/))
#### 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.http_authenticatable = [:database]
```
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/plataformatec/devise/issues/4696).
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
### Heroku
Using Devise on Heroku with Ruby on Rails 3.2 requires setting:
```ruby
config.assets.initialize_on_precompile = false
```
Read more about the potential issues at http://guides.rubyonrails.org/asset_pipeline.html
### 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
### Contributors
We have a long list of valued contributors. Check them all at:
https://github.com/plataformatec/devise/graphs/contributors
https://github.com/wardencommunity/warden
## License
MIT License. Copyright 2009-2018 Plataformatec. http://plataformatec.com.br
MIT License.
Copyright 2020-CURRENT Rafael França, Carlos Antonio 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

@@ -27,6 +27,7 @@ class Devise::ConfirmationsController < DeviseController
set_flash_message!(:notice, :confirmed)
respond_with_navigational(resource){ redirect_to after_confirmation_path_for(resource_name, resource) }
else
# TODO: use `error_status` when the default changes to `:unprocessable_entity` / `:unprocessable_content`.
respond_with_navigational(resource.errors, status: :unprocessable_entity){ render :new }
end
end

View File

@@ -36,7 +36,7 @@ class Devise::PasswordsController < DeviseController
if resource.errors.empty?
resource.unlock_access! if unlockable?(resource)
if Devise.sign_in_after_reset_password
if resource_class.sign_in_after_reset_password
flash_message = resource.active_for_authentication? ? :updated : :updated_not_active
set_flash_message!(:notice, flash_message)
resource.after_database_authentication
@@ -53,7 +53,7 @@ class Devise::PasswordsController < DeviseController
protected
def after_resetting_password_path_for(resource)
Devise.sign_in_after_reset_password ? after_sign_in_path_for(resource) : new_session_path(resource_name)
resource_class.sign_in_after_reset_password ? after_sign_in_path_for(resource) : new_session_path(resource_name)
end
# The path used after sending reset password instructions

View File

@@ -67,7 +67,7 @@ class Devise::RegistrationsController < DeviseController
Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name)
set_flash_message! :notice, :destroyed
yield resource if block_given?
respond_with_navigational(resource){ redirect_to after_sign_out_path_for(resource_name) }
respond_with_navigational(resource){ redirect_to after_sign_out_path_for(resource_name), status: Devise.responder.redirect_status }
end
# GET /resource/cancel

View File

@@ -28,7 +28,7 @@ class Devise::SessionsController < DeviseController
signed_out = (Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name))
set_flash_message! :notice, :signed_out if signed_out
yield if block_given?
respond_to_on_destroy
respond_to_on_destroy(non_navigational_status: :no_content)
end
protected
@@ -45,7 +45,7 @@ class Devise::SessionsController < DeviseController
end
def auth_options
{ scope: resource_name, recall: "#{controller_path}#new" }
{ scope: resource_name, recall: "#{controller_path}#new", locale: I18n.locale }
end
def translation_scope
@@ -62,7 +62,7 @@ class Devise::SessionsController < DeviseController
if all_signed_out?
set_flash_message! :notice, :already_signed_out
respond_to_on_destroy
respond_to_on_destroy(non_navigational_status: :unauthorized)
end
end
@@ -72,12 +72,12 @@ class Devise::SessionsController < DeviseController
users.all?(&:blank?)
end
def respond_to_on_destroy
def respond_to_on_destroy(non_navigational_status: :no_content)
# We actually need to hardcode this as Rails default responder doesn't
# support returning empty response on GET request
respond_to do |format|
format.all { head :no_content }
format.any(*navigational_formats) { redirect_to after_sign_out_path_for(resource_name) }
format.all { head non_navigational_status }
format.any(*navigational_formats) { redirect_to after_sign_out_path_for(resource_name), status: Devise.responder.redirect_status }
end
end
end

View File

@@ -29,6 +29,7 @@ class Devise::UnlocksController < DeviseController
set_flash_message! :notice, :unlocked
respond_with_navigational(resource){ redirect_to after_unlock_path_for(resource) }
else
# TODO: use `error_status` when the default changes to `:unprocessable_entity` / `:unprocessable_content`.
respond_with_navigational(resource.errors, status: :unprocessable_entity){ render :new }
end
end

View File

@@ -15,6 +15,7 @@ class DeviseController < Devise.parent_controller.constantize
end
prepend_before_action :assert_is_devise_resource!
self.responder = Devise.responder
respond_to :html if mimes_for_respond_to.empty?
# Override prefixes to consider the scoped view.
@@ -32,6 +33,19 @@ class DeviseController < Devise.parent_controller.constantize
end
end
# Override internal methods to exclude `_prefixes` from action methods since
# we override it above.
#
# There was an intentional change in Rails 7.1 that will allow it to become
# an action method because it's a public method of a non-abstract controller,
# but we also can't make this abstract because it can affect potential actions
# defined in the parent controller, so instead we ensure `_prefixes` is going
# to be considered internal. (and thus, won't become an action method.)
# Ref: https://github.com/rails/rails/pull/48699
def self.internal_methods #:nodoc:
super << :_prefixes
end
protected
# Gets the actual resource stored in the instance variable
@@ -112,7 +126,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 +198,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,18 +1,5 @@
# frozen_string_literal: true
# Keeping the helper around for backward compatibility.
module DeviseHelper
# Retain this method for backwards compatibility, deprecated in favour of modifying the
# devise/shared/error_messages partial
def devise_error_messages!
ActiveSupport::Deprecation.warn <<-DEPRECATION.strip_heredoc
[Devise] `DeviseHelper.devise_error_messages!`
is deprecated and it will be removed in the next major version.
To customize the errors styles please run `rails g devise:views` and modify the
`devise/shared/error_messages` partial.
DEPRECATION
return "" if resource.errors.empty?
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

@@ -4,8 +4,8 @@
<%= render "devise/shared/error_messages", resource: resource %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true, autocomplete: "email", value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %>
<p><%= f.label :email %></p>
<p><%= f.email_field :email, autofocus: true, autocomplete: "email", value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %></p>
</div>
<div class="actions">

View File

@@ -5,16 +5,16 @@
<%= f.hidden_field :reset_password_token %>
<div class="field">
<%= f.label :password, "New password" %><br />
<p><%= f.label :password, "New password" %></p>
<% if @minimum_password_length %>
<em>(<%= @minimum_password_length %> characters minimum)</em><br />
<p><em>(<%= @minimum_password_length %> characters minimum)</em></p>
<% end %>
<%= f.password_field :password, autofocus: true, autocomplete: "new-password" %>
<p><%= f.password_field :password, autofocus: true, autocomplete: "new-password" %></p>
</div>
<div class="field">
<%= f.label :password_confirmation, "Confirm new password" %><br />
<%= f.password_field :password_confirmation, autocomplete: "off" %>
<p><%= f.label :password_confirmation, "Confirm new password" %></p>
<p><%= f.password_field :password_confirmation, autocomplete: "new-password" %></p>
</div>
<div class="actions">

View File

@@ -4,12 +4,12 @@
<%= render "devise/shared/error_messages", resource: resource %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true, autocomplete: "email" %>
<p><%= f.label :email %></p>
<p><%= f.email_field :email, autofocus: true, autocomplete: "email" %></p>
</div>
<div class="actions">
<%= f.submit "Send me reset password instructions" %>
<%= f.submit "Send me password reset instructions" %>
</div>
<% end %>

View File

@@ -4,8 +4,8 @@
<%= render "devise/shared/error_messages", resource: resource %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true, autocomplete: "email" %>
<p><%= f.label :email %></p>
<p><%= f.email_field :email, autofocus: true, autocomplete: "email" %></p>
</div>
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
@@ -13,22 +13,21 @@
<% end %>
<div class="field">
<%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
<%= f.password_field :password, autocomplete: "new-password" %>
<p><%= f.label :password %> <i>(leave blank if you don't want to change it)</i></p>
<p><%= f.password_field :password, autocomplete: "new-password" %></p>
<% if @minimum_password_length %>
<br />
<em><%= @minimum_password_length %> characters minimum</em>
<p><em><%= @minimum_password_length %> characters minimum</em></p>
<% end %>
</div>
<div class="field">
<%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation, autocomplete: "new-password" %>
<p><%= f.label :password_confirmation %></p>
<p><%= f.password_field :password_confirmation, autocomplete: "new-password" %></p>
</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: "current-password" %>
<p><%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i></p>
<p><%= f.password_field :current_password, autocomplete: "current-password" %></p>
</div>
<div class="actions">
@@ -38,6 +37,6 @@
<h3>Cancel my account</h3>
<p>Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %></p>
<div>Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?", turbo_confirm: "Are you sure?" }, method: :delete %></div>
<%= link_to "Back", :back %>

View File

@@ -4,21 +4,21 @@
<%= render "devise/shared/error_messages", resource: resource %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true, autocomplete: "email" %>
<p><%= f.label :email %></p>
<p><%= f.email_field :email, autofocus: true, autocomplete: "email" %></p>
</div>
<div class="field">
<%= f.label :password %>
<p><%= f.label :password %></p>
<% if @minimum_password_length %>
<em>(<%= @minimum_password_length %> characters minimum)</em>
<% end %><br />
<%= f.password_field :password, autocomplete: "new-password" %>
<p><em>(<%= @minimum_password_length %> characters minimum)</em></p>
<% end %>
<p><%= f.password_field :password, autocomplete: "new-password" %></p>
</div>
<div class="field">
<%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation, autocomplete: "new-password" %>
<p><%= f.label :password_confirmation %></p>
<p><%= f.password_field :password_confirmation, autocomplete: "new-password" %></p>
</div>
<div class="actions">

View File

@@ -2,19 +2,19 @@
<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true, autocomplete: "email" %>
<p><%= f.label :email %></p>
<p><%= f.email_field :email, autofocus: true, autocomplete: "email" %></p>
</div>
<div class="field">
<%= f.label :password %><br />
<%= f.password_field :password, autocomplete: "current-password" %>
<p><%= f.label :password %></p>
<p><%= f.password_field :password, autocomplete: "current-password" %></p>
</div>
<% if devise_mapping.rememberable? %>
<div class="field">
<%= f.check_box :remember_me %>
<%= f.label :remember_me %>
<p><%= f.check_box :remember_me %></p>
<p><%= f.label :remember_me %></p>
</div>
<% end %>

View File

@@ -1,5 +1,5 @@
<% if resource.errors.any? %>
<div id="error_explanation">
<div id="error_explanation" data-turbo-temporary>
<h2>
<%= I18n.t("errors.messages.not_saved",
count: resource.errors.count,

View File

@@ -1,25 +1,25 @@
<%- if controller_name != 'sessions' %>
<%= link_to "Log in", new_session_path(resource_name) %><br />
<p><%= link_to "Log in", new_session_path(resource_name) %></p>
<% end %>
<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
<%= link_to "Sign up", new_registration_path(resource_name) %><br />
<p><%= link_to "Sign up", new_registration_path(resource_name) %></p>
<% end %>
<%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %>
<%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
<p><%= link_to "Forgot your password?", new_password_path(resource_name) %></p>
<% end %>
<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
<p><%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %></p>
<% 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 />
<p><%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %></p>
<% 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 />
<p><%= button_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider), data: { turbo: false } %></p>
<% end %>
<% end %>

View File

@@ -4,8 +4,8 @@
<%= render "devise/shared/error_messages", resource: resource %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true, autocomplete: "email" %>
<p><%= f.label :email %></p>
<p><%= f.email_field :email, autofocus: true, autocomplete: "email" %></p>
</div>
<div class="actions">

View File

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

@@ -10,18 +10,26 @@ 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.oss@gmail.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.metadata = {
"homepage_uri" => "https://github.com/heartcombo/devise",
"documentation_uri" => "https://rubydoc.info/github/heartcombo/devise",
"changelog_uri" => "https://github.com/heartcombo/devise/blob/main/CHANGELOG.md",
"source_code_uri" => "https://github.com/heartcombo/devise",
"bug_tracker_uri" => "https://github.com/heartcombo/devise/issues",
"wiki_uri" => "https://github.com/heartcombo/devise/wiki"
}
s.files = Dir["{app,config,lib}/**/*", "CHANGELOG.md", "MIT-LICENSE", "README.md"]
s.require_paths = ["lib"]
s.required_ruby_version = '>= 2.1.0'
s.required_ruby_version = '>= 2.7.0'
s.add_dependency("warden", "~> 1.2.3")
s.add_dependency("orm_adapter", "~> 0.1")
s.add_dependency("bcrypt", "~> 3.0")
s.add_dependency("railties", ">= 4.1.0", "< 6.0")
s.add_dependency("railties", ">= 7.0")
s.add_dependency("responders")
end

View File

@@ -2,26 +2,30 @@ source "https://rubygems.org"
gemspec path: ".."
gem "rails", '~> 5.2'
gem "rails", "~> 7.0.0"
gem "omniauth"
gem "omniauth-oauth2"
gem "rdoc"
gem "activemodel-serializers-xml", github: "rails/activemodel-serializers-xml"
gem "rails-controller-testing"
gem "responders", "~> 2.1"
gem "responders", "~> 3.1"
group :test do
gem "omniauth-facebook"
gem "omniauth-openid"
gem "rexml"
gem "timecop"
gem "webrat", "0.7.3", require: false
gem "mocha", "~> 1.1", require: false
gem 'test_after_commit', require: false
gem "mocha", "~> 2.1", require: false
gem "minitest", "< 6"
gem "ostruct"
end
platforms :ruby do
gem "sqlite3", "~> 1.3.6"
gem "sqlite3", "~> 1.4"
end
group :mongoid do
gem "mongoid", "~> 7.5"
end

View File

@@ -0,0 +1,31 @@
source "https://rubygems.org"
gemspec path: ".."
gem "rails", "~> 7.1.0"
gem "omniauth"
gem "omniauth-oauth2"
gem "rdoc"
gem "rails-controller-testing"
gem "responders", "~> 3.1"
group :test do
gem "omniauth-facebook"
gem "omniauth-openid"
gem "rexml"
gem "timecop"
gem "webrat"
gem "mocha", "~> 2.1", require: false
gem "minitest", "< 6"
gem "ostruct"
end
platforms :ruby do
gem "sqlite3", "~> 1.4"
end
group :mongoid do
gem "mongoid", "~> 8.1"
end

View File

@@ -0,0 +1,32 @@
source "https://rubygems.org"
gemspec path: ".."
gem "rails", "~> 7.1.0"
gem "omniauth"
gem "omniauth-oauth2"
gem "rdoc"
gem "rails-controller-testing"
gem "responders", "~> 3.1"
group :test do
gem "omniauth-facebook"
gem "omniauth-openid"
gem "rexml"
gem "timecop"
gem "webrat", require: false
gem "mocha", "~> 2.1", require: false
gem "minitest", "< 6"
gem "ostruct"
end
platforms :ruby do
gem "sqlite3"
end
group :mongoid do
gem "mongoid", "~> 8.1"
end

View File

@@ -0,0 +1,31 @@
source "https://rubygems.org"
gemspec path: ".."
gem "rails", "~> 8.0.0"
gem "omniauth"
gem "omniauth-oauth2"
gem "rdoc"
gem "rails-controller-testing"
gem "responders", "~> 3.1"
group :test do
gem "omniauth-facebook"
gem "omniauth-openid"
gem "rexml"
gem "timecop"
gem 'webrat'
gem "mocha", "~> 2.1", require: false
gem "minitest", "< 6"
gem "ostruct"
end
platforms :ruby do
gem "sqlite3"
end
group :mongoid do
gem "mongoid", "~> 8.1"
end

View File

@@ -2,26 +2,30 @@ source "https://rubygems.org"
gemspec path: ".."
gem "rails", '6.0.0.beta1'
gem "rails", github: "rails/rails", branch: "main"
gem "omniauth"
gem "omniauth-oauth2"
gem "rdoc"
gem "activemodel-serializers-xml", github: "rails/activemodel-serializers-xml"
gem "rails-controller-testing"
gem "responders", "~> 2.4"
gem "responders", "~> 3.1"
group :test do
gem "omniauth-facebook"
gem "omniauth-openid"
gem "rexml"
gem "timecop"
gem "webrat", "0.7.3", require: false
gem "mocha", "~> 1.1", require: false
gem 'test_after_commit', require: false
gem "mocha", "~> 2.1", require: false
gem "minitest", "< 6"
gem "ostruct"
end
platforms :ruby do
gem "sqlite3", "~> 1.3.6"
gem "sqlite3"
end
group :mongoid do
gem "mongoid", github: "mongodb/mongoid", branch: "master"
end

View File

@@ -1,35 +0,0 @@
# frozen_string_literal: true
source "https://rubygems.org"
gemspec path: ".."
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
end
platforms :jruby do
gem "activerecord-jdbc-adapter"
gem "activerecord-jdbcsqlite3-adapter"
gem "jruby-openssl"
end
platforms :ruby do
gem "sqlite3", "~> 1.3.6"
end
group :mongoid do
gem "mongoid", "~> 4.0"
end

View File

@@ -1,174 +0,0 @@
GIT
remote: git://github.com/rails/rails.git
revision: 0cad778c2605a5204a05a9f1dbd3344e39f248d8
branch: 4-1-stable
specs:
actionmailer (4.1.16)
actionpack (= 4.1.16)
actionview (= 4.1.16)
mail (~> 2.5, >= 2.5.4)
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.6.2)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0, < 6.0)
responders
warden (~> 1.2.3)
GEM
remote: https://rubygems.org/
specs:
actionpack (4.1.16)
actionview (= 4.1.16)
activesupport (= 4.1.16)
rack (~> 1.5.2)
rack-test (~> 0.6.2)
actionview (4.1.16)
activesupport (= 4.1.16)
builder (~> 3.1)
erubis (~> 2.7.0)
activemodel (4.1.16)
activesupport (= 4.1.16)
builder (~> 3.1)
activerecord (4.1.16)
activemodel (= 4.1.16)
activesupport (= 4.1.16)
arel (~> 5.0.0)
activesupport (4.1.16)
i18n (~> 0.6, >= 0.6.9)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.1)
tzinfo (~> 1.1)
arel (5.0.1.20140414130214)
bcrypt (3.1.12)
bson (3.2.6)
builder (3.2.3)
concurrent-ruby (1.0.5)
connection_pool (2.2.1)
erubis (2.7.0)
faraday (0.11.0)
multipart-post (>= 1.2, < 3)
hashie (3.5.5)
i18n (0.8.1)
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.4.0)
minitest (5.10.1)
mocha (1.2.1)
metaclass (~> 0.0.1)
mongoid (4.0.2)
activemodel (~> 4.0)
moped (~> 2.0.0)
origin (~> 2.1)
tzinfo (>= 0.3.37)
moped (2.0.7)
bson (~> 3.0)
connection_pool (~> 2.0)
optionable (~> 0.2.0)
multi_json (1.12.1)
multi_xml (0.6.0)
multipart-post (2.0.0)
nokogiri (1.9.1)
mini_portile2 (~> 2.4.0)
oauth2 (1.3.1)
faraday (>= 0.8, < 0.12)
jwt (~> 1.0)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
omniauth (1.4.2)
hashie (>= 1.2, < 4)
rack (>= 1.0, < 3)
omniauth-facebook (4.0.0)
omniauth-oauth2 (~> 1.2)
omniauth-oauth2 (1.4.0)
oauth2 (~> 1.0)
omniauth (~> 1.2)
omniauth-openid (1.0.1)
omniauth (~> 1.0)
rack-openid (~> 1.3.1)
optionable (0.2.0)
origin (2.3.0)
orm_adapter (0.5.0)
rack (1.5.5)
rack-openid (1.3.1)
rack (>= 1.1.0)
ruby-openid (>= 2.1.8)
rack-test (0.6.3)
rack (>= 1.0)
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)
rdoc (5.1.0)
responders (1.1.2)
railties (>= 3.2, < 4.2)
ruby-openid (2.7.0)
sprockets (3.7.1)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (2.3.3)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
sqlite3 (1.3.13)
test_after_commit (1.1.0)
activerecord (>= 3.2)
thor (0.19.4)
thread_safe (0.3.6)
timecop (0.8.1)
tzinfo (1.2.2)
thread_safe (~> 0.1)
warden (1.2.7)
rack (>= 1.0)
webrat (0.7.3)
nokogiri (>= 1.2.0)
rack (>= 1.0)
rack-test (>= 0.5.3)
PLATFORMS
ruby
DEPENDENCIES
activerecord-jdbc-adapter
activerecord-jdbcsqlite3-adapter
devise!
jruby-openssl
mocha (~> 1.1)
mongoid (~> 4.0)
nokogiri (= 1.9.1)
omniauth
omniauth-facebook
omniauth-oauth2
omniauth-openid
rails!
rdoc (~> 5.1)
sqlite3 (~> 1.3.6)
test_after_commit
timecop
webrat (= 0.7.3)
BUNDLED WITH
1.17.3

View File

@@ -1,34 +0,0 @@
# frozen_string_literal: true
source "https://rubygems.org"
gemspec path: ".."
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
end
platforms :jruby do
gem "activerecord-jdbc-adapter"
gem "activerecord-jdbcsqlite3-adapter"
gem "jruby-openssl"
end
platforms :ruby do
gem "sqlite3", "~> 1.3.6"
end
group :mongoid do
gem "mongoid", "~> 4.0"
end

View File

@@ -1,195 +0,0 @@
GIT
remote: git://github.com/rails/rails.git
revision: dc3ae21802c316e1639239d28202db7aa7fb7cac
branch: 4-2-stable
specs:
actionmailer (4.2.8)
actionpack (= 4.2.8)
actionview (= 4.2.8)
activejob (= 4.2.8)
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)
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)
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)
globalid (>= 0.3.0)
activemodel (4.2.8)
activesupport (= 4.2.8)
builder (~> 3.1)
activerecord (4.2.8)
activemodel (= 4.2.8)
activesupport (= 4.2.8)
arel (~> 6.0)
activesupport (4.2.8)
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)
bundler (>= 1.3.0, < 2.0)
railties (= 4.2.8)
sprockets-rails
railties (4.2.8)
actionpack (= 4.2.8)
activesupport (= 4.2.8)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
PATH
remote: ..
specs:
devise (4.6.2)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0, < 6.0)
responders
warden (~> 1.2.3)
GEM
remote: https://rubygems.org/
specs:
arel (6.0.4)
bcrypt (3.1.12)
bson (3.2.6)
builder (3.2.3)
concurrent-ruby (1.0.5)
connection_pool (2.2.1)
erubis (2.7.0)
faraday (0.11.0)
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)
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.4.0)
minitest (5.10.1)
mocha (1.2.1)
metaclass (~> 0.0.1)
mongoid (4.0.2)
activemodel (~> 4.0)
moped (~> 2.0.0)
origin (~> 2.1)
tzinfo (>= 0.3.37)
moped (2.0.7)
bson (~> 3.0)
connection_pool (~> 2.0)
optionable (~> 0.2.0)
multi_json (1.12.1)
multi_xml (0.6.0)
multipart-post (2.0.0)
nokogiri (1.9.1)
mini_portile2 (~> 2.4.0)
oauth2 (1.3.1)
faraday (>= 0.8, < 0.12)
jwt (~> 1.0)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
omniauth (1.6.1)
hashie (>= 3.4.6, < 3.6.0)
rack (>= 1.6.2, < 3)
omniauth-facebook (4.0.0)
omniauth-oauth2 (~> 1.2)
omniauth-oauth2 (1.4.0)
oauth2 (~> 1.0)
omniauth (~> 1.2)
omniauth-openid (1.0.1)
omniauth (~> 1.0)
rack-openid (~> 1.3.1)
optionable (0.2.0)
origin (2.3.0)
orm_adapter (0.5.0)
rack (1.6.5)
rack-openid (1.3.1)
rack (>= 1.1.0)
ruby-openid (>= 2.1.8)
rack-test (0.6.3)
rack (>= 1.0)
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.8)
activesupport (>= 4.2.0.beta, < 5.0)
nokogiri (~> 1.6)
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
rake (12.0.0)
rdoc (5.1.0)
responders (2.4.1)
actionpack (>= 4.2.0, < 6.0)
railties (>= 4.2.0, < 6.0)
ruby-openid (2.7.0)
sprockets (3.7.1)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.0)
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)
thread_safe (0.3.6)
timecop (0.8.1)
tzinfo (1.2.2)
thread_safe (~> 0.1)
warden (1.2.7)
rack (>= 1.0)
webrat (0.7.3)
nokogiri (>= 1.2.0)
rack (>= 1.0)
rack-test (>= 0.5.3)
PLATFORMS
ruby
DEPENDENCIES
activerecord-jdbc-adapter
activerecord-jdbcsqlite3-adapter
devise!
jruby-openssl
mocha (~> 1.1)
mongoid (~> 4.0)
nokogiri (= 1.9.1)
omniauth
omniauth-facebook
omniauth-oauth2
omniauth-openid
rails!
rdoc (~> 5.1)
sqlite3 (~> 1.3.6)
test_after_commit
timecop
webrat (= 0.7.3)
BUNDLED WITH
1.17.3

View File

@@ -1,34 +0,0 @@
# frozen_string_literal: true
source "https://rubygems.org"
gemspec path: ".."
gem "rails", '~> 5.0.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
gem 'test_after_commit', require: false
end
platforms :ruby do
gem "sqlite3", "~> 1.3.6"
end
# TODO:
# group :mongoid do
# gem "mongoid", "~> 4.0.0"
# end

View File

@@ -1,194 +0,0 @@
GIT
remote: git://github.com/rails/activemodel-serializers-xml.git
revision: dd9c0acf26aab111ebc647cd8deb99ebc6946531
specs:
activemodel-serializers-xml (1.0.1)
activemodel (> 5.x)
activesupport (> 5.x)
builder (~> 3.1)
PATH
remote: ..
specs:
devise (4.6.2)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0, < 6.0)
responders
warden (~> 1.2.3)
GEM
remote: https://rubygems.org/
specs:
actioncable (5.0.2)
actionpack (= 5.0.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)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.0.2)
actionview (= 5.0.2)
activesupport (= 5.0.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)
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)
globalid (>= 0.3.6)
activemodel (5.0.2)
activesupport (= 5.0.2)
activerecord (5.0.2)
activemodel (= 5.0.2)
activesupport (= 5.0.2)
arel (~> 7.0)
activesupport (5.0.2)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
minitest (~> 5.1)
tzinfo (~> 1.1)
arel (7.1.4)
bcrypt (3.1.12)
builder (3.2.3)
concurrent-ruby (1.0.5)
erubis (2.7.0)
faraday (0.11.0)
multipart-post (>= 1.2, < 3)
globalid (0.4.0)
activesupport (>= 4.2.0)
hashie (3.5.5)
i18n (0.8.1)
jwt (1.5.6)
loofah (2.0.3)
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)
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)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
omniauth (1.6.1)
hashie (>= 3.4.6, < 3.6.0)
rack (>= 1.6.2, < 3)
omniauth-facebook (4.0.0)
omniauth-oauth2 (~> 1.2)
omniauth-oauth2 (1.4.0)
oauth2 (~> 1.0)
omniauth (~> 1.2)
omniauth-openid (1.0.1)
omniauth (~> 1.0)
rack-openid (~> 1.3.1)
orm_adapter (0.5.0)
rack (2.0.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)
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.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)
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)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.0)
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)
thread_safe (0.3.6)
timecop (0.8.1)
tzinfo (1.2.3)
thread_safe (~> 0.1)
warden (1.2.7)
rack (>= 1.0)
webrat (0.7.3)
nokogiri (>= 1.2.0)
rack (>= 1.0)
rack-test (>= 0.5.3)
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2)
PLATFORMS
ruby
DEPENDENCIES
activemodel-serializers-xml!
devise!
mocha (~> 1.1)
omniauth
omniauth-facebook
omniauth-oauth2
omniauth-openid
rails (~> 5.0.0)
rails-controller-testing
rdoc
responders (~> 2.1)
sqlite3 (~> 1.3.6)
test_after_commit
timecop
webrat (= 0.7.3)
BUNDLED WITH
1.17.1

View File

@@ -1,203 +0,0 @@
GIT
remote: git://github.com/rails/activemodel-serializers-xml.git
revision: f744aeca2747ed3134e492249c4ee39b548efdf6
specs:
activemodel-serializers-xml (1.0.2)
activemodel (> 5.x)
activesupport (> 5.x)
builder (~> 3.1)
PATH
remote: ..
specs:
devise (4.6.2)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0, < 6.0)
responders
warden (~> 1.2.3)
GEM
remote: https://rubygems.org/
specs:
actioncable (5.2.1)
actionpack (= 5.2.1)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailer (5.2.1)
actionpack (= 5.2.1)
actionview (= 5.2.1)
activejob (= 5.2.1)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.2.1)
actionview (= 5.2.1)
activesupport (= 5.2.1)
rack (~> 2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.2.1)
activesupport (= 5.2.1)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.2.1)
activesupport (= 5.2.1)
globalid (>= 0.3.6)
activemodel (5.2.1)
activesupport (= 5.2.1)
activerecord (5.2.1)
activemodel (= 5.2.1)
activesupport (= 5.2.1)
arel (>= 9.0)
activestorage (5.2.1)
actionpack (= 5.2.1)
activerecord (= 5.2.1)
marcel (~> 0.3.1)
activesupport (5.2.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
arel (9.0.0)
bcrypt (3.1.12)
builder (3.2.3)
concurrent-ruby (1.0.5)
crass (1.0.4)
erubi (1.7.1)
faraday (0.12.2)
multipart-post (>= 1.2, < 3)
globalid (0.4.1)
activesupport (>= 4.2.0)
hashie (3.5.7)
i18n (1.1.0)
concurrent-ruby (~> 1.0)
jwt (1.5.6)
loofah (2.2.2)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.0)
mini_mime (>= 0.1.1)
marcel (0.3.3)
mimemagic (~> 0.3.2)
metaclass (0.0.4)
method_source (0.9.0)
mimemagic (0.3.2)
mini_mime (1.0.1)
mini_portile2 (2.3.0)
minitest (5.11.3)
mocha (1.7.0)
metaclass (~> 0.0.1)
multi_json (1.13.1)
multi_xml (0.6.0)
multipart-post (2.0.0)
nio4r (2.3.1)
nokogiri (1.8.5)
mini_portile2 (~> 2.3.0)
oauth2 (1.4.0)
faraday (>= 0.8, < 0.13)
jwt (~> 1.0)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
omniauth (1.8.1)
hashie (>= 3.4.6, < 3.6.0)
rack (>= 1.6.2, < 3)
omniauth-facebook (5.0.0)
omniauth-oauth2 (~> 1.2)
omniauth-oauth2 (1.5.0)
oauth2 (~> 1.1)
omniauth (~> 1.2)
omniauth-openid (1.0.1)
omniauth (~> 1.0)
rack-openid (~> 1.3.1)
orm_adapter (0.5.0)
rack (2.0.5)
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.1)
actioncable (= 5.2.1)
actionmailer (= 5.2.1)
actionpack (= 5.2.1)
actionview (= 5.2.1)
activejob (= 5.2.1)
activemodel (= 5.2.1)
activerecord (= 5.2.1)
activestorage (= 5.2.1)
activesupport (= 5.2.1)
bundler (>= 1.3.0)
railties (= 5.2.1)
sprockets-rails (>= 2.0.0)
rails-controller-testing (1.0.2)
actionpack (~> 5.x, >= 5.0.1)
actionview (~> 5.x, >= 5.0.1)
activesupport (~> 5.x)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.4)
loofah (~> 2.2, >= 2.2.2)
railties (5.2.1)
actionpack (= 5.2.1)
activesupport (= 5.2.1)
method_source
rake (>= 0.8.7)
thor (>= 0.19.0, < 2.0)
rake (12.3.1)
rdoc (6.0.4)
responders (2.4.0)
actionpack (>= 4.2.0, < 5.3)
railties (>= 4.2.0, < 5.3)
ruby-openid (2.7.0)
sprockets (3.7.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.3.13)
test_after_commit (1.1.0)
activerecord (>= 3.2)
thor (0.20.0)
thread_safe (0.3.6)
timecop (0.9.1)
tzinfo (1.2.5)
thread_safe (~> 0.1)
warden (1.2.7)
rack (>= 1.0)
webrat (0.7.3)
nokogiri (>= 1.2.0)
rack (>= 1.0)
rack-test (>= 0.5.3)
websocket-driver (0.7.0)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.3)
PLATFORMS
ruby
DEPENDENCIES
activemodel-serializers-xml!
devise!
mocha (~> 1.1)
omniauth
omniauth-facebook
omniauth-oauth2
omniauth-openid
rails (~> 5.2)
rails-controller-testing
rdoc
responders (~> 2.1)
sqlite3 (~> 1.3.6)
test_after_commit
timecop
webrat (= 0.7.3)
BUNDLED WITH
1.17.1

View File

@@ -1,216 +0,0 @@
GIT
remote: git://github.com/rails/activemodel-serializers-xml.git
revision: f744aeca2747ed3134e492249c4ee39b548efdf6
specs:
activemodel-serializers-xml (1.0.2)
activemodel (> 5.x)
activesupport (> 5.x)
builder (~> 3.1)
PATH
remote: ..
specs:
devise (4.6.2)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0, < 6.0)
responders
warden (~> 1.2.3)
GEM
remote: https://rubygems.org/
specs:
actioncable (6.0.0.beta1)
actionpack (= 6.0.0.beta1)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (6.0.0.beta1)
actionpack (= 6.0.0.beta1)
activejob (= 6.0.0.beta1)
activerecord (= 6.0.0.beta1)
activestorage (= 6.0.0.beta1)
activesupport (= 6.0.0.beta1)
mail (>= 2.7.1)
actionmailer (6.0.0.beta1)
actionpack (= 6.0.0.beta1)
actionview (= 6.0.0.beta1)
activejob (= 6.0.0.beta1)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (6.0.0.beta1)
actionview (= 6.0.0.beta1)
activesupport (= 6.0.0.beta1)
rack (~> 2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actiontext (6.0.0.beta1)
actionpack (= 6.0.0.beta1)
activerecord (= 6.0.0.beta1)
activestorage (= 6.0.0.beta1)
activesupport (= 6.0.0.beta1)
nokogiri (>= 1.8.5)
actionview (6.0.0.beta1)
activesupport (= 6.0.0.beta1)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (6.0.0.beta1)
activesupport (= 6.0.0.beta1)
globalid (>= 0.3.6)
activemodel (6.0.0.beta1)
activesupport (= 6.0.0.beta1)
activerecord (6.0.0.beta1)
activemodel (= 6.0.0.beta1)
activesupport (= 6.0.0.beta1)
activestorage (6.0.0.beta1)
actionpack (= 6.0.0.beta1)
activerecord (= 6.0.0.beta1)
marcel (~> 0.3.1)
activesupport (6.0.0.beta1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
bcrypt (3.1.12)
builder (3.2.3)
concurrent-ruby (1.1.4)
crass (1.0.4)
erubi (1.8.0)
faraday (0.15.4)
multipart-post (>= 1.2, < 3)
globalid (0.4.2)
activesupport (>= 4.2.0)
hashie (3.6.0)
i18n (1.5.2)
concurrent-ruby (~> 1.0)
jwt (2.1.0)
loofah (2.2.3)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
mini_mime (>= 0.1.1)
marcel (0.3.3)
mimemagic (~> 0.3.2)
metaclass (0.0.4)
method_source (0.9.2)
mimemagic (0.3.3)
mini_mime (1.0.1)
mini_portile2 (2.4.0)
minitest (5.11.3)
mocha (1.8.0)
metaclass (~> 0.0.1)
multi_json (1.13.1)
multi_xml (0.6.0)
multipart-post (2.0.0)
nio4r (2.3.1)
nokogiri (1.10.1)
mini_portile2 (~> 2.4.0)
oauth2 (1.4.1)
faraday (>= 0.8, < 0.16.0)
jwt (>= 1.0, < 3.0)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
omniauth (1.9.0)
hashie (>= 3.4.6, < 3.7.0)
rack (>= 1.6.2, < 3)
omniauth-facebook (5.0.0)
omniauth-oauth2 (~> 1.2)
omniauth-oauth2 (1.6.0)
oauth2 (~> 1.1)
omniauth (~> 1.9)
omniauth-openid (1.0.1)
omniauth (~> 1.0)
rack-openid (~> 1.3.1)
orm_adapter (0.5.0)
rack (2.0.6)
rack-openid (1.3.1)
rack (>= 1.1.0)
ruby-openid (>= 2.1.8)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (6.0.0.beta1)
actioncable (= 6.0.0.beta1)
actionmailbox (= 6.0.0.beta1)
actionmailer (= 6.0.0.beta1)
actionpack (= 6.0.0.beta1)
actiontext (= 6.0.0.beta1)
actionview (= 6.0.0.beta1)
activejob (= 6.0.0.beta1)
activemodel (= 6.0.0.beta1)
activerecord (= 6.0.0.beta1)
activestorage (= 6.0.0.beta1)
activesupport (= 6.0.0.beta1)
bundler (>= 1.3.0)
railties (= 6.0.0.beta1)
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.0.4)
loofah (~> 2.2, >= 2.2.2)
railties (6.0.0.beta1)
actionpack (= 6.0.0.beta1)
activesupport (= 6.0.0.beta1)
method_source
rake (>= 0.8.7)
thor (>= 0.20.3, < 2.0)
rake (12.3.2)
rdoc (6.1.1)
responders (2.4.1)
actionpack (>= 4.2.0, < 6.0)
railties (>= 4.2.0, < 6.0)
ruby-openid (2.7.0)
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.1)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.3.13)
test_after_commit (1.1.0)
activerecord (>= 3.2)
thor (0.20.3)
thread_safe (0.3.6)
timecop (0.9.1)
tzinfo (1.2.5)
thread_safe (~> 0.1)
warden (1.2.8)
rack (>= 2.0.6)
webrat (0.7.3)
nokogiri (>= 1.2.0)
rack (>= 1.0)
rack-test (>= 0.5.3)
websocket-driver (0.7.0)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.3)
PLATFORMS
ruby
DEPENDENCIES
activemodel-serializers-xml!
devise!
mocha (~> 1.1)
omniauth
omniauth-facebook
omniauth-oauth2
omniauth-openid
rails (= 6.0.0.beta1)
rails-controller-testing
rdoc
responders (~> 2.4)
sqlite3 (~> 1.3.6)
test_after_commit
timecop
webrat (= 0.7.3)
BUNDLED WITH
1.17.1

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

@@ -13,16 +13,16 @@ module Devise
autoload :Encryptor, 'devise/encryptor'
autoload :FailureApp, 'devise/failure_app'
autoload :OmniAuth, 'devise/omniauth'
autoload :Orm, 'devise/orm'
autoload :ParameterFilter, 'devise/parameter_filter'
autoload :ParameterSanitizer, 'devise/parameter_sanitizer'
autoload :TestHelpers, 'devise/test_helpers'
autoload :TimeInflector, 'devise/time_inflector'
autoload :TokenGenerator, 'devise/token_generator'
autoload :SecretKeyFinder, 'devise/secret_key_finder'
module Controllers
autoload :Helpers, 'devise/controllers/helpers'
autoload :Rememberable, 'devise/controllers/rememberable'
autoload :Responder, 'devise/controllers/responder'
autoload :ScopedViews, 'devise/controllers/scoped_views'
autoload :SignInOut, 'devise/controllers/sign_in_out'
autoload :StoreLocation, 'devise/controllers/store_location'
@@ -59,7 +59,7 @@ module Devise
NO_INPUT = []
# True values used to check params
TRUE_VALUES = [true, 1, '1', 't', 'T', 'true', 'TRUE']
TRUE_VALUES = [true, 1, '1', 'on', 'ON', 't', 'T', 'true', 'TRUE']
# Secret key used by the key generator
mattr_accessor :secret_key
@@ -71,7 +71,7 @@ module Devise
# The number of times to hash the password.
mattr_accessor :stretches
@@stretches = 11
@@stretches = 12
# The default key used when authenticating over http auth.
mattr_accessor :http_authentication_key
@@ -217,7 +217,16 @@ module Devise
# Which formats should be treated as navigational.
mattr_accessor :navigational_formats
@@navigational_formats = ["*/*", :html]
@@navigational_formats = ["*/*", :html, :turbo_stream]
# The default responder used by Devise, used to customize status codes with:
#
# `config.responder.error_status`
# `config.responder.redirect_status`
#
# Can be replaced by a custom application responder.
mattr_accessor :responder
@@responder = Devise::Controllers::Responder
# When set to true, signing out a user signs out all other scopes.
mattr_accessor :sign_out_all_scopes
@@ -264,8 +273,14 @@ module Devise
# PRIVATE CONFIGURATION
# Store scopes mappings.
mattr_reader :mappings
@@mappings = {}
def self.mappings
# Starting from Rails 8.0, routes are lazy-loaded by default in test and development environments.
# However, Devise's mappings are built during the routes loading phase.
# To ensure it works correctly, we need to load the routes first before accessing @@mappings.
Rails.application.try(:reload_routes_unless_loaded)
@@mappings
end
# OmniAuth configurations.
mattr_reader :omniauth_configs
@@ -297,14 +312,6 @@ module Devise
mattr_accessor :sign_in_after_change_password
@@sign_in_after_change_password = true
def self.rails51? # :nodoc:
Rails.gem_version >= Gem::Version.new("5.1.x")
end
def self.activerecord51? # :nodoc:
defined?(ActiveRecord) && ActiveRecord.gem_version >= Gem::Version.new("5.1.x")
end
# Default way to set up Devise. Run rails generate devise_install to create
# a fresh initializer with all configuration values.
def self.setup
@@ -317,12 +324,20 @@ module Devise
end
def get
ActiveSupport::Dependencies.constantize(@name)
# TODO: Remove AS::Dependencies usage when dropping support to Rails < 7.
if ActiveSupport::Dependencies.respond_to?(:constantize)
ActiveSupport::Dependencies.constantize(@name)
else
@name.constantize
end
end
end
def self.ref(arg)
ActiveSupport::Dependencies.reference(arg)
# TODO: Remove AS::Dependencies usage when dropping support to Rails < 7.
if ActiveSupport::Dependencies.respond_to?(:reference)
ActiveSupport::Dependencies.reference(arg)
end
Getter.new(arg)
end
@@ -430,9 +445,9 @@ module Devise
# Devise.setup do |config|
# config.allow_unconfirmed_access_for = 2.days
#
# config.warden do |manager|
# config.warden do |warden_config|
# # Configure warden to use other strategies, like oauth.
# manager.oauth(:twitter)
# warden_config.oauth(:twitter)
# end
# end
def self.warden(&block)
@@ -502,12 +517,12 @@ module Devise
# constant-time comparison algorithm to prevent timing attacks
def self.secure_compare(a, b)
return false if a.blank? || b.blank? || a.bytesize != b.bytesize
l = a.unpack "C#{a.bytesize}"
return false if a.nil? || b.nil?
ActiveSupport::SecurityUtils.secure_compare(a, b)
end
res = 0
b.each_byte { |byte| res |= byte ^ l.shift }
res == 0
def self.deprecator
@deprecator ||= ActiveSupport::Deprecation.new("5.0", "Devise")
end
end

View File

@@ -36,16 +36,17 @@ 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
opts[:locale] = I18n.locale
warden.authenticate!(opts) if !devise_controller? || opts.delete(:force)
end
end
@@ -57,9 +58,9 @@ module Devise
end
end
def current_#{group_name}(favourite=nil)
def current_#{group_name}(favorite = nil)
mappings = #{mappings}
mappings.unshift mappings.delete(favourite.to_sym) if favourite
mappings.unshift mappings.delete(favorite.to_sym) if favorite
mappings.each do |mapping|
current = warden.authenticate(scope: mapping)
return current if current
@@ -113,8 +114,9 @@ module Devise
mapping = mapping.name
class_eval <<-METHODS, __FILE__, __LINE__ + 1
def authenticate_#{mapping}!(opts={})
def authenticate_#{mapping}!(opts = {})
opts[:scope] = :#{mapping}
opts[:locale] = I18n.locale
warden.authenticate!(opts) if !devise_controller? || opts.delete(:force)
end
@@ -252,7 +254,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

View File

@@ -0,0 +1,35 @@
# frozen_string_literal: true
module Devise
module Controllers
# Custom Responder to configure default statuses that only apply to Devise,
# and allow to integrate more easily with Hotwire/Turbo.
class Responder < ActionController::Responder
if respond_to?(:error_status=) && respond_to?(:redirect_status=)
self.error_status = :ok
self.redirect_status = :found
else
# TODO: remove this support for older Rails versions, which aren't supported by Turbo
# and/or responders. It won't allow configuring a custom response, but it allows Devise
# to use these methods and defaults across the implementation more easily.
def self.error_status
:ok
end
def self.redirect_status
:found
end
def self.error_status=(*)
warn "[DEVISE] Setting the error status on the Devise responder has no effect with this " \
"version of `responders`, please make sure you're using a newer version. Check the changelog for more info."
end
def self.redirect_status=(*)
warn "[DEVISE] Setting the redirect status on the Devise responder has no effect with this " \
"version of `responders`, please make sure you're using a newer version. Check the changelog for more info."
end
end
end
end
end

View File

@@ -10,7 +10,7 @@ module Devise
# cause exceptions to be thrown from this method; if you simply want to check
# if a scope has already previously been authenticated without running
# authentication hooks, you can directly call `warden.authenticated?(scope: scope)`
def signed_in?(scope=nil)
def signed_in?(scope = nil)
[scope || Devise.mappings.keys].flatten.any? do |_scope|
warden.authenticate?(scope: _scope)
end
@@ -21,7 +21,7 @@ module Devise
# to the set_user method in warden.
# If you are using a custom warden strategy and the timeoutable module, you have to
# set `env["devise.skip_timeout"] = true` in the request to use this method, like we do
# in the sessions controller: https://github.com/plataformatec/devise/blob/master/app/controllers/devise/sessions_controller.rb#L7
# in the sessions controller: https://github.com/heartcombo/devise/blob/main/app/controllers/devise/sessions_controller.rb#L7
#
# Examples:
#
@@ -37,16 +37,7 @@ module Devise
expire_data_after_sign_in!
if options[:bypass]
ActiveSupport::Deprecation.warn(<<-DEPRECATION.strip_heredoc, caller)
[Devise] bypass option is deprecated and it will be removed in future version of Devise.
Please use bypass_sign_in method instead.
Example:
bypass_sign_in(user)
DEPRECATION
warden.session_serializer.store(resource, scope)
elsif warden.user(scope) == resource && !options.delete(:force)
if warden.user(scope) == resource && !options.delete(:force)
# Do nothing. User already signed in and we are not forcing it.
true
else
@@ -77,7 +68,7 @@ module Devise
# sign_out :user # sign_out(scope)
# sign_out @user # sign_out(resource)
#
def sign_out(resource_or_scope=nil)
def sign_out(resource_or_scope = nil)
return sign_out_all_scopes unless resource_or_scope
scope = Devise::Mapping.find_scope!(resource_or_scope)
user = warden.user(scope: scope, run_callbacks: false) # If there is no user
@@ -92,7 +83,7 @@ module Devise
# Sign out all active users or scopes. This helper is useful for signing out all roles
# in one click. This signs out ALL scopes in warden. Returns true if there was at least one logout
# and false if there was no user logged in on all scopes.
def sign_out_all_scopes(lock=true)
def sign_out_all_scopes(lock = true)
users = Devise.mappings.keys.map { |s| warden.user(scope: s, run_callbacks: false) }
warden.logout
@@ -106,10 +97,6 @@ module Devise
private
def expire_data_after_sign_in!
# session.keys will return an empty array if the session is not yet loaded.
# This is a bug in both Rack and Rails.
# A call to #empty? forces the session to be loaded.
session.empty?
session.keys.grep(/^devise\./).each { |k| session.delete(k) }
end

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

@@ -18,6 +18,11 @@ module Devise
delegate :flash, to: :request
include AbstractController::Callbacks
around_action do |failure_app, action|
I18n.with_locale(failure_app.i18n_locale, &action)
end
def self.call(env)
@respond ||= action(:respond)
@respond.call(env)
@@ -71,8 +76,11 @@ module Devise
end
flash.now[:alert] = i18n_message(:invalid) if is_flashing_format?
# self.response = recall_app(warden_options[:recall]).call(env)
self.response = recall_app(warden_options[:recall]).call(request.env)
self.response = recall_app(warden_options[:recall]).call(request.env).tap { |response|
status = response[0].in?(300..399) ? Devise.responder.redirect_status : Devise.responder.error_status
# Avoid warnings translating status to code using Rails if available (e.g. `unprocessable_entity` => `unprocessable_content`)
response[0] = ActionDispatch::Response.try(:rack_status_code, status) || Rack::Utils.status_code(status)
}
end
def redirect
@@ -103,16 +111,25 @@ module Devise
options[:scope] = "devise.failure"
options[:default] = [message]
auth_keys = scope_class.authentication_keys
keys = (auth_keys.respond_to?(:keys) ? auth_keys.keys : auth_keys).map { |key| scope_class.human_attribute_name(key) }
options[:authentication_keys] = keys.join(I18n.translate(:"support.array.words_connector"))
human_keys = (auth_keys.respond_to?(:keys) ? auth_keys.keys : auth_keys).map { |key|
scope_class.human_attribute_name(key).downcase
}
options[:authentication_keys] = human_keys.join(I18n.t(:"support.array.words_connector"))
options = i18n_options(options)
I18n.t(:"#{scope}.#{message}", options)
I18n.t(:"#{scope}.#{message}", **options).then { |msg|
# Ensure that auth keys at the start of the translated string are properly cased.
msg.start_with?(human_keys.first) ? msg.upcase_first : msg
}
else
message.to_s
end
end
def i18n_locale
warden_options[:locale]
end
def redirect_url
if warden_message == :timeout
flash[:timedout] = true if is_flashing_format?
@@ -137,7 +154,7 @@ module Devise
opts = {}
# Initialize script_name with nil to prevent infinite loops in
# authenticated mounted engines in rails 4.2 and 5.0
# authenticated mounted engines
opts[:script_name] = nil
route = route(scope)
@@ -149,13 +166,6 @@ module Devise
if relative_url_root?
opts[:script_name] = relative_url_root
# We need to add the rootpath to `script_name` manually for applications that use a Rails
# version lower than 5.1. Otherwise, it is going to generate a wrong path for Engines
# that use Devise. Remove it when the support of Rails 5.0 is droped.
elsif root_path_defined?(context) && rails_5_and_down?
rootpath = context.routes.url_helpers.root_path
opts[:script_name] = rootpath.chomp('/') if rootpath.length > 1
end
if context.respond_to?(route)
@@ -168,7 +178,7 @@ module Devise
end
def skip_format?
%w(html */*).include? request_format.to_s
%w(html */* turbo_stream).include? request_format.to_s
end
# Choose whether we should respond in an HTTP authentication fashion,
@@ -271,21 +281,5 @@ module Devise
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_5_and_down?
return false if rails_5_up?
Rails::VERSION::MAJOR >= 4
end
def rails_5_up?
Rails::VERSION::MAJOR >= 5 && Rails::VERSION::MINOR > 0
end
end
end

View File

@@ -7,6 +7,6 @@ Warden::Manager.after_set_user do |record, warden, options|
if record && record.respond_to?(:active_for_authentication?) && !record.active_for_authentication?
scope = options[:scope]
warden.logout(scope)
throw :warden, scope: scope, message: record.inactive_message
throw :warden, scope: scope, message: record.inactive_message, locale: options.fetch(:locale, I18n.locale)
end
end

View File

@@ -4,6 +4,11 @@ Warden::Manager.after_authentication do |record, warden, options|
clean_up_for_winning_strategy = !warden.winning_strategy.respond_to?(:clean_up_csrf?) ||
warden.winning_strategy.clean_up_csrf?
if Devise.clean_up_csrf_token_on_authentication && clean_up_for_winning_strategy
warden.request.session.try(:delete, :_csrf_token)
if warden.request.respond_to?(:reset_csrf_token)
# Rails 7.1+
warden.request.reset_csrf_token
else
warden.request.session.try(:delete, :_csrf_token)
end
end
end

View File

@@ -3,10 +3,7 @@
# After each sign in, if resource responds to failed_attempts, sets it to 0
# This is only triggered when the user is explicitly set (with set_user)
Warden::Manager.after_set_user except: :fetch do |record, warden, options|
if record.respond_to?(:failed_attempts) && warden.authenticated?(options[:scope])
unless record.failed_attempts.to_i.zero?
record.failed_attempts = 0
record.save(validate: false)
end
if record.respond_to?(:reset_failed_attempts!) && warden.authenticated?(options[:scope])
record.reset_failed_attempts!
end
end

View File

@@ -21,11 +21,11 @@ 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
throw :warden, scope: scope, message: :timeout, locale: options.fetch(:locale, I18n.locale)
end
unless env['devise.skip_trackable']

View File

@@ -33,28 +33,22 @@ module Devise
subject: subject_for(action),
to: resource.email,
from: mailer_sender(devise_mapping),
reply_to: mailer_reply_to(devise_mapping),
reply_to: mailer_sender(devise_mapping),
template_path: template_paths,
template_name: action
}.merge(opts)
}
# Give priority to the mailer's default if they exists.
headers.delete(:from) if default_params[:from]
headers.delete(:reply_to) if default_params[:reply_to]
headers.merge!(opts)
@email = headers[:to]
headers
end
def mailer_reply_to(mapping)
mailer_sender(mapping, :reply_to)
end
def mailer_from(mapping)
mailer_sender(mapping, :from)
end
def mailer_sender(mapping, sender = :from)
default_sender = default_params[sender]
if default_sender.present?
default_sender.respond_to?(:to_proc) ? instance_eval(&default_sender) : default_sender
elsif Devise.mailer_sender.is_a?(Proc)
def mailer_sender(mapping)
if Devise.mailer_sender.is_a?(Proc)
Devise.mailer_sender.call(mapping.name)
else
Devise.mailer_sender

View File

@@ -30,7 +30,7 @@ module Devise
alias :name :singular
# Receives an object and find a scope for it. If a scope cannot be found,
# Receives an object and finds a scope for it. If a scope cannot be found,
# raises an error. If a symbol is given, it's considered to be the scope.
def self.find_scope!(obj)
obj = obj.devise_scope if obj.respond_to?(:devise_scope)
@@ -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

@@ -84,6 +84,7 @@ module Devise
end
devise_modules_hook! do
include Devise::Orm
include Devise::Models::Authenticatable
selected_modules.each do |m|

View File

@@ -1,6 +1,5 @@
# frozen_string_literal: true
require 'active_model/version'
require 'devise/hooks/activatable'
require 'devise/hooks/csrf_cleaner'
@@ -10,7 +9,7 @@ module Devise
#
# == Options
#
# Authenticatable adds the following options to devise_for:
# Authenticatable adds the following options to +devise+:
#
# * +authentication_keys+: parameters used for authentication. By default [:email].
#
@@ -56,7 +55,7 @@ module Devise
module Authenticatable
extend ActiveSupport::Concern
BLACKLIST_FOR_SERIALIZATION = [:encrypted_password, :reset_password_token, :reset_password_sent_at,
UNSAFE_ATTRIBUTES_FOR_SERIALIZATION = [:encrypted_password, :reset_password_token, :reset_password_sent_at,
:remember_created_at, :sign_in_count, :current_sign_in_at, :last_sign_in_at, :current_sign_in_ip,
:last_sign_in_ip, :password_salt, :confirmation_token, :confirmed_at, :confirmation_sent_at,
:remember_token, :unconfirmed_email, :failed_attempts, :unlock_token, :locked_at]
@@ -105,12 +104,12 @@ module Devise
# given to :except will simply add names to exempt to Devise internal list.
def serializable_hash(options = nil)
options = options.try(:dup) || {}
options[:except] = Array(options[:except])
options[:except] = Array(options[:except]).dup
if options[:force_except]
options[:except].concat Array(options[:force_except])
else
options[:except].concat BLACKLIST_FOR_SERIALIZATION
options[:except].concat UNSAFE_ATTRIBUTES_FOR_SERIALIZATION
end
super(options)
@@ -153,7 +152,8 @@ 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?
# # For Rails < 6 use `changed?` instead of `saved_changes?`.
# if new_record? || saved_changes?
# pending_devise_notifications << [notification, args]
# else
# render_and_send_devise_message(notification, *args)
@@ -183,11 +183,8 @@ module Devise
# # 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
# message.deliver_now
# end
# end
#
@@ -195,12 +192,7 @@ module Devise
#
def send_devise_notification(notification, *args)
message = devise_mailer.send(notification, self, *args)
# Remove once we move to Rails 4.2+ only.
if message.respond_to?(:deliver_now)
message.deliver_now
else
message.deliver
end
message.deliver_now
end
def downcase_keys
@@ -272,17 +264,17 @@ module Devise
find_first_by_auth_conditions(tainted_conditions)
end
def find_first_by_auth_conditions(tainted_conditions, opts={})
def find_first_by_auth_conditions(tainted_conditions, opts = {})
to_adapter.find_first(devise_parameter_filter.filter(tainted_conditions).merge(opts))
end
# Find or initialize a record setting an error if it can't be found.
def find_or_initialize_with_error_by(attribute, value, error=:invalid) #:nodoc:
def find_or_initialize_with_error_by(attribute, value, error = :invalid) #:nodoc:
find_or_initialize_with_errors([attribute], { attribute => value }, error)
end
# Find or initialize a record with group of attributes based on a list of required attributes.
def find_or_initialize_with_errors(required_attributes, attributes, error=:invalid) #:nodoc:
def find_or_initialize_with_errors(required_attributes, attributes, error = :invalid) #:nodoc:
attributes.try(:permit!)
attributes = attributes.to_h.with_indifferent_access
.slice(*required_attributes)

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 < ActiveRecord::Base # ActiveRecord
if Devise::Orm.active_record?(self) # ActiveRecord
after_commit :send_on_create_confirmation_instructions, on: :create, if: :send_confirmation_notification?
after_commit :send_reconfirmation_instructions, on: :update, if: :reconfirmation_required?
else # Mongoid
@@ -76,7 +76,7 @@ module Devise
# Confirm a user by setting it's confirmed_at to actual time. If the user
# is already confirmed, add an error to email field. If the user is invalid
# add errors
def confirm(args={})
def confirm(args = {})
pending_any_confirmation do
if confirmation_period_expired?
self.errors.add(:email, :confirmation_period_expired,
@@ -258,44 +258,23 @@ module Devise
generate_confirmation_token && save(validate: false)
end
if Devise.activerecord51?
def postpone_email_change_until_confirmation_and_regenerate_confirmation_token
@reconfirmation_required = true
self.unconfirmed_email = self.email
self.email = self.email_in_database
self.confirmation_token = nil
generate_confirmation_token
end
else
def postpone_email_change_until_confirmation_and_regenerate_confirmation_token
@reconfirmation_required = true
self.unconfirmed_email = self.email
self.email = self.email_was
self.confirmation_token = nil
generate_confirmation_token
end
def postpone_email_change_until_confirmation_and_regenerate_confirmation_token
@reconfirmation_required = true
self.unconfirmed_email = self.email
self.email = self.devise_email_in_database
self.confirmation_token = nil
generate_confirmation_token
end
if Devise.activerecord51?
def postpone_email_change?
postpone = self.class.reconfirmable &&
will_save_change_to_email? &&
!@bypass_confirmation_postpone &&
self.email.present? &&
(!@skip_reconfirmation_in_callback || !self.email_in_database.nil?)
@bypass_confirmation_postpone = false
postpone
end
else
def postpone_email_change?
postpone = self.class.reconfirmable &&
email_changed? &&
!@bypass_confirmation_postpone &&
self.email.present? &&
(!@skip_reconfirmation_in_callback || !self.email_was.nil?)
@bypass_confirmation_postpone = false
postpone
end
def postpone_email_change?
postpone = self.class.reconfirmable &&
devise_will_save_change_to_email? &&
!@bypass_confirmation_postpone &&
self.email.present? &&
(!@skip_reconfirmation_in_callback || !self.devise_email_in_database.nil?)
@bypass_confirmation_postpone = false
postpone
end
def reconfirmation_required?
@@ -334,7 +313,7 @@ module Devise
# confirmation instructions to it. If not, try searching for a user by unconfirmed_email
# field. If no user is found, returns a new user with an email not found error.
# Options must contain the user email
def send_confirmation_instructions(attributes={})
def send_confirmation_instructions(attributes = {})
confirmable = find_by_unconfirmed_email_with_errors(attributes) if reconfirmable
unless confirmable.try(:persisted?)
confirmable = find_or_initialize_with_errors(confirmation_keys, attributes, :not_found)
@@ -348,7 +327,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,9 +7,13 @@ 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:
# DatabaseAuthenticatable adds the following options to +devise+:
#
# * +pepper+: a random string used to provide a more secure hash. Use
# `rails secret` to generate new keys.
@@ -38,7 +42,7 @@ module Devise
def initialize(*args, &block)
@skip_email_changed_notification = false
@skip_password_change_notification = false
super
super
end
# Skips sending the email changed notification after_update
@@ -80,16 +84,7 @@ module Devise
# users to change relevant information like the e-mail without changing
# their password). In case the password field is rejected, the confirmation
# is also rejected as long as it is also blank.
def update_with_password(params, *options)
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
def update_with_password(params)
current_password = params.delete(:current_password)
if params[:password].blank?
@@ -98,9 +93,9 @@ module Devise
end
result = if valid_password?(current_password)
update(params, *options)
update(params)
else
assign_attributes(params, *options)
assign_attributes(params)
valid?
errors.add(:current_password, current_password.blank? ? :blank : :invalid)
false
@@ -117,25 +112,16 @@ module Devise
#
# Example:
#
# def update_without_password(params, *options)
# def update_without_password(params)
# params.delete(:email)
# super(params)
# 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
def update_without_password(params)
params.delete(:password)
params.delete(:password_confirmation)
result = update(params, *options)
result = update(params)
clean_up_passwords
result
end
@@ -173,16 +159,9 @@ module Devise
encrypted_password[0,29] if encrypted_password
end
if Devise.activerecord51?
# Send notification to user when email changes.
def send_email_changed_notification
send_devise_notification(:email_changed, to: email_before_last_save)
end
else
# Send notification to user when email changes.
def send_email_changed_notification
send_devise_notification(:email_changed, to: email_was)
end
# Send notification to user when email changes.
def send_email_changed_notification
send_devise_notification(:email_changed, to: devise_email_before_last_save)
end
# Send notification to user when password changes.
@@ -195,30 +174,18 @@ 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)
end
if Devise.activerecord51?
def send_email_changed_notification?
self.class.send_email_changed_notification && saved_change_to_email? && !@skip_email_changed_notification
end
else
def send_email_changed_notification?
self.class.send_email_changed_notification && email_changed? && !@skip_email_changed_notification
end
def send_email_changed_notification?
self.class.send_email_changed_notification && devise_saved_change_to_email? && !@skip_email_changed_notification
end
if Devise.activerecord51?
def send_password_change_notification?
self.class.send_password_change_notification && saved_change_to_encrypted_password? && !@skip_password_change_notification
end
else
def send_password_change_notification?
self.class.send_password_change_notification && encrypted_password_changed? && !@skip_password_change_notification
end
def send_password_change_notification?
self.class.send_password_change_notification && devise_saved_change_to_encrypted_password? && !@skip_password_change_notification
end
module ClassMethods

View File

@@ -18,7 +18,7 @@ module Devise
# * +maximum_attempts+: how many attempts should be accepted before blocking the user.
# * +lock_strategy+: lock the user account by :failed_attempts or :none.
# * +unlock_strategy+: unlock the user account by :time, :email, :both or :none.
# * +unlock_in+: the time you want to lock the user after to lock happens. Only available when unlock_strategy is :time or :both.
# * +unlock_in+: the time you want to unlock the user after lock happens. Only available when unlock_strategy is :time or :both.
# * +unlock_keys+: the keys you want to use when locking and unlocking an account
#
module Lockable
@@ -57,6 +57,14 @@ module Devise
save(validate: false)
end
# Resets failed attempts counter to 0.
def reset_failed_attempts!
if respond_to?(:failed_attempts) && !failed_attempts.to_i.zero?
self.failed_attempts = 0
save(validate: false)
end
end
# Verifies whether a user is locked or not.
def access_locked?
!!locked_at && !lock_expired?
@@ -76,7 +84,7 @@ module Devise
if_access_locked { send_unlock_instructions }
end
# Overwrites active_for_authentication? from Devise::Models::Activatable for locking purposes
# Overwrites active_for_authentication? from Devise::Models::Authenticatable for locking purposes
# by verifying whether a user is active to sign in or not based on locked?
def active_for_authentication?
super && !access_locked?
@@ -110,7 +118,7 @@ module Devise
false
end
end
def increment_failed_attempts
self.class.increment_counter(:failed_attempts, id)
reload
@@ -168,7 +176,7 @@ module Devise
# unlock instructions to it. If not user is found, returns a new user
# with an email not found error.
# Options must contain the user's unlock keys
def send_unlock_instructions(attributes={})
def send_unlock_instructions(attributes = {})
lockable = find_or_initialize_with_errors(unlock_keys, attributes, :not_found)
lockable.resend_unlock_instructions if lockable.persisted?
lockable

View File

@@ -8,11 +8,11 @@ module Devise
#
# == Options
#
# Oauthable adds the following options to devise_for:
# Oauthable adds the following options to +devise+:
#
# * +omniauth_providers+: Which providers are available to this model. It expects an array:
#
# devise_for :database_authenticatable, :omniauthable, omniauth_providers: [:twitter]
# devise :database_authenticatable, :omniauthable, omniauth_providers: [:twitter]
#
module Omniauthable
extend ActiveSupport::Concern

View File

@@ -7,7 +7,7 @@ module Devise
#
# ==Options
#
# Recoverable adds the following options to devise_for:
# Recoverable adds the following options to +devise+:
#
# * +reset_password_keys+: the keys you want to use when recovering the password for an account
# * +reset_password_within+: the time period within which the password must be reset or the token expires.
@@ -99,24 +99,13 @@ module Devise
send_devise_notification(:reset_password_instructions, token, {})
end
if Devise.activerecord51?
def clear_reset_password_token?
encrypted_password_changed = respond_to?(:will_save_change_to_encrypted_password?) && will_save_change_to_encrypted_password?
authentication_keys_changed = self.class.authentication_keys.any? do |attribute|
respond_to?("will_save_change_to_#{attribute}?") && send("will_save_change_to_#{attribute}?")
end
authentication_keys_changed || encrypted_password_changed
def clear_reset_password_token?
encrypted_password_changed = devise_respond_to_and_will_save_change_to_attribute?(:encrypted_password)
authentication_keys_changed = self.class.authentication_keys.any? do |attribute|
devise_respond_to_and_will_save_change_to_attribute?(attribute)
end
else
def clear_reset_password_token?
encrypted_password_changed = respond_to?(:encrypted_password_changed?) && encrypted_password_changed?
authentication_keys_changed = self.class.authentication_keys.any? do |attribute|
respond_to?("#{attribute}_changed?") && send("#{attribute}_changed?")
end
authentication_keys_changed || encrypted_password_changed
end
authentication_keys_changed || encrypted_password_changed
end
module ClassMethods
@@ -131,7 +120,7 @@ module Devise
# password instructions to it. If user is not found, returns a new user
# with an email not found error.
# Attributes must contain the user's email
def send_reset_password_instructions(attributes={})
def send_reset_password_instructions(attributes = {})
recoverable = find_or_initialize_with_errors(reset_password_keys, attributes, :not_found)
recoverable.send_reset_password_instructions if recoverable.persisted?
recoverable
@@ -142,7 +131,7 @@ module Devise
# try saving the record. If not user is found, returns a new user
# containing an error in reset_password_token attribute.
# Attributes must contain reset_password_token, password and confirmation
def reset_password_by_token(attributes={})
def reset_password_by_token(attributes = {})
original_token = attributes[:reset_password_token]
reset_password_token = Devise.token_generator.digest(self, :reset_password_token, original_token)

View File

@@ -15,7 +15,7 @@ module Devise
#
# == Options
#
# Rememberable adds the following options in devise_for:
# Rememberable adds the following options to +devise+:
#
# * +remember_for+: the time you want the user will be remembered without
# asking for credentials. After this time the user will be blocked and
@@ -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

@@ -11,7 +11,7 @@ module Devise
#
# == Options
#
# Timeoutable adds the following options to devise_for:
# Timeoutable adds the following options to +devise+:
#
# * +timeout_in+: the interval to timeout the user session without activity.
#

View File

@@ -33,7 +33,7 @@ module Devise
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/plataformatec/devise/issues/4673 for more details.
# See https://github.com/heartcombo/devise/issues/4673 for more details.
return if new_record?
update_tracked_fields(request)

View File

@@ -9,11 +9,13 @@ module Devise
#
# == Options
#
# Validatable adds the following options to devise_for:
# Validatable adds the following options to +devise+:
#
# * +email_regexp+: the regular expression used to validate e-mails;
# * +password_length+: a range expressing password length. Defaults to 6..128.
#
# Since +password_length+ is applied in a proc within `validates_length_of` it can be overridden
# at runtime.
module Validatable
# All validations used by this module.
VALIDATIONS = [:validates_presence_of, :validates_uniqueness_of, :validates_format_of,
@@ -29,17 +31,12 @@ 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_format_of :email, with: email_regexp, allow_blank: true, if: :will_save_change_to_email?
else
validates_uniqueness_of :email, allow_blank: true, if: :email_changed?
validates_format_of :email, with: email_regexp, allow_blank: true, if: :email_changed?
end
validates_uniqueness_of :email, allow_blank: true, case_sensitive: true, if: :devise_will_save_change_to_email?
validates_format_of :email, with: email_regexp, allow_blank: true, if: :devise_will_save_change_to_email?
validates_presence_of :password, if: :password_required?
validates_confirmation_of :password, if: :password_required?
validates_length_of :password, within: password_length, allow_blank: true
validates_length_of :password, minimum: proc { password_length.min }, maximum: proc { password_length.max }, allow_blank: true
end
end
@@ -47,7 +44,7 @@ module Devise
unavailable_validations = VALIDATIONS.select { |v| !base.respond_to?(v) }
unless unavailable_validations.empty?
raise "Could not use :validatable module since #{base} does not respond " <<
raise "Could not use :validatable module since #{base} does not respond " \
"to the following methods: #{unavailable_validations.to_sentence}."
end
end

View File

@@ -1,17 +1,14 @@
# frozen_string_literal: true
begin
gem "omniauth", ">= 1.0.0"
require "omniauth"
require "omniauth/version"
rescue LoadError
warn "Could not load 'omniauth'. Please ensure you have the omniauth gem >= 1.0.0 installed and listed in your Gemfile."
raise
end
unless OmniAuth::VERSION =~ /^1\./
raise "You are using an old OmniAuth version, please ensure you have 1.0.0.pr2 version or later installed."
end
# Clean up the default path_prefix. It will be automatically set by Devise.
OmniAuth.config.path_prefix = nil

69
lib/devise/orm.rb Normal file
View File

@@ -0,0 +1,69 @@
# frozen_string_literal: true
module Devise
module Orm # :nodoc:
def self.active_record?(model)
defined?(ActiveRecord) && model < ActiveRecord::Base
end
def self.included(model)
if Devise::Orm.active_record?(model)
model.include DirtyTrackingActiveRecordMethods
else
model.include DirtyTrackingMongoidMethods
end
end
module DirtyTrackingActiveRecordMethods
def devise_email_before_last_save
email_before_last_save
end
def devise_email_in_database
email_in_database
end
def devise_saved_change_to_email?
saved_change_to_email?
end
def devise_saved_change_to_encrypted_password?
saved_change_to_encrypted_password?
end
def devise_will_save_change_to_email?
will_save_change_to_email?
end
def devise_respond_to_and_will_save_change_to_attribute?(attribute)
respond_to?("will_save_change_to_#{attribute}?") && send("will_save_change_to_#{attribute}?")
end
end
module DirtyTrackingMongoidMethods
def devise_email_before_last_save
respond_to?(:email_previously_was) ? email_previously_was : email_was
end
def devise_email_in_database
email_was
end
def devise_saved_change_to_email?
respond_to?(:email_previously_changed?) ? email_previously_changed? : email_changed?
end
def devise_saved_change_to_encrypted_password?
respond_to?(:encrypted_password_previously_changed?) ? encrypted_password_previously_changed? : encrypted_password_changed?
end
def devise_will_save_change_to_email?
email_changed?
end
def devise_respond_to_and_will_save_change_to_attribute?(attribute)
respond_to?("#{attribute}_changed?") && send("#{attribute}_changed?")
end
end
end
end

View File

@@ -130,8 +130,7 @@ module Devise
#
# Returns an +ActiveSupport::HashWithIndifferentAccess+.
def cast_to_hash(params)
# TODO: Remove the `with_indifferent_access` method call when we only support Rails 5+.
params && params.to_h.with_indifferent_access
params && params.to_h
end
def default_params

View File

@@ -17,6 +17,10 @@ module Devise
app.reload_routes! if Devise.reload_routes
end
initializer "devise.deprecator" do |app|
app.deprecators[:devise] = Devise.deprecator if app.respond_to?(:deprecators)
end
initializer "devise.url_helpers" do
Devise.include_helpers(Devise::Controllers)
end
@@ -34,7 +38,7 @@ module Devise
end
initializer "devise.secret_key" do |app|
Devise.secret_key ||= Devise::SecretKeyFinder.new(app).find
Devise.secret_key ||= app.secret_key_base
Devise.token_generator ||=
if secret_key = Devise.secret_key
@@ -43,5 +47,11 @@ module Devise
)
end
end
initializer "devise.configure_zeitwerk" do
if Rails.autoloaders.zeitwerk_enabled? && !defined?(ActionMailer)
Rails.autoloaders.main.ignore("#{root}/app/mailers/devise/mailer.rb")
end
end
end
end

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.
#
@@ -235,7 +235,6 @@ module ActionDispatch::Routing
options[:constraints] = (@scope[:constraints] || {}).merge(options[:constraints] || {})
options[:defaults] = (@scope[:defaults] || {}).merge(options[:defaults] || {})
options[:options] = @scope[:options] || {}
options[:options][:format] = false if options[:format] == false
resources.map!(&:to_sym)
@@ -287,7 +286,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 +310,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 +327,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
@@ -413,7 +412,7 @@ module ActionDispatch::Routing
controller: controllers[:registrations]
}
resource :registration, options do
resource :registration, **options do
get :cancel
end
end
@@ -447,7 +446,7 @@ ERROR
match "#{path_prefix}/#{provider}",
to: "#{controllers[:omniauth_callbacks]}#passthru",
as: "#{provider}_omniauth_authorize",
via: [:get, :post]
via: OmniAuth.config.allowed_request_methods
match "#{path_prefix}/#{provider}/callback",
to: "#{controllers[:omniauth_callbacks]}##{provider}",
@@ -462,7 +461,7 @@ ERROR
current_scope = @scope.dup
exclusive = { as: new_as, path: new_path, module: nil }
exclusive.merge!(options.slice(:constraints, :defaults, :options))
exclusive.merge!(options.slice(:constraints, :format, :defaults, :options))
if @scope.respond_to? :new
@scope = @scope.new exclusive
@@ -474,7 +473,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

@@ -1,27 +0,0 @@
# 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

@@ -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
@@ -62,17 +64,7 @@ module Devise
#
# sign_in users(:alice)
# sign_in users(:alice), scope: :admin
def sign_in(resource, deprecated = nil, scope: nil)
if deprecated.present?
scope = resource
resource = deprecated
ActiveSupport::Deprecation.warn <<-DEPRECATION.strip_heredoc
[Devise] sign_in(:#{scope}, resource) on controller tests is deprecated and will be removed from Devise.
Please use sign_in(resource, scope: :#{scope}) instead.
DEPRECATION
end
def sign_in(resource, scope: nil)
scope ||= Devise::Mapping.find_scope!(resource)
warden.instance_variable_get(:@users).delete(scope)
@@ -139,9 +131,8 @@ 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,15 +0,0 @@
# frozen_string_literal: true
module Devise
module TestHelpers
def self.included(base)
base.class_eval do
ActiveSupport::Deprecation.warn <<-DEPRECATION.strip_heredoc
[Devise] including `Devise::TestHelpers` is deprecated and will be removed from Devise.
For controller tests, please include `Devise::Test::ControllerHelpers` instead.
DEPRECATION
include Devise::Test::ControllerHelpers
end
end
end
end

View File

@@ -1,5 +1,5 @@
# frozen_string_literal: true
module Devise
VERSION = "4.6.2".freeze
VERSION = "5.0.0.rc".freeze
end

View File

@@ -5,7 +5,7 @@ require 'generators/devise/orm_helpers'
module ActiveRecord
module Generators
class DeviseGenerator < ActiveRecord::Generators::Base
class DeviseGenerator < Base
argument :attributes, type: :array, default: [], banner: "field:type field:type"
class_option :primary_key_type, type: :string, desc: "The type for primary key"
@@ -82,23 +82,32 @@ RUBY
postgresql?
end
def rails5_and_up?
Rails::VERSION::MAJOR >= 5
def rails61_and_up?
Rails::VERSION::MAJOR > 6 || (Rails::VERSION::MAJOR == 6 && Rails::VERSION::MINOR >= 1)
end
def postgresql?
config = ActiveRecord::Base.configurations[Rails.env]
config && config['adapter'] == 'postgresql'
ar_config && ar_config['adapter'] == 'postgresql'
end
def migration_version
if rails5_and_up?
"[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
end
end
def ar_config
if ActiveRecord::Base.configurations.respond_to?(:configs_for)
if rails61_and_up?
ActiveRecord::Base.configurations.configs_for(env_name: Rails.env, name: "primary").configuration_hash
else
ActiveRecord::Base.configurations.configs_for(env_name: Rails.env, spec_name: "primary").config
end
else
ActiveRecord::Base.configurations[Rails.env]
end
end
def migration_version
"[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
end
def primary_key_type
primary_key_string if rails5_and_up?
primary_key_string
end
def primary_key_string

View File

@@ -11,7 +11,7 @@ module Devise
Create inherited Devise controllers in your app/controllers folder.
Use -c to specify which controller you want to overwrite.
If you do no specify a controller, all controllers will be created.
If you do not specify a controller, all controllers will be created.
For example:
rails generate devise:controllers users -c=sessions

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

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

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

45
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|
@@ -68,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
@@ -103,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) %>'
@@ -145,6 +157,9 @@ Devise.setup do |config|
# initial account confirmation) to be applied. Requires additional unconfirmed_email
# db field (see migrations). Until confirmed, new email is stored in
# unconfirmed_email column, and copied to email column on successful confirmation.
# Also, when used in conjunction with `send_email_changed_notification`,
# the notification is sent to the original email when the change is requested,
# not when the unconfirmed email is confirmed.
config.reconfirmable = true
# Defines which key will be used when confirming an account
@@ -244,14 +259,14 @@ Devise.setup do |config|
# ==> Navigation configuration
# Lists the formats that should be treated as navigational. Formats like
# :html, should redirect to the sign in page when the user does not have
# :html should redirect to the sign in page when the user does not have
# access, but formats like :xml or :json, should return 401.
#
# If you have any extra navigational formats, like :iphone or :mobile, you
# should add them to the navigational formats lists.
#
# The "*/*" below is required to match Internet Explorer requests.
# config.navigational_formats = ['*/*', :html]
# config.navigational_formats = ['*/*', :html, :turbo_stream]
# The default HTTP method used to sign out a resource. Default is :delete.
config.sign_out_via = :delete
@@ -265,9 +280,9 @@ Devise.setup do |config|
# If you want to use other strategies, that are not supported by Devise, or
# change the failure app, you can configure them inside the config.warden block.
#
# config.warden do |manager|
# manager.intercept_401 = false
# manager.default_strategies(scope: :user).unshift :some_external_strategy
# config.warden do |warden_config|
# warden_config.intercept_401 = false
# warden_config.default_strategies(scope: :user).unshift :some_external_strategy
# end
# ==> Mountable engine configurations
@@ -284,12 +299,14 @@ Devise.setup do |config|
# so you need to do it manually. For the users scope, it would be:
# config.omniauth_path_prefix = '/my_engine/users/auth'
# ==> Turbolinks configuration
# If your app is using Turbolinks, Turbolinks::Controller needs to be included to make redirection work correctly:
#
# ActiveSupport.on_load(:devise_failure_app) do
# include Turbolinks::Controller
# end
# ==> Hotwire/Turbo configuration
# When using Devise with Hotwire/Turbo, the http status for error responses
# and some redirects must match the following. The default in Devise for existing
# apps is `200 OK` and `302 Found` respectively, but new apps are generated with
# these new defaults that match Hotwire/Turbo behavior.
# Note: These might become the new default in future versions of Devise.
config.responder.error_status = <%= Rack::Utils::SYMBOL_TO_STATUS_CODE.key(422).inspect %>
config.responder.redirect_status = :see_other
# ==> Configuration for :registerable

View File

@@ -13,7 +13,10 @@
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 %>
<%= f.input :password_confirmation,
label: "Confirm your new password",
required: true,
input_html: { autocomplete: "new-password" } %>
</div>
<div class="form-actions">

View File

@@ -30,6 +30,6 @@
<h3>Cancel my account</h3>
<p>Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %></p>
<div>Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?", turbo_confirm: "Are you sure?" }, method: :delete %></div>
<%= link_to "Back", :back %>

View File

@@ -3,7 +3,7 @@
require 'test_helper'
require 'ostruct'
require 'warden/strategies/base'
require 'devise/test_helpers'
require 'devise/test/controller_helpers'
class CustomStrategyController < ActionController::Base
def new
@@ -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

@@ -14,8 +14,8 @@ class HelperMethodsTest < Devise::ControllerTestCase
end
test 'does not respond_to helper or helper_method' do
refute_respond_to @controller.class, :helper
refute_respond_to @controller.class, :helper_method
assert_not_respond_to @controller.class, :helper
assert_not_respond_to @controller.class, :helper_method
end
test 'defines methods like current_user' do

View File

@@ -64,30 +64,30 @@ class ControllerAuthenticatableTest < Devise::ControllerTestCase
end
test 'proxy authenticate_user! to authenticate with user scope' do
@mock_warden.expects(:authenticate!).with(scope: :user)
@mock_warden.expects(:authenticate!).with({ scope: :user, locale: :en })
@controller.authenticate_user!
end
test 'proxy authenticate_user! options to authenticate with user scope' do
@mock_warden.expects(:authenticate!).with(scope: :user, recall: "foo")
@mock_warden.expects(:authenticate!).with({ scope: :user, recall: "foo", locale: :en })
@controller.authenticate_user!(recall: "foo")
end
test 'proxy authenticate_admin! to authenticate with admin scope' do
@mock_warden.expects(:authenticate!).with(scope: :admin)
@mock_warden.expects(:authenticate!).with({ scope: :admin, locale: :en })
@controller.authenticate_admin!
end
test 'proxy authenticate_[group]! to authenticate!? with each scope' do
[:user, :admin].each do |scope|
@mock_warden.expects(:authenticate!).with(scope: scope)
@mock_warden.expects(:authenticate!).with({ scope: scope, locale: :en })
@mock_warden.expects(:authenticate?).with(scope: scope).returns(false)
end
@controller.authenticate_commenter!
end
test 'proxy authenticate_publisher_account! to authenticate with namespaced publisher account scope' do
@mock_warden.expects(:authenticate!).with(scope: :publisher_account)
@mock_warden.expects(:authenticate!).with({ scope: :publisher_account, locale: :en })
@controller.authenticate_publisher_account!
end
@@ -98,7 +98,7 @@ class ControllerAuthenticatableTest < Devise::ControllerTestCase
test 'proxy admin_signed_in? to authenticatewith admin scope' do
@mock_warden.expects(:authenticate).with(scope: :admin)
refute @controller.admin_signed_in?
assert_not @controller.admin_signed_in?
end
test 'proxy publisher_account_signed_in? to authenticate with namespaced publisher account scope' do
@@ -127,14 +127,14 @@ class ControllerAuthenticatableTest < Devise::ControllerTestCase
test 'sign in proxy to set_user on warden' do
user = User.new
@mock_warden.expects(:user).returns(nil)
@mock_warden.expects(:set_user).with(user, scope: :user).returns(true)
@mock_warden.expects(:set_user).with(user, { scope: :user }).returns(true)
@controller.sign_in(:user, user)
end
test 'sign in accepts a resource as argument' do
user = User.new
@mock_warden.expects(:user).returns(nil)
@mock_warden.expects(:set_user).with(user, scope: :user).returns(true)
@mock_warden.expects(:set_user).with(user, { scope: :user }).returns(true)
@controller.sign_in(user)
end
@@ -148,7 +148,7 @@ class ControllerAuthenticatableTest < Devise::ControllerTestCase
test 'sign in again when the user is already in only if force is given' do
user = User.new
@mock_warden.expects(:user).returns(user)
@mock_warden.expects(:set_user).with(user, scope: :user).returns(true)
@mock_warden.expects(:set_user).with(user, { scope: :user }).returns(true)
@controller.sign_in(user, force: true)
end
@@ -269,7 +269,7 @@ class ControllerAuthenticatableTest < Devise::ControllerTestCase
user = User.new
@controller.session[:user_return_to] = "/foo.bar"
@mock_warden.expects(:user).with(:user).returns(nil)
@mock_warden.expects(:set_user).with(user, scope: :user).returns(true)
@mock_warden.expects(:set_user).with(user, { scope: :user }).returns(true)
@controller.expects(:redirect_to).with("/foo.bar")
@controller.sign_in_and_redirect(user)
end
@@ -277,7 +277,7 @@ class ControllerAuthenticatableTest < Devise::ControllerTestCase
test 'sign in and redirect uses the configured after sign in path' do
admin = Admin.new
@mock_warden.expects(:user).with(:admin).returns(nil)
@mock_warden.expects(:set_user).with(admin, scope: :admin).returns(true)
@mock_warden.expects(:set_user).with(admin, { scope: :admin }).returns(true)
@controller.expects(:redirect_to).with(admin_root_path)
@controller.sign_in_and_redirect(admin)
end
@@ -319,10 +319,10 @@ class ControllerAuthenticatableTest < Devise::ControllerTestCase
test 'is_flashing_format? is guarded against flash (middleware) not being loaded' do
@controller.request.expects(:respond_to?).with(:flash).returns(false)
refute @controller.is_flashing_format?
assert_not @controller.is_flashing_format?
end
test 'is not a devise controller' do
refute @controller.devise_controller?
assert_not @controller.devise_controller?
end
end

View File

@@ -51,11 +51,11 @@ 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
@mock_warden.expects(:authenticate?).with(:rememberable, scope: :user).returns(true)
@mock_warden.expects(:authenticate?).with(:rememberable, { scope: :user }).returns(true)
@mock_warden.expects(:user).with(:user).returns(User.new)
@controller.expects(:redirect_to).with(root_path)
@controller.send :require_no_authentication
@@ -71,7 +71,7 @@ class HelpersTest < Devise::ControllerTestCase
end
test 'require no authentication sets a flash message' do
@mock_warden.expects(:authenticate?).with(:rememberable, scope: :user).returns(true)
@mock_warden.expects(:authenticate?).with(:rememberable, { scope: :user }).returns(true)
@mock_warden.expects(:user).with(:user).returns(User.new)
@controller.expects(:redirect_to).with(root_path)
@controller.send :require_no_authentication
@@ -121,7 +121,7 @@ class HelpersTest < Devise::ControllerTestCase
MyController.send(:public, :navigational_formats)
swap Devise, navigational_formats: ['*/*', :html] do
refute @controller.navigational_formats.include?("*/*")
assert_not @controller.navigational_formats.include?("*/*")
end
MyController.send(:protected, :navigational_formats)

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

@@ -74,7 +74,7 @@ class SessionsControllerTest < Devise::ControllerTestCase
assert_template "devise/sessions/new"
end
test "#destroy doesn't set the flash if the requested format is not navigational" do
test "#destroy doesn't set the flash and returns 204 status if the requested format is not navigational" do
request.env["devise.mapping"] = Devise.mappings[:user]
user = create_user
user.confirm
@@ -88,21 +88,15 @@ class SessionsControllerTest < Devise::ControllerTestCase
assert_equal 204, @response.status
end
if defined?(ActiveRecord) && ActiveRecord::Base.respond_to?(:mass_assignment_sanitizer)
test "#new doesn't raise mass-assignment exception even if sign-in key is attr_protected" do
request.env["devise.mapping"] = Devise.mappings[:user]
test "#destroy returns 401 status if user is not signed in and the requested format is not navigational" do
request.env["devise.mapping"] = Devise.mappings[:user]
delete :destroy, format: 'json'
assert_equal 401, @response.status
end
ActiveRecord::Base.mass_assignment_sanitizer = :strict
User.class_eval { attr_protected :email }
begin
assert_nothing_raised do
get :new, user: { email: "allez viens!" }
end
ensure
ActiveRecord::Base.mass_assignment_sanitizer = :logger
User.class_eval { attr_accessible :email }
end
end
test "#destroy returns 302 status if user is not signed in and the requested format is navigational" do
request.env["devise.mapping"] = Devise.mappings[:user]
delete :destroy
assert_equal 302, @response.status
end
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

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

@@ -71,8 +71,8 @@ class DeviseTest < ActiveSupport::TestCase
test 'add new module using the helper method' do
Devise.add_module(:coconut)
assert_equal 1, Devise::ALL.select { |v| v == :coconut }.size
refute Devise::STRATEGIES.include?(:coconut)
refute defined?(Devise::Models::Coconut)
assert_not Devise::STRATEGIES.include?(:coconut)
assert_not defined?(Devise::Models::Coconut)
Devise::ALL.delete(:coconut)
Devise.add_module(:banana, strategy: :fruits)
@@ -86,13 +86,18 @@ class DeviseTest < ActiveSupport::TestCase
Devise::CONTROLLERS.delete(:kivi)
end
test 'should complain when comparing empty or different sized passes' do
test 'Devise.secure_compare fails when comparing different strings or nil' do
[nil, ""].each do |empty|
refute Devise.secure_compare(empty, "something")
refute Devise.secure_compare("something", empty)
refute Devise.secure_compare(empty, empty)
assert_not Devise.secure_compare(empty, "something")
assert_not Devise.secure_compare("something", empty)
end
refute Devise.secure_compare("size_1", "size_four")
assert_not Devise.secure_compare(nil, nil)
assert_not Devise.secure_compare("size_1", "size_four")
end
test 'Devise.secure_compare passes when strings are the same, even two empty strings' do
assert Devise.secure_compare("", "")
assert Devise.secure_compare("something", "something")
end
test 'Devise.email_regexp should match valid email addresses' do

View File

@@ -73,13 +73,12 @@ class FailureTest < ActiveSupport::TestCase
instance_eval(&block)
end
def call_failure(env_params={})
def call_failure(env_params = {})
env = {
'REQUEST_URI' => 'http://test.host/',
'HTTP_HOST' => 'test.host',
'REQUEST_METHOD' => 'GET',
'warden.options' => { scope: :user },
'rack.session' => {},
'action_dispatch.request.formats' => Array(env_params.delete('formats') || Mime[:html]),
'rack.input' => "",
'warden' => OpenStruct.new(message: nil)
@@ -185,22 +184,39 @@ class FailureTest < ActiveSupport::TestCase
test 'uses the proxy failure message as symbol' do
call_failure('warden' => OpenStruct.new(message: :invalid))
assert_equal 'Invalid Email or password.', @request.flash[:alert]
assert_equal 'Invalid email or password.', @request.flash[:alert]
assert_equal 'http://test.host/users/sign_in', @response.second["Location"]
end
test 'supports authentication_keys as a Hash for the flash message' do
swap Devise, authentication_keys: { email: true, login: true } do
call_failure('warden' => OpenStruct.new(message: :invalid))
assert_equal 'Invalid Email, Login or password.', @request.flash[:alert]
assert_equal 'Invalid email, login or password.', @request.flash[:alert]
end
end
test 'downcases authentication_keys for the flash message' do
call_failure('warden' => OpenStruct.new(message: :invalid))
assert_equal 'Invalid email or password.', @request.flash[:alert]
end
test 'humanizes the flash message' do
call_failure('warden' => OpenStruct.new(message: :invalid))
assert_equal @request.flash[:alert], @request.flash[:alert].humanize
end
test 'uses custom i18n options' do
call_failure('warden' => OpenStruct.new(message: :does_not_exist), app: FailureWithI18nOptions)
assert_equal 'User Steve does not exist', @request.flash[:alert]
end
test 'respects the i18n locale passed via warden options when redirecting' do
call_failure('warden' => OpenStruct.new(message: :invalid), 'warden.options' => { locale: :"pt-BR" })
assert_equal 'Email ou senha inválidos.', @request.flash[:alert]
assert_equal 'http://test.host/users/sign_in', @response.second["Location"]
end
test 'uses the proxy failure message as string' do
call_failure('warden' => OpenStruct.new(message: 'Hello world'))
assert_equal 'Hello world', @request.flash[:alert]
@@ -214,14 +230,18 @@ class FailureTest < ActiveSupport::TestCase
test 'set up a default message' do
call_failure
assert_match(/You are being/, @response.last.body)
assert_match(/redirected/, @response.last.body)
assert_match(/users\/sign_in/, @response.last.body)
if Devise::Test.rails71_and_up?
assert_empty @response.last.body
else
assert_match(/You are being/, @response.last.body)
assert_match(/redirected/, @response.last.body)
assert_match(/users\/sign_in/, @response.last.body)
end
end
test 'works for any navigational format' do
swap Devise, navigational_formats: [:xml] do
call_failure('formats' => Mime[:xml])
swap Devise, navigational_formats: [:json] do
call_failure('formats' => Mime[:json])
assert_equal 302, @response.first
end
end
@@ -236,7 +256,7 @@ class FailureTest < ActiveSupport::TestCase
context 'For HTTP request' do
test 'return 401 status' do
call_failure('formats' => Mime[:xml])
call_failure('formats' => Mime[:json])
assert_equal 401, @response.first
end
@@ -258,13 +278,13 @@ class FailureTest < ActiveSupport::TestCase
end
test 'return WWW-authenticate headers if model allows' do
call_failure('formats' => Mime[:xml])
call_failure('formats' => Mime[:json])
assert_equal 'Basic realm="Application"', @response.second["WWW-Authenticate"]
end
test 'does not return WWW-authenticate headers if model does not allow' do
swap Devise, http_authenticatable: false do
call_failure('formats' => Mime[:xml])
call_failure('formats' => Mime[:json])
assert_nil @response.second["WWW-Authenticate"]
end
end
@@ -278,7 +298,13 @@ class FailureTest < ActiveSupport::TestCase
test 'uses the failure message as response body' do
call_failure('formats' => Mime[:xml], 'warden' => OpenStruct.new(message: :invalid))
assert_match '<error>Invalid Email or password.</error>', @response.third.body
assert_match '<error>Invalid email or password.</error>', @response.third.body
end
test 'respects the i18n locale passed via warden options when responding to HTTP request' do
call_failure('formats' => Mime[:json], 'warden' => OpenStruct.new(message: :invalid), 'warden.options' => { locale: :"pt-BR" })
assert_equal %({"error":"Email ou senha inválidos."}), @response.third.body
end
context 'on ajax call' do
@@ -326,8 +352,8 @@ class FailureTest < ActiveSupport::TestCase
"warden" => stub_everything
}
call_failure(env)
assert @response.third.body.include?('<h2>Log in</h2>')
assert @response.third.body.include?('Invalid Email or password.')
assert_includes @response.third.body, '<h2>Log in</h2>'
assert_includes @response.third.body, 'Invalid email or password.'
end
test 'calls the original controller if not confirmed email' do
@@ -337,8 +363,8 @@ class FailureTest < ActiveSupport::TestCase
"warden" => stub_everything
}
call_failure(env)
assert @response.third.body.include?('<h2>Log in</h2>')
assert @response.third.body.include?('You have to confirm your email address before continuing.')
assert_includes @response.third.body, '<h2>Log in</h2>'
assert_includes @response.third.body, 'You have to confirm your email address before continuing.'
end
test 'calls the original controller if inactive account' do
@@ -348,8 +374,8 @@ class FailureTest < ActiveSupport::TestCase
"warden" => stub_everything
}
call_failure(env)
assert @response.third.body.include?('<h2>Log in</h2>')
assert @response.third.body.include?('Your account is not activated yet.')
assert_includes @response.third.body, '<h2>Log in</h2>'
assert_includes @response.third.body, 'Your account is not activated yet.'
end
if Rails.application.config.respond_to?(:relative_url_root)
@@ -361,20 +387,86 @@ 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
test 'respects the i18n locale passed via warden options when recalling original controller' do
env = {
"warden.options" => { recall: "devise/sessions#new", attempted_path: "/users/sign_in", locale: :"pt-BR" },
"devise.mapping" => Devise.mappings[:user],
"warden" => stub_everything
}
call_failure(env)
assert_includes @response.third.body, '<h2>Log in</h2>'
assert_includes @response.third.body, 'Email ou senha inválidos.'
end
# TODO: remove conditional/else when supporting only responders 3.1+
if ActionController::Responder.respond_to?(:error_status=)
test 'respects the configured responder `error_status` for the status code' do
swap Devise.responder, error_status: :unprocessable_entity do
env = {
"warden.options" => { recall: "devise/sessions#new", attempted_path: "/users/sign_in" },
"devise.mapping" => Devise.mappings[:user],
"warden" => stub_everything
}
call_failure(env)
assert_equal 422, @response.first
assert_includes @response.third.body, 'Invalid email or password.'
end
end
test 'respects the configured responder `redirect_status` if the recall app returns a redirect status code' do
swap Devise.responder, redirect_status: :see_other do
env = {
"warden.options" => { recall: "devise/registrations#cancel", attempted_path: "/users/cancel" },
"devise.mapping" => Devise.mappings[:user],
"warden" => stub_everything
}
call_failure(env)
assert_equal 303, @response.first
end
end
else
test 'uses default hardcoded responder `error_status` for the status code since responders version does not support configuring it' do
env = {
"warden.options" => { recall: "devise/sessions#new", attempted_path: "/users/sign_in" },
"devise.mapping" => Devise.mappings[:user],
"warden" => stub_everything
}
call_failure(env)
assert_equal 200, @response.first
assert_includes @response.third.body, 'Invalid email or password.'
end
test 'users default hardcoded responder `redirect_status` for the status code since responders version does not support configuring it' do
env = {
"warden.options" => { recall: "devise/registrations#cancel", attempted_path: "/users/cancel" },
"devise.mapping" => Devise.mappings[:user],
"warden" => stub_everything
}
call_failure(env)
assert_equal 302, @response.first
end
end
end
context "Lazy loading" do
test "loads" do
assert_equal Devise::FailureApp.new.lazy_loading_works?, "yes it does"
assert_equal "yes it does", Devise::FailureApp.new.lazy_loading_works?
end
end
context "Without Flash Support" do
test "returns to the default redirect location without a flash message" do
call_failure request_klass: RequestWithoutFlashSupport

View File

@@ -20,11 +20,7 @@ if DEVISE_ORM == :active_record
Rails.application.config.paths.add "db/migrate", with: "db2/migrate"
run_generator %w(monster)
if Rails.version >= '5.0.3'
assert_migration "db2/migrate/devise_create_monsters.rb", /def change/
else
assert_migration "db/migrate/devise_create_monsters.rb", /def change/
end
assert_migration "db2/migrate/devise_create_monsters.rb", /def change/
Rails.application.config.paths["db/migrate"] = old_paths
end
@@ -49,11 +45,7 @@ if DEVISE_ORM == :active_record
assert_file "app/models/monster.rb"
run_generator %w(monster)
if Rails.version >= '5.0.3'
assert_migration "db2/migrate/add_devise_to_monsters.rb"
else
assert_migration "db/migrate/add_devise_to_monsters.rb"
end
assert_migration "db2/migrate/add_devise_to_monsters.rb"
Rails.application.config.paths["db/migrate"] = old_paths
end
@@ -84,11 +76,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 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/
end
assert_migration "db/migrate/devise_create_monsters.rb", /create_table :monsters, id: :uuid do/
end
end

View File

@@ -37,5 +37,4 @@ class DeviseGeneratorTest < Rails::Generators::TestCase
FileUtils.mkdir_p(destination)
FileUtils.cp routes, destination
end
end

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