3948 Commits

Author SHA1 Message Date
Carlos Antonio da Silva
e9c534d363 Fix "Test is missing assertions" warnings
`test_set_null_fields_on_migrations`
      ./devise/test/models_test.rb:87
    `test_does_not_crash_when_the_last_request_at_is_a_String`
      ./devise/test/integration/timeoutable_test.rb:191
    `test_defined_Warden_after_authentication_callback_should_not_be_called_when_sign_in_is_called`
      ./devise/test/test/controller_helpers_test.rb:114
    `test_defined_Warden_before_logout_callback_should_not_be_called_when_sign_out_is_called`
      ./devise/test/test/controller_helpers_test.rb:128
2026-01-05 18:16:22 -03:00
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.
v5.0.0.rc
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