Compare commits

...

568 Commits

Author SHA1 Message Date
Marcos Ferreira
6f9a736115 wip 2019-10-29 14:11:26 -03:00
Rafael França
885c61ece3 Merge pull request #5157 from tabakazu/add_assert_and_replace_mathcer
Add assert to Lockable integration test and Replace mathcer `assert_not` to `refute`
2019-10-25 11:54:53 -04:00
tabakazu
940b939791 Add assert for check last_sign_in_ip value 2019-10-24 21:12:27 +09:00
Looi David
406915cb78 changed? behaviour has been updated (#5135)
* `changed?` behaviour has been updated

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

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

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

* Use `media_type` instead of `content_type`

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

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

* Use render template instead of render file

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

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

* Don't set `represent_boolean_as_integer` on Rails 6

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

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

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

Test results
---

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

Other gems
---

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

Previous changes
---

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

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

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

Related resources:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

* Set encrypted password to nil if password is nil

* [#4245] Fixing the build

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

> You can add it to your Gemfile with:

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

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

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

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

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

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

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

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

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

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

```ruby
class User
  devise :trackable

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

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

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

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

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

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

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

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

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

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

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

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

* Add specs
2018-01-16 10:25:20 -02:00
Rafael França
371d657e35 Merge pull request #4753 from segiddins/patch-1
[Gemspec] Ensure it is loaded as utf-8
2018-01-15 15:03:03 -05:00
Samuel Giddins
82087ce211 [Gemspec] Ensure it is loaded as utf-8 2018-01-12 21:26:42 -08:00
Leonardo Tegon
463351922f Update copyright [ci skip] 2018-01-03 21:20:13 -02:00
Leonardo Tegon
3080e9e018 Don't run ruby 2.5.0 with rails 4.1
https://github.com/rails/rails/issues/25125
2017-12-29 16:42:58 -02:00
Leonardo Tegon
caf633854d Run gem update --system before install on CI
There's an issue with the combination of Bundler `1.16.1` and rubygems `2.7.3`.
This command will install rubygems `2.7.4` in order to fix it.

https://github.com/travis-ci/travis-ci/issues/8978
2017-12-29 16:11:04 -02:00
Leonardo Tegon
f016e823cd Use rdoc 5.1 for ruby 2.1 on CI
`rdoc 6.0` requires ruby version >= `2.2.2`
2017-12-29 16:09:51 -02:00
Leonardo Tegon
9843cb27dc Run tests on ruby 2.5.0 2017-12-29 15:08:49 -02:00
Leonardo Tegon
50bbb56576 Prepare for 4.4.0 release 2017-12-29 14:34:02 -02:00
Leonardo Tegon
135d898e0e Update CHANGELOG.md 2017-12-26 07:59:48 -02:00
Filip Soszyński
b01ae718b3 Primary key type in migration template (#4426)
* Tests

* Add primary key type to migration template

* Change Rails version-detecting method in test
2017-12-23 17:20:45 -02:00
fjg
8c9cc8d355 Change the way to detect ActiveRecord vs Mongoid (#4302)
* Change the way to detect ActiveRecord vs Mongoid

Cause of **mongoid-paperclip** declaring *after_commit* callback while **mongoid** (and MongoDB) does not support it.

* Update test for ActiveRecord presence to handle Mongoid/ActiveRecord project
2017-12-23 16:39:39 -02:00
Anton Davydov
95689757c0 Delete unnecessary condition for helper method (#4359) 2017-12-22 15:38:45 -02:00
Rafael França
0720bc72c3 Merge pull request #4731 from alexhifer/master
Added the ability to change the default migrations path
2017-12-21 18:33:07 -05:00
Leonardo Tegon
5f1c210511 Update CHANGELOG.md [ci skip] 2017-12-21 17:15:01 -02:00
Mike Rogers
16b3d6d67c Adding autocomplete="email" to email fields (#4643)
As discussed in https://github.com/plataformatec/devise/issues/4635
2017-12-21 17:13:50 -02:00
Lutz Lengemann
7b3081760f Move failed_attempts increment into its a function (#4351)
With this change one can overwrite when the incrementation is handled without duplicating the other `valid_for_authentication` logic.
2017-12-21 16:49:09 -02:00
Olivier Lacan
5a3b7a1771 Clarify how store_location_for modifies URIs (#4391)
This fairly straightforward refactor extracts the most obtuse
portions of store_location_for into the following discrete
private methods:
- extract_path_from_location
- remove_domain_from_uri
- add_fragment_back_to_path

This may seem like indirection but it was very unclear what
operation was being performed on the location sent to
store_location_for prior to this change.

I considered documenting the behavior but the code seemed
like a prime candidate for method extraction.
2017-12-21 16:15:53 -02:00
Sai Chander
db011c0192 set_flash_method! instead of set_flash_method in omniauth callbacks controller (#4680) 2017-12-21 15:53:14 -02:00
Pat Allan
f39c6fd927 Add the frozen_string_literal pragma comment to all Ruby files. (#4725) 2017-12-21 15:36:29 -02:00
Guilherme Goettems Schneider
8b9fba73fd Allow frozen options in as_json (#4655)
The test uses `as_json` instead of `to_json` because `to_json` does `#dup` on `options` before it reaches `#serializable_hash` and the test would pass without the fix.
2017-12-21 15:23:25 -02:00
Alexey Degtyarev
12298ef968 Added the ability to change the default migrations path (introduced in Rails 5.0.3) 2017-12-21 17:12:19 +02:00
Paulo Henrique Castro
1b02534bef change validatable docs to match generator (#4727)
lib/generators/templates/devise.rb#L160
2017-12-19 08:34:45 -02:00
Shiva Bhusal
42b68d53a7 Adds Table of content to Readme.md (#4621)
* Adds Table of content to Readme.md

* adds 's' to content
2017-12-17 14:00:32 -02:00
Mark Donald Amobi
4f2e915833 minor grammar fix in rememberable documentation (#4550) 2017-12-07 23:16:27 -02:00
Ahmad hamza
f8c1ee0f90 Added nested attributes example for README (#4434) 2017-12-07 23:13:30 -02:00
Calvin Claus
2458334de6 added note about stopping spring (#4506)
For me it was necessary to stop spring for the route helpers to be defined.
2017-12-07 22:29:41 -02:00
Leonardo Tegon
451ba5362b Update changelog [ci skip] 2017-11-28 13:03:53 -02:00
Ashley Foster
31801fc9a0 Fix missing validations on Signup (#4674)
* Fix missing validations on Signup

This commit fixes issue
https://github.com/plataformatec/devise/issues/4673

This removes `validate: false` from saving a record when `Trackable` is
in use.

* Add test case

* Add mongoid model
2017-11-28 12:58:41 -02:00
Felipe Renan
ce0414271a Merge pull request #4704 from plataformatec/plataformatec/issue-template
Add issue template
2017-11-22 20:07:44 -02:00
Rafael França
701d4929d8 Merge pull request #4375 from fbbergamo/change-status-append
Replace log_process_action to append_info_to_payload
2017-11-22 15:53:28 -05:00
Felipe Renan
e61f4bae40 Add issue template
The issue template is a guide to help the contributors report issues.
2017-11-22 18:39:01 -02:00
Rafael França
88e9a85d6a Merge pull request #4694 from rpbaptist/devise_scope-doc
Provide additional info on devise_scope usage
2017-11-06 11:37:55 -05:00
Richard Baptist
d6ffa8ef22 Provide additional info on devise_scope usage 2017-11-06 17:25:29 +01:00
Rafael França
448106f458 Merge pull request #4692 from masatooba/fix-rake-to-rails
Change `rake secret` to `rails secret` in comments
2017-11-02 22:58:56 -04:00
Masato Oba
a88f88eb4b Change rake secret to rails secret in comments 2017-11-02 15:38:32 +00:00
Rafael França
2b10d517f6 Merge pull request #4683 from masatooba/remove-unnecessary-method
Remove unnecessary hide! method definition
2017-10-31 01:51:16 -04:00
Rafael França
4db1d819b0 Merge pull request #4682 from haneru/edit-gemfile
Removed gem minitest
2017-10-31 01:50:37 -04:00
Rafael França
840c2e7306 Merge pull request #4686 from kyoshidajp/fix_mongoid_failed_test
Fix mongoid test failed problem
2017-10-31 01:44:48 -04:00
Rafael França
657507b705 Merge pull request #4687 from masatooba/fix-spec-typo
Fix small typo in test
2017-10-30 15:33:35 -04:00
Masato Oba
975bb8490d Fix typo 'an user' to 'a user' 2017-10-29 12:31:06 +00:00
Masato Oba
6ceb649b10 Fix small typo in authenticatable_test.rb 2017-10-29 12:10:39 +00:00
Katsuhiko YOSHIDA
bcb67ecde8 Fix mongoid test failed problem 2017-10-28 15:56:32 +09:00
haneru
4184e23d71 bundle installed 2017-10-28 01:46:55 +09:00
masatooba
a24f98f315 Delete unnecessary hide! method
This method has already been added to Rails.
2017-10-28 01:26:26 +09:00
haneru
c74e2693a3 Removed gem minitest 2017-10-28 01:09:43 +09:00
Rafael França
7a7a099573 Merge pull request #4677 from bananaappletw/master
Remove TODO when Rails 5.0.3 is released
2017-10-23 15:07:09 -04:00
Rafael França
215d034b86 Merge pull request #4645 from swamp09/ci_against
CI against Ruby 2.2.8, 2.3.5, and 2.4.2
2017-10-20 13:34:04 -04:00
Vasiliy Ermolovich
3323197d68 Merge pull request #4668 from pat/mri2.5.0-fix
Fix syntax for MRI 2.5.0-preview1.
2017-10-14 16:25:23 +03:00
Pat Allan
1009096172 Fix syntax for MRI 2.5.0-preview1. 2017-10-13 10:38:43 +11:00
bananaappletw
197ac56520 Remove TODO when Rails 5.0.3 is released 2017-10-07 02:40:32 -07:00
swamp09
92b94bc84d CI against Ruby 2.2.8, 2.3.5, and 2.4.2 2017-09-16 23:40:57 +09:00
Rafael França
71fc5b351a Merge pull request #4565 from pat/frozen-string-literals
Ensure string literals can be frozen.
2017-06-21 14:16:43 -04:00
Pat Allan
4e9860d268 Ensure string literals can be frozen. 2017-06-21 09:22:49 +10:00
Rafael França
ad8547dede Merge pull request #4381 from slbug/master
remove warnings about default value with new thor
2017-06-13 15:51:20 -04:00
Lucas Mazza
079ed3b6f8 Update Changelog [ci skip] 2017-05-14 21:10:36 -03:00
Rafael Mendonça França
5e014ab607 Exclude Rails 4.1 in Ruby 2.4.1 2017-05-11 19:23:05 -07:00
Rafael Mendonça França
0f6014b84d Make sure we are using a version of minitest that is not broken with
Rails.
2017-05-11 19:06:29 -07:00
Rafael Mendonça França
b5629ebf1d Test with Rails 5.0 2017-05-11 19:00:04 -07:00
Lucas Mazza
ee01bac8b0 Update CHANGELOG. 2017-05-10 17:18:00 -03:00
Lucas Mazza
3e1c9e343c Add Devise.activerecord51?
Active Record changed it's public API, so we should check against its
version instead of Rails as it is possible to use Rails 5.1 with Mongoid,
which still has the older Dirty API.

However, this patch does not fixes a scenario where an app has both
Active Record and Mongoid loaded. It should be fixed by either normalizing
the Mongoid/ActiveRecord API or replacing the conditional method
definitions with a shim layer that abstracts this away.
2017-05-10 17:09:38 -03:00
Lucas Mazza
399774af69 Prepare for 4.3.0 release. 2017-05-10 16:50:40 -03:00
Rafael França
a62faa2c82 Merge pull request #4528 from mikevic/master
Update copyright licence year to 2017
2017-05-05 14:10:44 -07:00
Michael Kevin Victor
059dfc8cce Update copyright licence year to 2017 2017-05-05 18:28:30 +05:30
Rafael França
cc6a582408 Merge pull request #4523 from trammel/rails-5.1-render-text
Rails 5.1 fix: Replaced render :text 404 with :plain in omniauth
2017-05-03 10:49:24 -07:00
Jonathon Padfield
ce08d7abb8 Replaced render :text 404 with :plain in omniauth
Rails 5.1 has deprecated render :text, and HEAD requests on the
omniauth callbacks passthru method is causing errors because the render
:text is non-existant, and there's no template to fall back to.

Replacing :text with :plain, adds a content-type type of text/plain and
also returns the previous message.

render :plain was supported back in rails 4.1.0
http://api.rubyonrails.org/v4.1.0/classes/ActionView/Helpers/RenderingHelper.html#method-i-render
2017-05-03 13:31:52 +10:00
Rafael França
83213569dd Merge pull request #4516 from danschultzer/separate-devise-test
Separate Devise test methods from Devise
2017-04-29 23:18:58 -07:00
Dan Schultzer
be2e17841e Separate Devise test methods from Devise 2017-04-29 10:24:22 -07:00
Rafael Mendonça França
0591d92f53 Move the version check to the lib folder
Closes #4514.
Fixes #4513.
2017-04-29 10:12:51 -07:00
Rafael Mendonça França
244cc60d35 Remove deprecation on email_was 2017-04-28 16:07:27 -07:00
Rafael Mendonça França
94c6d5f5cc Remove deprecation on _changed? methods 2017-04-28 16:05:39 -07:00
Rafael Mendonça França
0fe308e7a7 Remove deprecation in the email_was method 2017-04-28 15:33:55 -07:00
Rafael Mendonça França
801cf00146 Test by default with Rails 5.1 2017-04-28 15:33:43 -07:00
Rafael França
83002017ea Merge pull request #4504 from schmartmann/master
update rake reference to rails
2017-04-28 15:17:26 -07:00
Rafael França
0263b8dbfc Merge pull request #4503 from xemexpress/master
Update copyright year to 2017
2017-04-28 15:17:08 -07:00
Rafael França
4beeca46c4 Merge pull request #4512 from jcoyne/rails-5.1
Rails 5.1
2017-04-28 15:16:35 -07:00
Matthew Rudy Jacobs
7c4e8c8d17 Rails 5.1 requires ActionController::TestRequest to have a controller class
Pass it in as an anonymous class
2017-04-28 10:51:27 -05:00
Matthew Rudy Jacobs
36613b09d7 Allow Rails 5.1 2017-04-28 10:51:27 -05:00
Stefan Hartmann
31774452e8 update rake reference to rails 2017-04-25 16:19:20 -04:00
Felipe Bergamo
6eb412efae Typo test doc 2017-04-24 18:38:49 -03:00
Jason Luo
244c22a6a2 Update copyright year to 2017 2017-04-07 22:36:22 +08:00
Carlos Antonio da Silva
7d3d6fb3f0 Release 4.2.1 2017-03-15 12:33:23 -03:00
Carlos Antonio da Silva
ce071502ee Display unconfirmed email when using reconfirmable and email changed notification
Otherwise we'd be mistakenly displaying the original email in the
message (which is the same we're sending the message to).

Also tweak the messaging a bit in this case, to show that the email "is
being changed" (the change hasn't taken effect yet).

Related to #4455.
2017-03-15 11:47:47 -03:00
Carlos Antonio da Silva
32f63b2fb9 Bundle update 2017-03-15 10:31:00 -03:00
Carlos Antonio da Silva
bacd9d244c Ensure both times are UTC when validating the confirmation period
The fact that we're setting them value as UTC doesn't necessarily mean
we're gonna get it back as UTC, so ensure both are converted to compare.
2017-03-15 10:22:01 -03:00
Carlos Antonio da Silva
a665aada25 Merge pull request #4461 from jjuliano/patch-1
Confirmation link validity is wrong in different time zone
2017-03-15 10:17:25 -03:00
Carlos Antonio da Silva
0c5d78e31c Merge pull request #4456 from victor-am/hotfix_absent_new_password_values
Fix absent password params from Password#update

Closes #4397.
2017-03-13 19:41:46 -03:00
victor-am
60dc4be8c1 Fix absent password params from Password#update
Related to issue #4397

This hotfix adds a string coercion to new_password paramenters when
trying to reset an user's password.

Before that, when a user submitted a password recovery form with the
new_password and new_password_confirmation params as nil, Devise would
sign in the user with a success notice but without actually changing the
password.
2017-03-10 14:29:25 -03:00
Carlos Antonio da Silva
f7b6d78606 Merge pull request #4455 from plataformatec/feature/confirmation-notification
Notify original email when it's changed
2017-03-10 09:34:06 -03:00
Carlos Antonio da Silva
c605758800 Add some basic tests for the email changed notification 2017-03-10 09:10:57 -03:00
Carlos Antonio da Silva
2135ae5e5e Change email_change => email_changed notification
This better indicates what the setting is for, and when it's supposed to
be triggered.

We might eventually deprecate the existing password_change on in favor
of password_changed.
2017-03-10 08:56:34 -03:00
Joel Bryan Juliano
a3d31778c2 Confirmation link validity is wrong in different time zone
Due to time zone difference, the confirmation link in email is invalid, this can be solved by using UTC for Time.now for confirmation_period_expired?
2017-03-08 19:36:41 +08:00
Carlos Antonio da Silva
d7f6855ad8 Add some docs to the send email/password notification settings [ci skip] 2017-03-06 17:33:34 -03:00
Carlos Antonio da Silva
0a9e2c961f Add changelog entry for new email change notification feature [ci skip] 2017-03-06 17:20:55 -03:00
Carlos Antonio da Silva
8387cc9474 When using reconfirmable, notify the original email about the change right away
Do not wait for the email change to be confirmed by the "unconfirmed
email" with reconfirmable: notify the original email right away.
2017-03-06 17:07:55 -03:00
Carlos Antonio da Silva
70eb18d766 Notify original user email when the email changes
This adds a new setting `send_email_change_notification` which will
send an email to the original user email when their email is updated to
a new one.

It doesn't take into account the reconfirmable setting yet, it will be
added next, so that if confirmable is included and reconfirmable is
being used, the email will be triggered when the email change is
requested, not when confirmed (e.g when we store the email in
`unconfirmed_email`, not when it's later copied to `email` when that is
confirmed).
2017-03-06 17:04:26 -03:00
Carlos Antonio da Silva
bf4641c8cf Skip running tests on Ruby 2.4 / head and Rails 4.1 2017-03-02 09:59:05 -03:00
Carlos Antonio da Silva
c76f0e59b7 Use assert_nil to prevent minitest warnings 2017-03-02 08:12:46 -03:00
Carlos Antonio da Silva
fa2d333bde Update Gemfile dependencies 2017-03-02 08:12:36 -03:00
Carlos Antonio da Silva
15a50dc8d7 Test against latest ruby versions 2017-03-02 08:11:08 -03:00
Carlos Antonio da Silva
a47928090a Merge pull request #4445 from gogovan/fix-strategy-class-tests
Fix Omniauth config tests
2017-03-02 08:10:03 -03:00
Matthew Rudy Jacobs
6fc6a28e3b Avoid the assert_equal nil deprecation warning 2017-02-26 22:05:15 +00:00
Matthew Rudy Jacobs
6bc2db4567 Fix Omniauth config tests 2017-02-26 21:52:51 +00:00
George Guimarães
5abdb65e56 Deprecate mailing list 2017-02-04 18:57:47 -02:00
Vasiliy Ermolovich
25a3eeb30a Merge pull request #4403 from bakongo/fix_name_of_module_in_rdoc
fix name of the module in the docs
2017-01-20 23:30:11 +03:00
Daniel Wiesmann
33d5335f53 fix name of the module in the docs 2017-01-19 13:03:10 +01:00
Alexander Grebennik
47077bf810 fix warnings about default value with new thor 2016-12-20 02:14:41 +03:00
Felipe Bergamo
9caae50339 Replace log_process_action to append_info_to_payload 2016-12-10 18:40:57 -02:00
Vasiliy Ermolovich
8a4d610c58 Merge pull request #4361 from lmatiolis/fix-authenticatable-name-on-exception
Fix authenticatable_salt name on exception text.
2016-11-27 23:30:28 +03:00
lmatiolis
3d2a908f64 Fix authenticatable_salt name on exception text. 2016-11-23 17:25:44 -02:00
Lucas Mazza
d2ea28b3db Merge pull request #4343 from ethirajsrinivasan/set_minimum_password_length_for_registration_update_path
set minimum password length after user registration update
2016-10-31 13:50:47 -02:00
ethiraj
7a44233fb9 set minimum password length after user registration update 2016-10-27 08:33:35 +05:30
Hiroo Takizawa
a9bb7d0318 Update README.md
change "bundle command" to the writing of "command line"
2016-10-19 22:54:41 +03:00
José Valim
ebe65b516b Merge pull request #4318 from kami-zh/improve-readme
Update README - Decrease stretches to 12
2016-10-05 18:29:42 +02:00
kami
ebf79be163 Update README - Decrease stretches to 12 2016-10-06 01:05:39 +09:00
Carlos Antonio da Silva
88724e10ad Merge pull request #4292 from rousisk/rousisk-readme-var-to-symbol
convert variable to symbol in readme
2016-09-13 15:41:50 -03:00
Konstantinos Rousis
30405943b5 convert variable to symbol in readme 2016-09-13 20:39:44 +02:00
Lucas Mazza
9c0dccfec1 Merge pull request #4284 from znz/strip_heredoc
Use `strip_heredoc` for deprecation warnings
2016-09-04 12:49:10 -03:00
Kazuhiro NISHIYAMA
9fe7040db9 Use strip_heredoc for deprecation warnings 2016-09-04 19:15:09 +09:00
Lucas Mazza
4c3838bb75 Merge pull request #4255 from olivierlacan/patch-2
Fix typos in failure_app comments
2016-08-15 19:05:39 -03:00
Olivier Lacan
48aa20897f Fix typos in failure_app comments 2016-08-15 15:51:11 -04:00
Vasiliy Ermolovich
2a5f8b6688 Merge pull request #4250 from marcgg/patch-1
Fix a minor typo in specs
2016-08-11 11:21:31 +03:00
Marc G Gauthier
8ee01fc10b Fix a minor typo in specs
There is nothing much to this one, it's in the test description so it shouldn't impact a thing and will make this line more greppable.
2016-08-11 09:56:45 +02:00
Carlos Antonio da Silva
d7985e7ddb Merge pull request #4247 from rthbound/updates-omniauth-url
Updates url for omniauth to omniauth/omniauth repo
2016-08-10 14:56:53 -03:00
Ryan T. Hosford
ae8b0914a9 Updates url for omniauth to omniauth/omniauth repo 2016-08-10 09:57:14 -05:00
Lucas Mazza
6720f93d2c Remove deprecated omniauth path from store_location docs [ci skip] 2016-07-26 10:10:49 -03:00
Lucas Mazza
13d4fd4088 Merge pull request #4193 from 3wille/master
add block passthrough to devise_mail
2016-07-22 15:14:51 -03:00
Vasiliy Ermolovich
bbd614a725 Merge pull request #4206 from nickharvey27/fix-typo
Fix small typo
2016-07-19 09:50:06 +03:00
nickharvey27
eb0540e028 fix small typo 2016-07-18 23:46:51 -07:00
Frederik Wille
08374f1d33 fix test 2016-07-18 09:24:46 +02:00
Frederik Wille
a5f8cd9d32 simplify test 2016-07-18 09:00:32 +02:00
Lucas Mazza
54e7a3b9d9 Devise::Mailer#scope_name and Devise::Mailer#resource shouldn't be public. 2016-07-15 16:02:43 -03:00
Carlos Antonio da Silva
e761a8df2b Merge pull request #4200 from amingilani/master
[Minor] Fix indentation in generators
2016-07-15 08:17:07 -03:00
Frederik Wille
65d8e94ed9 add test
in the test we need to declare a subclass of ``Devise::Mailer`` to give
a block to mail call inside of method which has a corresponding view
template

there are propably better ways to test this, but this is pretty much the
use case for passing a block
2016-07-15 12:22:12 +02:00
amingilani
83b88353b5 Fix indentation in generators 2016-07-15 13:22:51 +05:00
Lucas Mazza
39227bd494 Merge pull request #4194 from nviennot/orm_surface
Reduce ORM API surface
2016-07-13 21:03:31 -03:00
Nicolas Viennot
e841c4c5ef Reduce ORM API surface 2016-07-13 12:48:12 -04:00
Frederik Wille
e90ba2fbcb add block passthrough to devise_mail
ActionMailer's ``mail`` method may receive a block for customizing the mails
format
``devise_mail`` now has the same functionality by just
passing the block to ``mail`` call.

fixes plataformatec/devise#2341
2016-07-13 11:25:35 +02:00
Lucas Mazza
e6b5f5f31a Expand CONTRIBUTING.md [ci skip]. 2016-07-12 21:29:02 -03:00
Lucas Mazza
245b1f9de0 Update .travis.yml. 2016-07-01 14:22:38 -03:00
Lucas Mazza
e05523f767 Prepare for 4.2.0 release. 2016-07-01 14:15:14 -03:00
Lucas Mazza
2c8727ad42 Test against Rails 5 by default. 2016-07-01 14:13:20 -03:00
Lucas Mazza
b1508e93e1 Properly check for authentication_keys or encrypted_password changes when clearing the reset password token
This change is required to better support scenarios where records don't have
an `encrypted_password` column and the password is managed elsewhere (LDAP, for instance).

The move from `email_changed?` to loop through the `authentication_keys` is also
useful to support edge cases where users can authenticate with different attributes
besides their email.

Closes #3624.
2016-07-01 14:08:38 -03:00
Lucas Mazza
5b57aa0b85 Merge pull request #4175 from AnnaGulstine/master
Added clarification to README regarding Devise setup
2016-07-01 13:59:22 -03:00
AnnaGulstine
768656deb9 Added clarification to README regarding Devise setup 2016-06-30 21:15:32 -05:00
Lucas Mazza
fe10a5b17a Fix test typo and expand test cases for Rememberable#rememberable_value.
Closes #4157
2016-06-27 17:08:52 -03:00
Lucas Mazza
22784cb55a Remove ActiveRecord::Migration inheritance deprecation warning. 2016-06-27 16:50:26 -03:00
Lucas Mazza
656720583f Remove assert_nothing_raised deprecated usage. 2016-06-27 16:48:12 -03:00
Lucas Mazza
a20cca6873 Fix IllegalStateError for controller tests with custom strategies. 2016-06-27 16:43:57 -03:00
Lucas Mazza
8d78dc072f Disable Travis CI fast_finish.
Fast finish triggers multiple Slack notification and floods our OSS slack room,
and it is a known bug for a while.

Reference: travis-ci/travis-ci/issues/1696
2016-06-27 15:17:20 -03:00
Lucas Mazza
b2a2e85412 Update dependencies. 2016-06-27 15:13:47 -03:00
Lucas Mazza
c2c74b0a39 Use ActiveSupport.on_load to hook into Active Record and Mongoid. 2016-06-27 14:55:22 -03:00
Lucas Mazza
92bb772d36 Update CHANGELOG. 2016-06-27 14:55:22 -03:00
Lucas Mazza
783234c72a Merge pull request #4153 from krishandley/fix_env_deprecation_warning
Fix Rails 5 env deprecation warning
2016-06-27 14:44:49 -03:00
Lucas Mazza
2671f19cb1 Merge pull request #4169 from hamadata/fix_test_helper_for_rails5_rc2
Test cases (not signed-in 302 redirection) failed on Rails5 RC2
2016-06-27 14:35:12 -03:00
Lucas Mazza
72ea8392a8 Merge pull request #4168 from bgreg/patch-1
Update README.md
2016-06-27 14:30:03 -03:00
HAMADA Takayuki
bb44d422d6 not signed_in 302 redirect failed on Rails5 RC2 2016-06-26 06:02:58 +09:00
Greg
5d304ae63a Update README.md
Explain the `MODEL` replacement before the command is shown.
2016-06-25 11:36:11 -07:00
Kris Handley
0c991af985 Fix Rails 5 env deprecation warning
Full warning ```DEPRECATION WARNING: env is deprecated and will be removed from Rails 5.1```
2016-06-18 14:20:08 +01:00
Arne Zeising
ac702843dd Change behavior to skip reconfirmation after creating a record with #save called in callback (#4125)
https://github.com/plataformatec/devise/pull/4125
2016-06-13 17:57:24 -03:00
Kostas Diamantis
4015488b90 Add missing support of Rails.application.config.action_controller.relative_url_root (#4146)
* Add Devise::FailureApp#{relative_url_root, relative_url_root?}

Also support missing action_controller.relative_url_root configuration.

* Dry assignment of relative_url_root

Also this commit adds support for
Rails.application.config.action_controller.relative_url_root
2016-06-13 15:46:43 -03:00
Lucas Mazza
cccc137714 Merge pull request #4139 from shinyaK14/public_file_server
Add public_file_server setting for Rails5
2016-06-13 11:34:04 -03:00
Lucas Mazza
3fa0afad67 Merge pull request #4148 from jamescook/james/remove-session-inspect
Remove unnecessary 'warden.raw_session.inspect'
2016-06-13 11:33:33 -03:00
Lucas Mazza
29142418ba Merge pull request #4140 from tkrajcar/add-inspect-override
Implement Devise::Models::Authenticatable#inspect, re-using #serializable_hash
2016-06-13 11:24:27 -03:00
James Cook
c3b54dc0c2 Remove unnecessary 'warden.raw_session.inspect' 2016-06-10 20:14:11 -05:00
Tim Krajcar
a0232cf763 Implement Devise::Models::Authenticatable#inspect, re-using #serializable_hash. 2016-06-03 15:54:58 -07:00
Shinya Kitamura
57980ba82a Add public_file_server setting for Rails5 2016-06-01 14:44:35 +08:00
Carlos Antonio da Silva
bcdd54cc5e Merge pull request #4129 from laserlemon/patch-1
Self-love isn't entirely appropriate in this setting
2016-05-26 11:47:17 -03:00
Steve Richert
83d5d3142d Self-love isn't entirely appropriate in this setting 2016-05-26 09:25:44 -04:00
Stefan Botzenhart
cbbe932ee2 Fix authenticated engine routes (#4081)
Fix infinite loop in authenticated engine routes in Rails 5

https://github.com/plataformatec/devise/issues/3705
2016-05-21 11:55:56 -03:00
Lucas Mazza
593ae41f9d Update existing Gemfiles. 2016-05-18 13:59:06 -03:00
Lucas Mazza
e9770fd434 Update Rails 5 Gemfile. 2016-05-18 13:50:07 -03:00
Lucas Mazza
53f6785e11 Fix Rails version reference on README.md [ci skip] 2016-05-18 13:42:31 -03:00
Lucas Mazza
1b48fd0abe Fix syntax highlight on README [ci skip] 2016-05-18 09:39:04 -03:00
Lucas Mazza
b835059baf Merge pull request #4118 from kamipo/patch-2
Fix release date in CHANGELOG.md
2016-05-17 10:05:48 -03:00
Ryuta Kamizono
f7359d6d96 Fix release date in CHANGELOG.md 2016-05-17 22:00:22 +09:00
Lucas Mazza
4924dd68ae Raise a more informative error when request.env['warden'] is nil.
Previously, a `NoMethodError` exception would be raised from here when the
middleware stack isn't present and Warden wasn't injected as expected
(like in a controller test). To foolproof ourselves, we now raise a more
informative error when `request.env['warden']` is `nil` so developers can
figure this out on their own instead of reaching to the issue tracker for
guidance.
2016-05-16 15:23:25 -03:00
Lucas Mazza
02ed166f51 Update CHANGELOG [ci skip] 2016-05-16 14:45:30 -03:00
Lucas Mazza
9a11586a72 Merge pull request #4071 from plataformatec/lm-test-helpers
Introduce `IntegrationHelpers` and deprecate `Devise::TestHelpers`.
2016-05-16 14:39:22 -03:00
Lucas Mazza
b5a5bae09c Tidy up ControllerHelpers implementation a bit. 2016-05-15 19:55:24 -03:00
Lucas Mazza
e757543323 Revisit docs on test helpers on README.md 2016-05-15 19:47:42 -03:00
Lucas Mazza
7b000390a0 Add Devise::Test::IntegrationHelpers. 2016-05-15 19:36:41 -03:00
Lucas Mazza
3f3ec236bb Move Devise::TestHelpers to Devise::Test::ControllerHelpers. 2016-05-15 19:36:41 -03:00
Lucas Mazza
22dd3b489d Merge pull request #4115 from wbotelhos/patch-1
removes bugfix, from unreleased, already shipped
2016-05-15 19:35:35 -03:00
Lucas Mazza
0d45142845 CONTRIBUTING.md edits
* Wrap lines to around ~80 characters.
* Suggest reporting issues with fresh apps that replicate the issue.
* Mention our policy regarding internationalizing Devise views.
2016-05-15 19:30:14 -03:00
Lucas Mazza
62d6b5afb7 Mention the bug report test case on CONTRIBUTING.md. 2016-05-15 19:24:59 -03:00
Lucas Mazza
934fe45cfe Drop _master suffix as the bug template doesnt use Rails/Devise master. 2016-05-15 19:21:50 -03:00
Lucas Mazza
675ae4d802 Lock devise version on the bug report template. 2016-05-15 19:20:32 -03:00
Lucas Mazza
48251f236f Use single quotes consistently through the integration test example. 2016-05-15 19:19:27 -03:00
Lucas Mazza
8e6e70eaa7 Merge pull request #4087 from leonardoprg/master
fix #3958 adding helper test to report bugs
2016-05-15 19:16:26 -03:00
Washington Botelho
4925ffda31 removes bugfix, from unreleased, already shipped 2016-05-15 13:51:41 -03:00
Ulisses Almeida
f89921e153 📝 Update with minor patch releases 2016-05-15 12:22:45 -03:00
Ulisses Almeida
863b811167 📝 Update CHANGELOG 2016-05-15 11:58:02 -03:00
Lucas Mazza
d1f8884ee6 Merge pull request #4105 from giedriusr/features/update_example_in_authenticatable
Update example code in authenticatable model
2016-05-15 11:49:02 -03:00
Ralin Chimev
9caf07dd4f Fix overwriting the remember_token when a valid one already exists (#4101)
The remember_token should not get overwritten when a user is
signing in and a valid token already exists.

Fixes #3950.
2016-05-15 11:48:12 -03:00
Ulisses Almeida
2044fffa25 Deprecate the bypass option of sign_in (#4078)
The sign_in method permits the bypass option
that ignore the others options used. This behavior
has lead some users to a misconfusion what the
method really does.

This change deprecate the bypass option in favor
of a method that only does the sign in with bypass.

Closes #3981
2016-05-15 11:46:48 -03:00
Giedrius Rimkus
2e442d81f7 Update example code in authenticatable model 2016-05-12 15:47:04 +03:00
Steven Spiel
28f0e3281a Consistency of quotation marks in README (#4103)
* Change double to single quotes in ruby code blocks

For consistency, I switched some of the double quotes to single quotes in the ruby code blocks.
2016-05-11 23:06:40 -03:00
Lucas Mazza
6a0d881554 Merge pull request #4104 from LucasAU/fix-omniauth-changeog
Fix suggested omniauth path
2016-05-11 22:37:32 -03:00
Lucas Nelson
4a9eee5a1c Fix suggested omniauth path
The suggested omniauth path noted in the CHANGELOG.md under 4.0.0.rc2 
did not work. It was missing an `_omniauth` in the middle of the 
method name.

user_github_authorize_path => user_github_omniauth_authorize_path
2016-05-12 10:24:47 +10:00
Vasiliy Ermolovich
a4d3b9f14a Merge pull request #4100 from shinyaK14/update_readme
Update README.md
2016-05-11 09:19:26 +03:00
Shinya Kitamura
1beac93961 Update README.md 2016-05-10 22:11:12 +08:00
Maarten van Vliet
8286325fd0 Remove reference to Rails 3.2 in post-install text (#4094) 2016-05-08 13:41:46 -03:00
Lucas Mazza
228f24c491 Merge pull request #4092 from bogdanvlviv/patch-5
Update .travis.yml
2016-05-06 22:11:57 -03:00
bogdanvlviv
cff78eec23 Update .travis.yml 2016-05-06 23:05:03 +03:00
Leonardo
20d786d7ca fix #3958 adding helper test to report bugs 2016-05-05 23:13:00 +01:00
Lucas Mazza
0c1b1a896f Update CHANGELOG [ci skip]. 2016-05-05 17:23:19 -03:00
Lucas Mazza
db8e247aa5 Document reload_routes on the app file template. 2016-05-05 17:23:05 -03:00
Lucas Mazza
e01fdba557 Merge pull request #4053 from sidonath/make-route-reloading-configurable
Make reloading of routes optional
2016-05-05 17:18:43 -03:00
Lucas Mazza
0a1e55f11c Update CHANGELOG [ci skip]. 2016-05-05 17:17:48 -03:00
Matt Yanchek
85bcbdf18b Set minimum password length for edit and new views (#4068)
* Set minimum password length for edit and new views

* Update edit.html.erb

* Update registerable_test.rb
2016-05-05 17:16:41 -03:00
Lucas Mazza
a45c4c0ac4 Update CHANGELOG.md. 2016-05-05 17:14:27 -03:00
Lucas Mazza
d293e00ef5 Merge pull request #4083 from plataformatec/lm-rm-deprecations
Remove deprecated APIs
2016-05-05 17:07:53 -03:00
Lucas Mazza
201a4f92c2 Remove deprecated Devise::Models::Recoverable#after_password_reset method. 2016-05-03 18:33:08 -03:00
Lucas Mazza
71f90c0d6e Remove deprecated Devise::Models::Recoverable#reset_password! method. 2016-05-03 18:33:08 -03:00
Lucas Mazza
26e22d8e95 Remove deprecated Devise::Models::Confirmable#confirm! method. 2016-05-03 18:33:08 -03:00
Lucas Mazza
9805728964 Remove deprecated Devise.bcrypt method. 2016-05-03 18:32:56 -03:00
Lucas Mazza
f64022a57b Remove deprecated OmniAuth URL helpers. 2016-05-03 18:32:56 -03:00
Lucas Mazza
e79201aef8 Remove deprecated ParameterSanitizer API. 2016-05-03 18:32:47 -03:00
Lucas Mazza
a2498074f1 Replace custom Array assertion with assert_equal. 2016-05-03 14:18:35 -03:00
Lucas Mazza
536279b05b Replace homemade assert_not matcher in favor of refute. 2016-05-03 13:57:10 -03:00
Lucas Mazza
031351224a Remove usage of ActiveSupport::Dependencies 3.x API. 2016-05-03 13:52:33 -03:00
Lucas Mazza
74ab3e9a05 Remove references to ActiveSupport::OrderedHash.
We no longer support legacy rubies where hashes aren't ordered, so we don't need
to use this class for it.
2016-05-03 13:48:42 -03:00
Ulisses Almeida
1bc9ebd7de Release 4.1.0 2016-05-02 23:51:49 -03:00
Ulisses Almeida
81869de9c5 Only set raise_in_transactional_callbacks for Rails 4.2
* Only set for active record orm.
* Only set for Rails versions that supports the config.
2016-05-02 23:22:51 -03:00
Ulisses Almeida
f6301c08f6 Add raise_in_transactional_callbacks to true
Using a rails app without this config generates a rails
warning, since it will be the new default. Let's udpate it.
2016-05-02 22:41:51 -03:00
Ulisses Almeida
d66d9297fb 📝 Update the CHANGELOG 2016-05-02 22:34:07 -03:00
ALLEN WANG QIANG
78bbf6dcc4 Send on create confirmation email after commit (#4064)
Call send_on_create_confirmation_instructions in after_commit instead of after_create, I think this is no harm in general and it makes things like async job work.

Fix #4062
2016-05-02 21:32:14 -03:00
Ulisses Almeida
1ff64fbbd3 Merge pull request #4076 from f3ndot/issue-4072-unlock-strategy-enabled-bug
Fix strategy checking in #unlock_strategy_enabled? for :none and undefined strategies
2016-05-02 21:28:49 -03:00
Justin Bull
3226ab16c1 Extract list of both strategies into class constant 2016-05-02 14:22:09 -04:00
Lucas Mazza
13285d7ef3 Remove a few Ruby syntax warnings from the test suite. 2016-05-02 10:47:05 -03:00
Justin Bull
7346ce709a 🪲 Fix strategy checking in #unlock_strategy_enabled? for :none and undefined strategies
A bug that if the unlock strategy was set to `:both`, it would return true for all & any inputs

See #4072
2016-05-01 13:56:12 -04:00
Ulisses Almeida
8ac32f14b1 Merge pull request #4061 from plataformatec/ua-remove-config-deprecations
Set the new defaults for Devise 4.1

In our configuration template we explicit set some configurations as recommended defaults.
Now we are enforcing these configurations to be the defaults.
It also removes all warning code about this change.
2016-05-01 13:12:21 -03:00
Ulisses Almeida
91ef42dc0a Remove remaining code of setup deprecation warning
Since all configurations are using the current
recomended defaults. We can remove this deprecation
warning for Devise 4.1.
2016-05-01 12:44:40 -03:00
Ulisses Almeida
1ddca80cee Set the new default of sign_out_via config 2016-05-01 12:44:40 -03:00
Ulisses Almeida
896521be73 Se the new default for skip_session_storage config 2016-05-01 12:44:40 -03:00
Ulisses Almeida
6e419ce821 Set the new default for reconfirmable config 2016-05-01 12:44:40 -03:00
Ulisses Almeida
93df02f601 Set the new default for strip_whitespace_keys config 2016-05-01 12:44:40 -03:00
José Valim
fdd9337b64 Merge pull request #4066 from sbc100/friendly_token
Friendly token
2016-04-30 10:03:04 +02:00
Lucas Mazza
2040b021e1 Extend the deprecation horizon for the ParameterSanitizer and the OmniAuth helpers. 2016-04-29 16:20:01 -03:00
Sam Clegg
d122faf410 Use friendly_token over token_generator when only raw value is needed
The first value returned by token_generator.generate is
simply the return value of friendly_token so this code should
be equivalent.

The use of token_generator here dates back to when the
confirmation_token was stored as a digest, but that is no
longer true.
2016-04-27 10:44:15 -04:00
Sam Clegg
eaa4713e22 Consistent use of save method 2016-04-26 15:16:13 -04:00
Ulisses Almeida
0c1a14e8f2 📝 Update the CHANGELOG 2016-04-26 11:32:15 -03:00
byzg
357ce9c3b5 Humanize authentication keys in failure flash message (#4014)
Humanize and translates the authentication keys in failure flash message.
2016-04-26 11:17:03 -03:00
kimgb
830d3e86ee updated email_regexp and added test cases (#4001)
Add a more permissive default e-mail regex.
2016-04-26 11:13:07 -03:00
Philipe Fatio
209b97d86b Remove upgrade path for old session format (#4032)
This removes an upgrade path that migrated the old serialization format
to the new one introduced. This was introduced in c22d755 (#2300)
3 years ago and should no longer be needed.
2016-04-26 11:10:55 -03:00
Ulisses Almeida
4da955d9cd Release 4.0.1 2016-04-25 17:06:05 -03:00
Ulisses Almeida
bff701758a Merge pull request #4043 from lmduc/master
Send confirmation instructions when a user updates the email address from nil
2016-04-25 16:42:55 -03:00
Ulisses Almeida
90acc6fc23 Change the check for permit! method
We are using the `permit!` method, we should check
for `permit!`.
2016-04-22 20:36:55 -03:00
Damir Zekic
eba2527b8e Make reloading of routes optional
As has been seen in a previous pull request, some applications require
routes to be loaded before the code is eagerly loaded, which implies
that all Rails applications using Devise need to have routes reloaded
twice:
https://github.com/plataformatec/devise/pull/3241

This can incur a very significant slowdown for large apps that have a
lot of routes or a lot of controllers, so reloading should be optional.
2016-04-21 00:10:17 -03:00
Ulisses Almeida
48220f087b Merge pull request #4050 from cadejscroggins/master
Make sure attribute_will_change! method exists before calling it
2016-04-20 23:10:25 -03:00
Cade Scroggins
26b17abb01 Remove attribute_will_change! method as it is unnecessary 2016-04-20 20:23:03 -05:00
Lucas Mazza
22468f3756 Merge pull request #3855 from joshsoftware/mongoid_dep
Upgrade Mongoid to 5.0
2016-04-19 10:14:26 -03:00
Yogesh Khater
9696d83e7d Upgrade Mongoid to 5.0 2016-04-19 17:18:40 +05:30
Lucas Mazza
940ca4f2b8 Release 4.0.0. version. 2016-04-18 11:52:49 -03:00
Ulisses Almeida
f38250245f 📝 Update CHANGELOG 2016-04-18 11:46:29 -03:00
Ulisses Almeida
4c7c27f73e Merge pull request #4044 from plataformatec/ua-remember-me
Remove deprecated argument of `remember_me!`
2016-04-18 11:45:46 -03:00
Ulisses Almeida
7a235849cf Remove deprecated argument of remember_me! 2016-04-18 11:14:01 -03:00
Ulisses Almeida
846ba80480 Merge pull request #4039 from plataformatec/ua-fix-remember-me
Fix extented remember me
2016-04-18 11:07:02 -03:00
Ulisses Almeida
93d98b6450 Merge pull request #4036 from plataformatec/ua-defaults-review
Add warning about default config change
2016-04-18 11:06:32 -03:00
MatBi
7d10019d2a Should check email present 2016-04-18 19:52:31 +08:00
MatBi
274f8f2f87 Should send confirmation instructions after changing email from nil 2016-04-18 19:35:56 +08:00
MatBi
3360b10c2f Skip reconfirmation in case that a record is created with #save called in callback 2016-04-18 19:32:54 +08:00
MatBi
6f9561e64f Refactor a test 2016-04-18 18:30:20 +08:00
MatBi
016b216d95 Change the name of variables to keep the tests consistent 2016-04-18 18:15:32 +08:00
Ulisses Almeida
164134c78a Add warning about default config change
This change add warnings for these configurations:

* strip_whitespace_keys - It is already explicit on config template, now
it will be the same of the template.
* email_regexp - In the new version this regexp will be more
permissive.
* reconfirmable - It is already explicit on config template, now
it will be the same of the template.
* skip_session_storage - It is already explicit on config template, now
it will be the same of the template.
* sign_out_via - It is already explicit on config template, now
it will be the same of the template.

These ones is important to change, since the configuration says current
explicit value are the default. It can lead to misunderstanging if users
remove the explicit configuration.

It also updates the template explicit values:

* Warns the `config.mailer_sender` is nil by default
* Update `config.password_length` to use the current default
* Make the e-mail configuration explicit
2016-04-15 20:31:54 -03:00
Ulisses Almeida
4a4b5ba196 Fix remember me always extending the period
Now the config `extend_remember_period` is used to:

`true` - Every time the user authentication is validated, the
cookie expiration is updated.
`false` - Does not updates the cookie expiration.

Closes #3994
2016-04-15 20:28:46 -03:00
Lucas Mazza
c87d8fda82 Merge pull request #4041 from plataformatec/ua-fix-rails5-build
Fix Rails 5 build
2016-04-15 17:50:04 -03:00
Ulisses Almeida
48af3e8249 Fix Rails 5 build
With this [PR](https://github.com/rails/activemodel-serializers-xml/pull/8)
of activemodel-serializers bundle will require it by default.
2016-04-15 16:57:35 -03:00
Ulisses Almeida
57d150e535 Merge pull request #4031 from tomkadwill/readme_changes
Update README
2016-04-12 11:26:47 -03:00
Carlos Antonio da Silva
d9f97fc9a4 Merge pull request #4035 from bogdanvlviv/deprecated
fix method name for File
2016-04-12 07:40:29 -03:00
Tom Kadwill
9cdf7860d5 Update README 2016-04-12 09:22:16 +01:00
bogdanvlviv
0f11c0f6b3 fix method name for File 2016-04-12 09:03:54 +03:00
Ulisses Almeida
9914ff32ec Merge pull request #4004 from bogdanvlviv/patch-4
removed deprecated private method Devise::Controllers::Helpers#expire_session_data_after_sign_in!
2016-04-11 16:30:36 -03:00
Lucas Mazza
728bf0c956 Merge pull request #4033 from codeodor/patch-2
Note change to Rails 5 that affects Devise example
2016-04-10 18:49:30 -03:00
Sammy Larbi
c520e93733 Note change to Rails 5 that affects Devise example
[A change in Rails 5](3979403781) left me hunting for hours on why I could no longer log in to my application. To save others the trouble, I thought it would be nice to note it in the README.
2016-04-09 17:55:20 -05:00
Ulisses Almeida
b397d33246 Merge pull request #4005 from bogdanvlviv/dependencies
change rails version from 4.2.5 to 4.2.6
2016-04-08 17:04:02 -03:00
Bogdan
aa25e2080e removed deprecated private method Devise::Controllers::Helpers#expire_session_data_after_sign_in! 2016-03-30 18:10:16 +03:00
Carlos Antonio da Silva
2b3799e6ce Merge pull request #4010 from bogdanvlviv/patch-5
Update .travis.yml
2016-03-26 09:22:33 -03:00
Bogdan
2af3a83ef4 Update .travis.yml 2016-03-26 03:48:33 +02:00
bogdanvlviv
c3c2438c9c change rails version from 4.2.5 to 4.2.6 2016-03-23 21:21:58 +02:00
Lucas Mazza
69bee06cee Merge pull request #3993 from totothink/master
unified use pending_reconfirmation? method
2016-03-12 14:34:21 -03:00
aaron
c70eb0a5a8 unified use pending_reconfirmation? method 2016-03-12 07:10:20 +08:00
Lucas Mazza
db901399f2 Fix Symbol syntax no deprecation message. 2016-03-09 15:59:00 -03:00
Lucas Mazza
d0e5a1d252 Update CHANGELOG [ci skip] 2016-03-09 11:34:14 -03:00
Lucas Mazza
ccda4692b4 Add a bin/test executable to use Rails 5 Minitest report. 2016-03-09 11:16:21 -03:00
Lucas Mazza
e6563bc4cb Update Gemfile's dependencies. 2016-03-09 11:13:04 -03:00
Lucas Mazza
1c2328bb90 Prep for 4.0.0.rc2 release. 2016-03-09 11:01:50 -03:00
Lucas Mazza
9ec126bd8b Update CHANGELOG [ci skip] 2016-03-09 11:00:04 -03:00
Lucas Mazza
b3cc3db49e Merge pull request #3991 from plataformatec/lm-deprecate-old-omniauth-helpers
Deprecate legacy OmniAuth URL helpers.
2016-03-09 10:55:33 -03:00
Lucas Mazza
5b1182460c Deprecate legacy OmniAuth URL helpers. 2016-03-09 10:36:39 -03:00
Lucas Mazza
76f76249e7 Merge pull request #3985 from plataformatec/lm-omniauth-route-helpers
Do not use the dynamic `:action` segment on Omniauth routes.
2016-03-07 11:50:35 -03:00
Lucas Mazza
353b14f473 Use versioned migrations when possible
Rails 5 deprecates inheriting directly from `ActiveRecord::Migration` in
favor of inheriting from `ActiveRecord::Migration[5.0]` where `5.0` is
the `major.minor` version of Rails that the migration was originally
written to support.

h/t to b0ce189c69.
2016-03-07 11:38:37 -03:00
Lucas Mazza
ec07bdb315 Do not use the dynamic :action segment on Omniauth routes.
This was deprecated on rails/rails#23980.

We now generate scope and provider specific routes, like `user_facebook_omniauth_callback`
or `user_github_omniauth_callback`.

We could deprecate the `omniauth_authorize_path` in favor of the generated routes, but
the `shared/links.html.erb` depends on it to generate all omniauth links at once.

Closes #3983.
2016-03-07 11:19:27 -03:00
José Valim
9ece7da447 Merge pull request #3984 from jeroenvisser101/remove-trailing-whitespace-from-view
Remove trailing whitespace from confirmation view
2016-03-07 13:08:53 +01:00
Jeroen Visser
b214333760 Remove trailing whitespace from confirmation view
Though not a real issue, it was highlighted as an error by my commit
hooks, so I took the opportunity to fix it.
2016-03-07 10:07:34 +01:00
Vasiliy Ermolovich
3423043759 Merge pull request #3961 from anthonyto/clarify_confirmation_comments
Clarify allow_unconfirmed_access_for comments in confirmation module
2016-02-18 09:54:06 +03:00
Anthony To
8c636ef08a Clarify allow_unconfirmed_access_for comments in confirmation module 2016-02-18 13:35:13 +11:00
Lucas Mazza
a9b94f5eb9 Update CHANGELOG. 2016-02-15 10:19:08 -02:00
Lucas Mazza
c228227bc1 Tweak no ORM check on InstallGenerator.
* Expand the explanation of why it fail.
* Raise a subclass of `Thor::Error` so the Thor doesn't output the exception
  backtrace as it isn't useful for developers facing this error.
2016-02-15 10:16:43 -02:00
José Valim
0c46373c20 Merge pull request #3954 from arjunsharma/master
Raise error if no ORM is found during install generator
2016-02-14 23:11:05 +01:00
Arjun Sharma
648ed3b412 Raise error if no ORM is found during install generator 2016-02-14 14:59:38 -07:00
Lucas Mazza
cecb3ee45b Merge pull request #3921 from oss92/reduce_complexity
Added DeviseController#set_flash_message!
2016-02-11 14:38:03 -02:00
George Guimarães
4585281da4 Devise is already thread-safe and has been working in production on both YARV and JRuby. 2016-02-11 13:29:42 -02:00
George Guimarães
014859ecff Merge branch 'gg-correct-encryption-meaning' 2016-02-11 13:25:49 -02:00
George Guimarães
1f36946f43 Merge pull request #3941 from SimonDKnight/FixDocumentationTestHelpers
Added clarity to documentation regarding where to place test helpers …
2016-02-10 23:42:19 -02:00
George Guimarães
9efc601c73 Merge branch 'jetheredge-patch-2' 2016-02-10 23:28:13 -02:00
Justin Etheredge
dc7e7d66c9 Increase default stretches to 11 2016-02-10 23:27:21 -02:00
oss92
18528650c3 Added DeviseController#set_flash_message! 2016-02-11 02:49:53 +02:00
Simon Knight
a371f03c51 Update README.md
Added formatting to file.
2016-02-10 21:11:57 +00:00
José Valim
f173040222 Merge pull request #3946 from plataformatec/gg-remove-hakiri
Removes Hakiri, since it thinks Devise is a Rails app
2016-02-10 22:06:46 +01:00
George Guimarães
b74235d4a1 Removes Hakiri, since it thinks Devise is a Rails app
I'd like to remove the Hakiri badge from devise's README.

Since we do check in Gemfile and Gemfile.lock for development
and testing purposes (contrary to the popular belief that gems
don't need those files), Hakiri thinks Devise is a Rails app,
instead of a library/gem.

Depending on the Rails version that is locked in Gemfile.lock,
Hakiri will show several CVEs for Rails. But our Travis pipeline
builds against several Rails' branches, all of them updated.

And it is up to the developers using Devise to update
Rails in their apps.

Those warnings (Rails CVEs) don't make sense for devise.
2016-02-10 18:43:33 -02:00
George Guimarães
4b8ea5d0f0 Updates the development/testing dependencies 2016-02-10 18:37:16 -02:00
George Guimarães
79e861b52b Reorder travis builds to prioritize newer ruby and rails versions 2016-02-10 17:20:36 -02:00
George Guimarães
c4b4411513 Change encryption for hashing in the documentation.
Throughout the documentations, we are using 'encrypt' incorrectly.
Encrypt means that someone will eventually decrypt the message,
which is obviously not the case for Devise.

I'm changing the docs to use 'hashing' instead.

However, I left the database field as `encrypted_password` for now.
I'll update the db field in an upcoming PR.
2016-02-10 17:10:52 -02:00
Lucas Mazza
7b33a8ef57 Merge pull request #3931 from giantmonkey/fix-spelling-of-verb-set-up
Spell verb *set up* with a space
2016-02-10 17:06:38 -02:00
Simon Knight
1dd315ce1d Added clarity to documentation regarding where to place test helpers for functional tests 2016-02-09 13:29:42 +00:00
José Valim
7c75ebe672 Merge pull request #3936 from bogdanvlviv/patch-3
Update confirmable_test.rb
2016-02-06 20:11:11 +01:00
bogdanvlviv
d9481ff9b8 Update confirmable_test.rb 2016-02-06 20:37:31 +02:00
Carlos Antonio da Silva
f0c39e08ca Merge pull request #3934 from bogdanvlviv/patch-2
change call deprecated method confirm! to confirm in test
2016-02-03 18:15:39 -02:00
Bogdan
d3fa53151a change call deprecated method confirm! to confirm in test 2016-02-03 22:09:38 +02:00
Paul Menzel
f2d7b8f740 Spell verb *set up* with a space
The verb *set up* is spelled with a space [1].

```
$ git grep -l 'to setup' | xargs sed -i 's/to setup/to set up/g'
$ git grep -l '# Setup' | xargs sed -i 's/# Setup/# Set up/g'
$ git grep -l "test 'setup" | xargs sed -i "s/test 'setup/test 'set up/g"
```

Revert the change for *setup block yields self*.

Change the rest manually.

[1] http://www.merriam-webster.com/dictionary/set%20up
2016-02-02 19:09:19 +01:00
Lucas Mazza
beb8cc8e0b Test against Rails 5 beta 2. 2016-02-02 14:28:34 -02:00
Lucas Mazza
17d6a74909 oauth2 1.1.0 is out. 2016-02-01 10:39:10 -02:00
Lucas Mazza
aab7610808 Release 4.0.0.rc1. 2016-02-01 09:20:42 -02:00
Lucas Mazza
8edee143e8 Prep for 4.0.0.rc1 release. 2016-01-31 17:05:16 -02:00
Lucas Mazza
49cf804c62 Merge pull request #3859 from twalpole/unsafe_h
Explicitly permit rather than using to_unsafe_h
2016-01-31 16:56:10 -02:00
Lucas Mazza
8ab738307e Merge pull request #3927 from plataformatec/lm-cookie-fix
Attempt to coerce the `generated_at` cookie to a `Time` object.
2016-01-31 16:23:31 -02:00
Carlos Antonio da Silva
9d9adc73cd Merge pull request #3928 from gfvcastro/remove-optional-parenthesis
Remove optional parenthesis.
2016-01-30 18:08:50 -02:00
Gustavo Villa
91f93b38ee Remove optional parenthesis. 2016-01-30 14:20:32 -03:00
Lucas Mazza
7bff3be869 Attempt to coerce the generated_at cookie to a Time object.
Time objects aren't properly coerced back when using the JSON cookie serialization,
so we need to do it ourselves.

To avoid any new JSON serialization issues, we now store the `generated_at` as
an String with the timestamp seconds + miliseconds in the cookie but still the
previous JSON encoded format.

Thanks to @boblail at https://github.com/plataformatec/devise/pull/3917 for the
initial patch.
2016-01-29 18:04:16 -02:00
Lucas Mazza
475599d4ab Merge pull request #3926 from schneems/schneems/fix-version
[close 3925] Fix version for older Bundler compat
2016-01-29 14:57:42 -02:00
schneems
7d81731d4f [close 3925] Fix version for older Bundler compat 2016-01-29 10:56:13 -06:00
Lucas Mazza
ffe9d6d406 Fix Symbol syntax on ParameterSanitizer deprecation message. 2016-01-28 11:10:15 -02:00
Lucas Mazza
cf7c9be6b4 Merge pull request #3919 from twalpole/gemfiles
switch to oauth2 home repository
2016-01-27 15:58:57 -02:00
Thomas Walpole
3e80c9a80f switch to oauth2 home repository 2016-01-27 09:03:01 -08:00
Lucas Mazza
c6cf035037 Merge pull request #3918 from plataformatec/lm-serialized_in_cookie
Refactor `Rememberable#serialized_in_cookie?` to split class/instance API
2016-01-27 14:44:12 -02:00
Lucas Mazza
6008885152 Refactor Rememberable.serialized_in_cookie? to split class/instance API.
We now expose a `remember_me?` instance method as internal API for the controller
layer check if the remember me cookie is still valid.
2016-01-27 14:11:26 -02:00
Lucas Mazza
0c7f8764c9 Bump Gemfile dependencies. 2016-01-27 13:52:37 -02:00
José Valim
d1d8c2f03d Ensure generated_at is a Time
Signed-off-by: José Valim <jose.valim@plataformatec.com.br>
2016-01-25 11:17:18 +01:00
José Valim
b97b3e6e3b Do not timeout if remember me is enabled
Signed-off-by: José Valim <jose.valim@plataformatec.com.br>
2016-01-22 16:19:10 +01:00
Lucas Mazza
cc02d06c58 Remove Rails 3.2 compatibility fix. 2016-01-18 13:59:27 -02:00
Lucas Mazza
b91bbb1590 Tweak ParameterSanitizer exception/deprecation messages. 2016-01-18 13:51:51 -02:00
José Valim
52b1ca2d80 Bump to dev version 2016-01-18 15:22:00 +01:00
José Valim
4ec7dc0f27 Store creation timestamp on remember cookies
Signed-off-by: José Valim <jose.valim@plataformatec.com.br>
2016-01-18 15:17:25 +01:00
Lucas Mazza
0a4da78b22 Add a notice to README regarding the sanitizer API change. 2016-01-17 12:53:31 -02:00
José Valim
aa3f64976f Merge pull request #3898 from kulte/master
Consistent formatting of file arguments to autoload
2016-01-13 23:10:38 +01:00
Zachary Friedman
260fa1a2e2 It would appear that consistency with the indentation used in the top-level Devise module would dictate this formatting change 2016-01-13 14:03:21 -08:00
José Valim
a321282ccc Merge pull request #3893 from retrospective5/updated-readme
Add link to devise_for documentation
2016-01-07 22:37:30 +01:00
araa
6f91baf99c Add link to devise_for documentation 2016-01-07 14:37:02 -05:00
José Valim
1a7f2195a2 Merge pull request #3891 from obduk/parent_mailer
Add parent_mailer to lib/generators/templates/devise.rb
2016-01-06 14:08:26 +01:00
Owen Davies
e5797001a7 Add parent_mailer to lib/generators/templates/devise.rb 2016-01-06 13:00:54 +00:00
Lucas Mazza
f0b937c538 Test against Ruby 2.3.0. 2016-01-05 14:48:10 -02:00
Carlos Antonio da Silva
9639bf8cc1 Merge pull request #3883 from Atul9/master
Update copyright notices to 2016 [ci skip]
2016-01-04 10:42:13 -02:00
José Valim
27e1588685 Merge pull request #3885 from dcmorse/master
Documentation clarification to README.md
2016-01-04 09:59:23 +01:00
Dave Morse
42fac75e8e Clarify previous clarification to README.md 2016-01-03 17:06:34 -05:00
Dave Morse
37b7e9b850 README.md: clarified how to include Devise::TestHelpers for :view tests.
Also clarified that including Devise::TestHelpers during integration tests is a mistake.
source: https://github.com/plataformatec/devise/issues/3881
2016-01-03 16:50:47 -05:00
Atul Bhosale
48e26c5d0a Update copyright notices to 2016 [ci skip] 2016-01-03 15:58:16 +05:30
Lucas Mazza
1d77099861 Merge pull request #3875 from james/master
Update controller generator templates for new ParameterSanitizer syntax
2015-12-27 22:53:01 -02:00
James Darling
924a989f37 Update controller generator templates for new ParameterSanitizer syntax
Devise::ParameterSanitizer has a new syntax for permitting additional
attributes to a model. This commit updates the generated controllers to
reflect that.
2015-12-28 00:45:03 +00:00
Lucas Mazza
6431445846 Cast the result of deperecated sanitization calls to a HWIA as well. 2015-12-21 09:57:20 -02:00
Lucas Mazza
8d57a54b2d ✂️ Remove custom Travis cache scripts. 2015-12-21 09:46:11 -02:00
Lucas Mazza
280d12b81c Merge pull request #3856 from plataformatec/lm-sanitizer-cleanup
Remove `ParametersSanitizer` inheritance.
2015-12-21 09:40:59 -02:00
Lucas Mazza
00a0b8e516 Fix duplicated exclude entry. 2015-12-20 23:02:52 -02:00
Lucas Mazza
238ccb15b5 Test against the beta Rails release. 2015-12-20 22:56:13 -02:00
Lucas Mazza
ace7b55a1a Merge pull request #3868 from twalpole/gemfile_update
update rails 5 gemfile with compatbile gem releases
2015-12-20 21:03:06 -02:00
Thomas Walpole
97ab41728e update rails 5 gemfile with compatbile gem releases 2015-12-20 12:31:51 -08:00
Lucas Mazza
acd9f84802 Merge pull request #3866 from plataformatec/lm-remove-key-generator
Remove `KeyGenerator` implementation ported from Rails 4.x.
2015-12-18 15:18:15 -02:00
Lucas Mazza
a24ecc65f5 Remove KeyGenerator implementation ported from Rails 4.x. 2015-12-18 14:49:50 -02:00
Lucas Mazza
4e45a5fde4 Remove Rails version mention from the initializer template. 2015-12-18 14:47:32 -02:00
Lucas Mazza
9499736593 Remove safeguard against a previously broken NullSessionHash#reset_session.
This behavior was fixed on https://github.com/rails/rails/pull/12279.
2015-12-18 14:47:32 -02:00
Lucas Mazza
df8b48646b Remove ParametersSanitizer inheritance.
We no longer need to support the `BaseSanitizer` implementation for apps without
the Strong Parameters API, and this section is lacking a minimal set of
docs to document the expected behavior besides the `README` section.
2015-12-18 11:39:03 -02:00
Lucas Mazza
b4904a4ba2 Merge pull request #3865 from djsegal/rails5
Add #3732 helper logic to devise controller
2015-12-18 10:53:14 -02:00
djsegal
2006f87b58 Add #3732 helper logic to devise controller: #3864 2015-12-18 04:05:30 -05:00
Thomas Walpole
5d9f6d892f Explicitly permit rather than using to_unsafe_h 2015-12-16 14:14:15 -08:00
Lucas Mazza
1ac4bdd090 Merge pull request #3857 from twalpole/test_fix
Fix Rails 5 test
2015-12-16 10:01:18 -02:00
Thomas Walpole
302c4e43bd fix Rails 5 test 2015-12-15 10:32:24 -08:00
Lucas Mazza
f5926f6514 Do not send Travis notifications of Pull Requests. 2015-12-15 15:26:08 -02:00
Lucas Mazza
330e0f7165 Update lockfile. 2015-12-15 14:55:36 -02:00
Lucas Mazza
42376db763 Update Devise version on README [ci skip] 2015-12-15 11:52:26 -02:00
Lucas Mazza
1147badf7c Update Rails dependency contrainst to support the stable 5.0.0 release. 2015-12-15 11:49:44 -02:00
Lucas Mazza
7b000390ac Update CHANGELOG.md [ci skip] 2015-12-15 11:48:41 -02:00
Lucas Mazza
dd5de829c9 Merge pull request #3714 from twalpole/rails5
Rails 5 Support
2015-12-15 11:44:01 -02:00
Lucas Mazza
2f7834245b Merge pull request #3835 from kv109/master
test for save in after_create hook breaks devise confirmation [3787]
2015-12-15 11:36:47 -02:00
Lucas Mazza
78d2654fb4 Merge pull request #3793 from chrismacias/save_in_after_create_hook_breaks_devise_confirmation
save in after_create hook breaks devise confirmation
2015-12-15 11:36:34 -02:00
José Valim
934dbd1f5a Merge pull request #3854 from joshsoftware/reset_password_token_issue
Comparing times in UTC
2015-12-15 11:55:24 +01:00
Siva Gollapalli
23933d2fb0 FIX# Comparing times in UTC 2015-12-15 15:17:11 +05:30
José Valim
76bbbb8ed5 Merge pull request #3853 from betesh/betesh-patch-1
Removed unnecessary module fixes #3852
2015-12-15 09:35:12 +01:00
betesh
8701a88c94 Removed unnecessary module 2015-12-15 02:52:17 -05:00
Thomas Walpole
2024fca4df Rails 5 compatability. Remove rails < 4.1 and Ruby < 2.1 2015-12-11 09:47:30 -08:00
Kacper Walanus
a0cd4655ba test for save in after_create hook breaks devise confirmation [3787] 2015-11-24 01:54:03 +01:00
Christian Macias
54bb30a1a4 changed email_was !='' to email_was.present? 2015-10-26 08:56:14 -07:00
Christian Macias
5ae6360e75 fix for #3787, save in after_create hook breaks devise confirmation 2015-10-22 13:05:02 -07:00
246 changed files with 5583 additions and 3616 deletions

View File

@@ -1,44 +1,89 @@
language: ruby
rvm:
- 1.9.3
- 2.0.0
- 2.1
- 2.2
- 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-stable
- gemfiles/Gemfile.rails-5.2-stable
- gemfiles/Gemfile.rails-5.0-stable
- gemfiles/Gemfile.rails-4.2-stable
- gemfiles/Gemfile.rails-4.1-stable
- gemfiles/Gemfile.rails-4.0-stable
- gemfiles/Gemfile.rails-3.2-stable
- Gemfile
matrix:
exclude:
- rvm: 2.2
gemfile: gemfiles/Gemfile.rails-3.2-stable
- rvm: 2.1.10
gemfile: Gemfile
- rvm: 2.1.10
gemfile: gemfiles/Gemfile.rails-6.0-stable
- rvm: 2.1.10
gemfile: gemfiles/Gemfile.rails-5.2-stable
- rvm: 2.1.10
gemfile: gemfiles/Gemfile.rails-5.0-stable
- rvm: 2.2.10
gemfile: Gemfile
- rvm: 2.2.10
gemfile: gemfiles/Gemfile.rails-6.0-stable
- rvm: 2.2.10
gemfile: gemfiles/Gemfile.rails-5.2-stable
- rvm: 2.3.8
gemfile: gemfiles/Gemfile.rails-6.0-stable
- rvm: 2.4.5
gemfile: gemfiles/Gemfile.rails-4.1-stable
- rvm: 2.4.5
gemfile: gemfiles/Gemfile.rails-6.0-stable
- 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-stable
allow_failures:
- rvm: ruby-head
- gemfile: gemfiles/Gemfile.rails-6.0-stable
services:
- mongodb
sudo: false
cache: bundler
env:
matrix:
- DEVISE_ORM=mongoid
- DEVISE_ORM=active_record
- DEVISE_ORM=mongoid
before_install: "rm ${BUNDLE_GEMFILE}.lock"
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: "bundle exec rake test"
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=

File diff suppressed because it is too large Load Diff

View File

@@ -1,16 +1,79 @@
### Please read before contributing
# How to contribute to Devise
1) Do not post questions in the issues tracker. If you have any questions about Devise, search the [Wiki](https://github.com/plataformatec/devise/wiki) or use the [Mailing List](https://groups.google.com/group/plataformatec-devise) or [Stack Overflow](http://stackoverflow.com/questions/tagged/devise).
Thanks for your interest on contributing to Devise! Here are a few general
guidelines on contributing and reporting bugs to Devise that we ask you to
take a look first. Notice that all of your interactions in the project are
expected to follow our [Code of Conduct](CODE_OF_CONDUCT.md).
2) If you find a security bug, **DO NOT** submit an issue here. Please send an e-mail to [opensource@plataformatec.com.br](mailto:opensource@plataformatec.com.br) instead.
## Reporting Issues
3) Do a small search on the issues tracker before submitting your issue to see if it was already reported / fixed.
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).
4) When reporting an issue, include Rails, Devise and Warden versions. If you are getting exceptions, please include the full backtrace.
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
even better a **sample Rails app that replicates the issue** - Devise has a lot
of moving parts and it's functionality can be affected by third party gems, so
we need as much context and details as possible to identify what might be broken
for you. We have a [test case template](guides/bug_report_templates/integration_test.rb)
that can be used to replicate issues with minimal setup.
5) Notice that all of your interactions in the project are expected to follow our [Code of Conduct](CODE_OF_CONDUCT.md)
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
internationalization.
That's it! The more information you give, the easier it becomes for us to track it down and fix it.
Ideally, you should provide an application that reproduces the error or a test case to Devise's suite.
Avoid opening new issues to ask questions in our issues tracker. Please go through
the project wiki, documentation and source code first, or try to ask your question
on [Stack Overflow](http://stackoverflow.com/questions/tagged/devise).
Thanks!
**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)
instead.**
## Sending Pull Requests
Before sending a new Pull Request, take a look on existing Pull Requests and Issues
to see if the proposed change or fix has been discussed in the past, or if the
change was already implemented but not yet released.
We expect new Pull Requests to include enough tests for new or changed behavior,
and we aim to maintain everything as most backwards compatible as possible,
reserving breaking changes to be ship in major releases when necessary - you
can wrap the new code path with a setting toggle from the `Devise` module defined
as `false` by default to require developers to opt-in for the new behavior.
If your Pull Request includes new or changed behavior, be sure that the changes
are beneficial to a wide range of use cases or it's an application specific change
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
to the new setting.
We also welcome Pull Requests that improve our existing documentation (both our
`README.md` and the RDoc sections in the source code) or improve existing rough
edges in our API that might be blocking existing integrations or 3rd party gems.
## Other ways to contribute
We welcome anyone that wants to contribute to Devise to triage and reply to
open issues to help troubleshoot and fix existing bugs on Devise. Here is what
you can do:
* Help ensure that existing issues follows the recommendations from the
_[Reporting Issues](#reporting-issues)_ section, providing feedback to the issue's
author on what might be missing.
* Review and update the existing content of our [Wiki](https://github.com/plataformatec/devise/wiki)
with up to date instructions and code samples - the wiki was grown with several
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
familiar with feel free to update it as necessary.
* Review existing Pull Requests, and testing patches against real existing
applications that use Devise.
Thanks again for your interest on contributing to the project!
:heart:

27
Gemfile
View File

@@ -1,15 +1,25 @@
# frozen_string_literal: true
source "https://rubygems.org"
gemspec
gem "rails", "4.2.2"
gem "omniauth", "~> 1.2.0"
gem "omniauth-oauth2", "~> 1.1.0"
gem "rails", "~> 5.2"
gem "omniauth", "~> 1.3"
gem "oauth2"
gem "omniauth-oauth2"
gem "rdoc"
gem "activemodel-serializers-xml", github: "rails/activemodel-serializers-xml"
gem "rails-controller-testing"
gem "responders", "~> 2.4"
group :test do
gem "omniauth-facebook"
gem "omniauth-openid", "~> 1.0.1"
gem "omniauth-openid"
gem "timecop"
gem "webrat", "0.7.3", require: false
gem "mocha", "~> 1.1", require: false
end
@@ -21,9 +31,10 @@ platforms :jruby do
end
platforms :ruby do
gem "sqlite3"
gem "sqlite3", "~> 1.3.6"
end
group :mongoid do
gem "mongoid", "~> 4.0"
end
# TODO:
# group :mongoid do
# gem "mongoid", "~> 4.0.0"
# end

View File

@@ -1,183 +1,204 @@
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 (3.5.3)
devise (4.7.1)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 3.2.6, < 5)
railties (>= 4.1.0)
responders
thread_safe (~> 0.1)
warden (~> 1.2.3)
GEM
remote: https://rubygems.org/
specs:
actionmailer (4.2.2)
actionpack (= 4.2.2)
actionview (= 4.2.2)
activejob (= 4.2.2)
actioncable (5.2.0)
actionpack (= 5.2.0)
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 (~> 1.0, >= 1.0.5)
actionpack (4.2.2)
actionview (= 4.2.2)
activesupport (= 4.2.2)
rack (~> 1.6)
rack-test (~> 0.6.2)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.1)
actionview (4.2.2)
activesupport (= 4.2.2)
rails-dom-testing (~> 2.0)
actionpack (5.2.0)
actionview (= 5.2.0)
activesupport (= 5.2.0)
rack (~> 2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.2.0)
activesupport (= 5.2.0)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.1)
activejob (4.2.2)
activesupport (= 4.2.2)
globalid (>= 0.3.0)
activemodel (4.2.2)
activesupport (= 4.2.2)
builder (~> 3.1)
activerecord (4.2.2)
activemodel (= 4.2.2)
activesupport (= 4.2.2)
arel (~> 6.0)
activesupport (4.2.2)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.2.0)
activesupport (= 5.2.0)
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)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
arel (6.0.0)
bcrypt (3.1.10)
bson (3.1.2)
builder (3.2.2)
connection_pool (2.2.0)
erubis (2.7.0)
faraday (0.9.1)
arel (9.0.0)
bcrypt (3.1.13)
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.3.5)
activesupport (>= 4.1.0)
hashie (3.4.0)
i18n (0.7.0)
json (1.8.3)
jwt (1.4.1)
loofah (2.0.2)
globalid (0.4.1)
activesupport (>= 4.2.0)
hashie (3.5.7)
i18n (1.0.0)
concurrent-ruby (~> 1.0)
jwt (1.5.6)
loofah (2.2.2)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.6.3)
mime-types (>= 1.16, < 3)
mail (2.7.0)
mini_mime (>= 0.1.1)
marcel (0.3.2)
mimemagic (~> 0.3.2)
metaclass (0.0.4)
mime-types (2.6.1)
mini_portile (0.6.2)
minitest (5.7.0)
mocha (1.1.0)
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)
mongoid (4.0.2)
activemodel (~> 4.0)
moped (~> 2.0.0)
origin (~> 2.1)
tzinfo (>= 0.3.37)
moped (2.0.6)
bson (~> 3.0)
connection_pool (~> 2.0)
optionable (~> 0.2.0)
multi_json (1.11.1)
multi_xml (0.5.5)
multi_json (1.12.1)
multi_xml (0.6.0)
multipart-post (2.0.0)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
oauth2 (0.9.4)
faraday (>= 0.8, < 0.10)
nio4r (2.3.0)
nokogiri (1.8.2)
mini_portile2 (~> 2.3.0)
oauth2 (1.3.1)
faraday (>= 0.8, < 0.12)
jwt (~> 1.0)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (~> 1.2)
omniauth (1.2.2)
hashie (>= 1.2, < 4)
rack (~> 1.0)
omniauth-facebook (1.6.0)
omniauth-oauth2 (~> 1.1)
omniauth-oauth2 (1.1.2)
faraday (>= 0.8, < 0.10)
multi_json (~> 1.3)
oauth2 (~> 0.9.3)
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)
optionable (0.2.0)
origin (2.1.1)
orm_adapter (0.5.0)
rack (1.6.2)
rack (2.0.4)
rack-openid (1.3.1)
rack (>= 1.1.0)
ruby-openid (>= 2.1.8)
rack-test (0.6.3)
rack (>= 1.0)
rails (4.2.2)
actionmailer (= 4.2.2)
actionpack (= 4.2.2)
actionview (= 4.2.2)
activejob (= 4.2.2)
activemodel (= 4.2.2)
activerecord (= 4.2.2)
activesupport (= 4.2.2)
bundler (>= 1.3.0, < 2.0)
railties (= 4.2.2)
sprockets-rails
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.6)
activesupport (>= 4.2.0.beta, < 5.0)
nokogiri (~> 1.6.0)
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.2)
loofah (~> 2.0)
railties (4.2.2)
actionpack (= 4.2.2)
activesupport (= 4.2.2)
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)
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 (10.4.2)
rdoc (4.2.0)
responders (2.1.0)
railties (>= 4.2.0, < 5)
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.2.0)
rack (~> 1.0)
sprockets-rails (2.3.1)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
sqlite3 (1.3.10)
thor (0.19.1)
thread_safe (0.3.5)
tzinfo (1.2.2)
sprockets (3.7.1)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.1)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.3.13)
thor (0.20.0)
thread_safe (0.3.6)
timecop (0.8.1)
tzinfo (1.2.5)
thread_safe (~> 0.1)
warden (1.2.4)
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!
activerecord-jdbc-adapter
activerecord-jdbcsqlite3-adapter
devise!
jruby-openssl
mocha (~> 1.1)
mongoid (~> 4.0)
omniauth (~> 1.2.0)
oauth2
omniauth (~> 1.3)
omniauth-facebook
omniauth-oauth2 (~> 1.1.0)
omniauth-openid (~> 1.0.1)
rails (= 4.2.2)
omniauth-oauth2
omniauth-openid
rails (~> 5.2)
rails-controller-testing
rdoc
sqlite3
responders (~> 2.4)
sqlite3 (~> 1.3.6)
timecop
webrat (= 0.7.3)
BUNDLED WITH
1.10.6
1.17.3

20
ISSUE_TEMPLATE.md Normal file
View File

@@ -0,0 +1,20 @@
## Pre-check
- Do not use the issues tracker for help or support, try Stack Overflow.
- For bugs, do a quick search and make sure the bug has not yet been reported
- If you found a security bug, do not report it through GitHub. Please send an e-mail to opensource@plataformatec.com.br instead.
- Finally, be nice and have fun!
## Environment
- Ruby **[version]**
- Rails **[version]**
- Devise **[version]**
## Current behavior
Include code samples, errors, steps to reproduce the error and stack traces if appropriate.
Will be even more helpful if you provide a sample application or a test case that reproduces the error.
## Expected behavior

View File

@@ -1,4 +1,4 @@
Copyright 2009-2015 Plataformatec. http://plataformatec.com.br
Copyright 2009-2019 Plataformatec. http://plataformatec.com.br
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the

331
README.md
View File

@@ -4,7 +4,6 @@ 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)
[![Security](https://hakiri.io/github/plataformatec/devise/master.svg)](https://hakiri.io/github/plataformatec/devise/master)
This README is [also available in a friendly navigable format](http://devise.plataformatec.com.br/).
@@ -17,18 +16,56 @@ Devise is a flexible authentication solution for Rails based on Warden. It:
It's composed of 10 modules:
* [Database Authenticatable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/DatabaseAuthenticatable): encrypts and stores a password in the database to validate the authenticity of a user while signing in. The authentication can be done both through POST requests or HTTP Basic Authentication.
* [Omniauthable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Omniauthable): adds OmniAuth (https://github.com/intridea/omniauth) support.
* [Confirmable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Confirmable): sends emails with confirmation instructions and verifies whether an account is already confirmed during sign in.
* [Recoverable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Recoverable): resets the user password and sends reset instructions.
* [Registerable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Registerable): handles signing up users through a registration process, also allowing them to edit and destroy their account.
* [Rememberable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Rememberable): manages generating and clearing a token for remembering the user from a saved cookie.
* [Trackable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Trackable): tracks sign in count, timestamps and IP address.
* [Timeoutable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Timeoutable): expires sessions that have not been active in a specified period of time.
* [Validatable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Validatable): provides validations of email and password. It's optional and can be customized, so you're able to define your own validations.
* [Lockable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Lockable): locks an account after a specified number of failed sign-in attempts. Can unlock via email or after a specified time period.
* [Database Authenticatable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/DatabaseAuthenticatable): hashes and stores a password in the database to validate the authenticity of a user while signing in. The authentication can be done both through POST requests or HTTP Basic Authentication.
* [Omniauthable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Omniauthable): adds OmniAuth (https://github.com/omniauth/omniauth) support.
* [Confirmable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Confirmable): sends emails with confirmation instructions and verifies whether an account is already confirmed during sign in.
* [Recoverable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Recoverable): resets the user password and sends reset instructions.
* [Registerable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Registerable): handles signing up users through a registration process, also allowing them to edit and destroy their account.
* [Rememberable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Rememberable): manages generating and clearing a token for remembering the user from a saved cookie.
* [Trackable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Trackable): tracks sign in count, timestamps and IP address.
* [Timeoutable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Timeoutable): expires sessions that have not been active in a specified period of time.
* [Validatable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Validatable): provides validations of email and password. It's optional and can be customized, so you're able to define your own validations.
* [Lockable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Lockable): locks an account after a specified number of failed sign-in attempts. Can unlock via email or after a specified time period.
## Table of Contents
<!-- TOC depthFrom:1 depthTo:6 withLinks:1 orderedList:0 -->
- [Information](#information)
- [The Devise wiki](#the-devise-wiki)
- [Bug reports](#bug-reports)
- [StackOverflow and Mailing List](#stackoverflow-and-mailing-list)
- [RDocs](#rdocs)
- [Example applications](#example-applications)
- [Extensions](#extensions)
- [Contributing](#contributing)
- [Starting with Rails?](#starting-with-rails)
- [Getting started](#getting-started)
- [Controller filters and helpers](#controller-filters-and-helpers)
- [Configuring Models](#configuring-models)
- [Strong Parameters](#strong-parameters)
- [Configuring views](#configuring-views)
- [Configuring controllers](#configuring-controllers)
- [Configuring routes](#configuring-routes)
- [I18n](#i18n)
- [Test helpers](#test-helpers)
- [Controller tests](#controller-tests)
- [Integration tests](#integration-tests)
- [OmniAuth](#omniauth)
- [Configuring multiple models](#configuring-multiple-models)
- [ActiveJob Integration](#activejob-integration)
- [Password reset tokens and Rails logs](#password-reset-tokens-and-rails-logs)
- [Other ORMs](#other-orms)
- [Rails API mode](#rails-api-mode)
- [Additional information](#additional-information)
- [Heroku](#heroku)
- [Warden](#warden)
- [Contributors](#contributors)
- [License](#license)
<!-- /TOC -->
Devise is guaranteed to be thread-safe on YARV. Thread-safety support on JRuby is in progress.
## Information
@@ -46,9 +83,13 @@ https://github.com/plataformatec/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.
### Mailing list
### StackOverflow and Mailing List
If you have any questions, comments, or concerns, please use the Google Group instead of the GitHub issue tracker:
If you have any questions, comments, or concerns, please use StackOverflow instead of the GitHub issue tracker:
http://stackoverflow.com/questions/tagged/devise
The deprecated mailing list can still be read on
https://groups.google.com/group/plataformatec-devise
@@ -78,7 +119,54 @@ We hope that you will consider contributing to Devise. Please read this short ov
https://github.com/plataformatec/devise/wiki/Contributing
You will usually want to write tests for your changes. To run the test suite, go into Devise's top-level directory and run "bundle install" and "rake". For the tests to pass, you will need to have a MongoDB server (version 2.0 or newer) running on your system.
You will usually want to write tests for your changes. To run the test suite, go into Devise's top-level directory and run `bundle install` and `bin/test`.
Devise works with multiple Ruby and Rails versions, and ActiveRecord and Mongoid ORMs, which means you can run the test suite with some modifiers: `DEVISE_ORM` and `BUNDLE_GEMFILE`.
### DEVISE_ORM
Since Devise support both Mongoid and ActiveRecord, we rely on this variable to run specific code for each ORM.
The default value of `DEVISE_ORM` is `active_record`. To run the tests for mongoid, you can pass `mongoid`:
```
DEVISE_ORM=mongoid bin/test
==> Devise.orm = :mongoid
```
When running the tests for Mongoid, you will need to have a MongoDB server (version 2.0 or newer) running on your system.
Please note that the command output will show the variable value being used.
### BUNDLE_GEMFILE
We can use this variable to tell bundler what Gemfile it should use (instead of the one in the current directory).
Inside the [gemfiles](https://github.com/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:
```bash
rbenv shell 2.4.2 # or rvm use 2.4.2
BUNDLE_GEMFILE=gemfiles/Gemfile.rails-4.1-stable bundle install
BUNDLE_GEMFILE=gemfiles/Gemfile.rails-4.1-stable bin/test
```
You can also combine both of them if the tests broke for Mongoid:
```bash
BUNDLE_GEMFILE=gemfiles/Gemfile.rails-4.1-stable bundle install
BUNDLE_GEMFILE=gemfiles/Gemfile.rails-4.1-stable DEVISE_ORM=mongoid bin/test
```
### Running tests
Devise uses [Mini Test](https://github.com/seattlerb/minitest) as test framework.
* Running all tests:
```bash
bin/test
```
* Running tests for an specific file:
```bash
bin/test test/models/trackable_test.rb
```
* Running a specific test given a regex:
```bash
bin/test test/models/trackable_test.rb:16
```
## Starting with Rails?
@@ -86,43 +174,46 @@ If you are building your first Rails application, we recommend you *do not* use
* Michael Hartl's online book: https://www.railstutorial.org/book/modeling_users
* Ryan Bates' Railscast: http://railscasts.com/episodes/250-authentication-from-scratch
* Codecademy's Ruby on Rails: Authentication and Authorization: http://www.codecademy.com/en/learn/rails-auth
* Codecademy's Ruby on Rails: Authentication and Authorization: https://www.codecademy.com/learn/rails-auth
Once you have solidified your understanding of Rails and authentication mechanisms, we assure you Devise will be very pleasant to work with. :smiley:
## Getting started
Devise 3.0 works with Rails 3.2 onwards. You can add it to your Gemfile with:
Devise 4.0 works with Rails 4.1 onwards. Add the following line to your Gemfile:
```ruby
gem 'devise'
```
Run the bundle command to install it.
Then run `bundle install`
After you install Devise and add it to your Gemfile, you need to run the generator:
Next, you need to run the generator:
```console
rails generate devise:install
$ rails generate devise:install
```
The generator will install an initializer which describes ALL of Devise's configuration options. It is *imperative* that you take a look at it. When you are done, you are ready to add Devise to any of your models using the generator:
```console
rails generate devise MODEL
```
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 default Devise modules. The generator also configures your `config/routes.rb` file to point to the Devise controller.
Next, check the MODEL for any additional configuration options you might want to add, such as confirmable or lockable. If you add an option, be sure to inspect the migration file (created by the generator if your ORM supports them) and uncomment the appropriate section. For example, if you add the confirmable option in the model, you'll need to uncomment the Confirmable section in the migration. Then run `rake db:migrate`
Next, you 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`:
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`:
```ruby
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
```
You should restart your application after changing Devise's configuration options. Otherwise, you will run into strange errors, for example, users being unable to login and route helpers being undefined.
The generator will install an initializer which describes ALL of Devise's configuration options. It is *imperative* that you take a look at it. When you are done, you are ready to add Devise to any of your models using the generator.
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
```
Next, check the MODEL for any additional configuration options you might want to add, such as confirmable or lockable. If you add an option, be sure to inspect the migration file (created by the generator if your ORM supports them) and uncomment the appropriate section. For example, if you add the confirmable option in the model, you'll need to uncomment the Confirmable section in the migration.
Then run `rails db:migrate`
You should restart your application after changing Devise's configuration options (this includes stopping spring). Otherwise, you will run into strange errors, for example, users being unable to login and route helpers being undefined.
### Controller filters and helpers
@@ -132,6 +223,8 @@ Devise will create some helpers to use inside your controllers and views. To set
before_action :authenticate_user!
```
For Rails 5, note that `protect_from_forgery` is no longer prepended to the `before_action` chain, so if you have set `authenticate_user` before `protect_from_forgery`, your request will result in "Can't verify CSRF token authenticity." To resolve this, either change the order in which you call them, or use `protect_from_forgery prepend: true`.
If your devise model is something other than User, replace "_user" with "_yourmodel". The same logic applies to the instructions below.
To verify if a user is signed in, use the following helper:
@@ -155,7 +248,7 @@ user_session
After signing in a user, confirming the account or updating the password, Devise will look for a scoped root path to redirect to. For instance, when using a `:user` resource, the `user_root_path` will be used if it exists; otherwise, the default `root_path` will be used. This means that you need to set the root inside your routes:
```ruby
root to: "home#index"
root to: 'home#index'
```
You can also override `after_sign_in_path_for` and `after_sign_out_path_for` to customize your redirect hooks.
@@ -174,25 +267,29 @@ member_session
### Configuring Models
The Devise method in your models also accepts some options to configure its modules. For example, you can choose the cost of the encryption algorithm with:
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: 20
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)
*For previous Devise versions see https://github.com/plataformatec/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.
There are just three actions in Devise that allow any set of parameters to be passed down to the model, therefore requiring sanitization. Their names and the permitted parameters by default are:
There are just three actions in Devise that allow any set of parameters to be passed down to the model, therefore requiring sanitization. Their names and default permitted parameters are:
* `sign_in` (`Devise::SessionsController#create`) - Permits only the authentication keys (like `email`)
* `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
@@ -201,18 +298,34 @@ class ApplicationController < ActionController::Base
protected
def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_up) << :username
devise_parameter_sanitizer.permit(:sign_up, keys: [:username])
end
end
```
The above works for any additional fields where the parameters are simple scalar types. If you have nested attributes (say you're using `accepts_nested_attributes_for`), then you will need to tell devise about those nestings and types. Devise allows you to completely change Devise defaults or invoke custom behaviour by passing a block:
The above works for any additional fields where the parameters are simple scalar types. If you have nested attributes (say you're using `accepts_nested_attributes_for`), then you will need to tell devise about those nestings and types:
```ruby
class ApplicationController < ActionController::Base
before_action :configure_permitted_parameters, if: :devise_controller?
protected
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: [:first_name, :last_name, address_attributes: [:country, :state, :city, :area, :postal_code]])
end
end
```
Devise allows you to completely change Devise defaults or invoke custom behaviour by passing a block:
To permit simple scalar values for username and email, use this
```ruby
def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:username, :email) }
devise_parameter_sanitizer.permit(:sign_in) do |user_params|
user_params.permit(:username, :email)
end
end
```
@@ -220,7 +333,9 @@ If you have some checkboxes that express the roles a user may take on registrati
```ruby
def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_up) { |u| u.permit({ roles: [] }, :email, :password, :password_confirmation) }
devise_parameter_sanitizer.permit(:sign_up) do |user_params|
user_params.permit({ roles: [] }, :email, :password, :password_confirmation)
end
end
```
For the list of permitted scalars, and how to declare permitted keys in nested hashes and arrays, see
@@ -231,8 +346,9 @@ If you have multiple Devise models, you may want to set up a different parameter
```ruby
class User::ParameterSanitizer < Devise::ParameterSanitizer
def sign_in
default_params.permit(:username, :email)
def initialize(*)
super
permit(:sign_up, keys: [:username, :email])
end
end
```
@@ -262,7 +378,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.
@@ -270,14 +386,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.
```console
rails generate devise:views -v registrations confirmations
$ rails generate devise:views -v registrations confirmations
```
### Configuring controllers
@@ -287,7 +403,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/`.
@@ -302,11 +418,12 @@ If the customization at the views level is not enough, you can customize each co
...
end
```
(Use the -c flag to specify a controller, for example: `rails generate devise:controllers users -c=sessions`)
2. Tell the router to use this controller:
```ruby
devise_for :users, controllers: { sessions: "users/sessions" }
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`.
@@ -344,21 +461,27 @@ Remember that Devise uses flash messages to let users know if sign in was succes
Devise also ships with default routes. If you need to customize them, you should probably be able to do it through the devise_for method. It accepts several options like :class_name, :path_prefix and so on, including the possibility to change path names for I18n:
```ruby
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' }
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 for details.
Be sure to check `devise_for` [documentation](http://www.rubydoc.info/github/plataformatec/devise/master/ActionDispatch/Routing/Mapper%3Adevise_for) for details.
If you have the need for more deep customization, for instance to also allow "/sign_in" besides "/users/sign_in", all you need to do is create your routes normally and wrap them in a `devise_scope` block in the router:
```ruby
devise_scope :user do
get "sign_in", to: "devise/sessions#new"
get 'sign_in', to: 'devise/sessions#new'
end
```
This way, you tell Devise to use the scope `:user` when "/sign_in" is accessed. Notice `devise_scope` is also aliased as `as` in your router.
Please note: You will still need to add `devise_for` in your routes in order to use helper methods such as `current_user`.
```ruby
devise_for :users, skip: :all
```
### 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:
@@ -403,48 +526,101 @@ Caution: Devise Controllers inherit from ApplicationController. If your app uses
### Test helpers
Devise includes some test helpers for functional specs. In order to use them, you need to include Devise in your functional tests by adding the following to the bottom of your `test/test_helper.rb` file:
Devise includes some test helpers for controller and integration tests.
In order to use them, you need to include the respective module in your test
cases/specs.
### Controller tests
Controller tests require that you include `Devise::Test::ControllerHelpers` on
your test case or its parent `ActionController::TestCase` superclass.
For Rails 5, include `Devise::Test::IntegrationHelpers` instead, since the superclass
for controller tests has been changed to ActionDispatch::IntegrationTest
(for more details, see the [Integration tests](#integration-tests) section).
```ruby
class ActionController::TestCase
include Devise::TestHelpers
class PostsControllerTest < ActionController::TestCase
include Devise::Test::ControllerHelpers
end
```
If you're using RSpec, you can put the following inside a file named `spec/support/devise.rb` or in your `spec/spec_helper.rb` (or `spec/rails_helper.rb` if you are using rspec-rails):
If you're using RSpec, you can put the following inside a file named
`spec/support/devise.rb` or in your `spec/spec_helper.rb` (or
`spec/rails_helper.rb` if you are using `rspec-rails`):
```ruby
RSpec.configure do |config|
config.include Devise::TestHelpers, type: :controller
config.include Devise::Test::ControllerHelpers, type: :controller
config.include Devise::Test::ControllerHelpers, type: :view
end
```
Just be sure that this inclusion is made *after* the `require 'rspec/rails'` directive.
Now you are ready to use the `sign_in` and `sign_out` methods. Such methods have the same signature as in controllers:
Now you are ready to use the `sign_in` and `sign_out` methods on your controller
tests:
```ruby
sign_in :user, @user # sign_in(scope, resource)
sign_in @user # sign_in(resource)
sign_out :user # sign_out(scope)
sign_out @user # sign_out(resource)
sign_in @user
sign_in @user, scope: :admin
```
There are two things that are important to keep in mind:
If you are testing Devise internal controllers or a controller that inherits
from Devise's, you need to tell Devise which mapping should be used before a
request. This is necessary because Devise gets this information from the router,
but since controller tests do not pass through the router, it needs to be stated
explicitly. For example, if you are testing the user scope, simply use:
1. These helpers are not going to work for integration tests driven by Capybara or Webrat. They are meant to be used with functional tests only. Instead, fill in the form or explicitly set the user in session;
```ruby
test 'GET new' do
# Mimic the router behavior of setting the Devise scope through the env.
@request.env['devise.mapping'] = Devise.mappings[:user]
2. If you are testing Devise internal controllers or a controller that inherits from Devise's, you need to tell Devise which mapping should be used before a request. This is necessary because Devise gets this information from the router, but since functional tests do not pass through the router, it needs to be stated explicitly. For example, if you are testing the user scope, simply use:
# Use the sign_in helper to sign in a fixture `User` record.
sign_in users(:alice)
```ruby
@request.env["devise.mapping"] = Devise.mappings[:user]
get :new
```
get :new
# assert something
end
```
### Integration tests
Integration test helpers are available by including the
`Devise::Test::IntegrationHelpers` module.
```ruby
class PostsTests < ActionDispatch::IntegrationTest
include Devise::Test::IntegrationHelpers
end
```
Now you can use the following `sign_in` and `sign_out` methods in your integration
tests:
```ruby
sign_in users(:bob)
sign_in users(:bob), scope: :admin
sign_out :user
```
RSpec users can include the `IntegrationHelpers` module on their `:feature` specs.
```ruby
RSpec.configure do |config|
config.include Devise::Test::IntegrationHelpers, type: :feature
end
```
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:
* https://github.com/plataformatec/devise/wiki/How-To:-Test-controllers-with-Rails-3-and-4-%28and-RSpec%29
* https://github.com/plataformatec/devise/wiki/How-To:-Test-controllers-with-Rails-(and-RSpec)
### OmniAuth
@@ -477,7 +653,7 @@ devise :database_authenticatable, :timeoutable
devise_for :admins
# Inside your protected controller
before_filter :authenticate_admin!
before_action :authenticate_admin!
# Inside your controllers and views
admin_signed_in?
@@ -519,6 +695,17 @@ config.log_level = :warn
Devise supports ActiveRecord (default) and Mongoid. To select another ORM, simply require it in the initializer file.
### Rails API Mode
Rails 5+ has a built-in [API Mode](https://edgeguides.rubyonrails.org/api_app.html) which optimizes Rails for use as an API (only). One of the side effects is that it changes the order of the middleware stack, and this can cause problems for `Devise::Test::IntegrationHelpers`. This problem usually surfaces as an ```undefined method `[]=' for nil:NilClass``` error when using integration test helpers, such as `#sign_in`. The solution is simply to reorder the middlewares by adding the following to test.rb:
```ruby
Rails.application.config.middleware.insert_before Warden::Manager, ActionDispatch::Cookies
Rails.application.config.middleware.insert_before Warden::Manager, ActionDispatch::Session::CookieStore
```
For a deeper understanding of this, review [this issue](https://github.com/plataformatec/devise/issues/4696).
## Additional information
### Heroku
@@ -545,6 +732,6 @@ https://github.com/plataformatec/devise/graphs/contributors
## License
MIT License. Copyright 2009-2015 Plataformatec. http://plataformatec.com.br
MIT License. Copyright 2009-2019 Plataformatec. http://plataformatec.com.br
You are not granted rights or licenses to the trademarks of Plataformatec, including without limitation the Devise name or logo.

View File

@@ -1,4 +1,5 @@
# encoding: UTF-8
# frozen_string_literal: true
require 'bundler/gem_tasks'
require 'rake/testtask'

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
class Devise::ConfirmationsController < DeviseController
# GET /resource/confirmation/new
def new
@@ -22,7 +24,7 @@ class Devise::ConfirmationsController < DeviseController
yield resource if block_given?
if resource.errors.empty?
set_flash_message(:notice, :confirmed) if is_flashing_format?
set_flash_message!(:notice, :confirmed)
respond_with_navigational(resource){ redirect_to after_confirmation_path_for(resource_name, resource) }
else
respond_with_navigational(resource.errors, status: :unprocessable_entity){ render :new }

View File

@@ -1,26 +1,28 @@
# frozen_string_literal: true
class Devise::OmniauthCallbacksController < DeviseController
prepend_before_filter { request.env["devise.skip_timeout"] = true }
prepend_before_action { request.env["devise.skip_timeout"] = true }
def passthru
render status: 404, text: "Not found. Authentication passthru."
render status: 404, plain: "Not found. Authentication passthru."
end
def failure
set_flash_message :alert, :failure, kind: OmniAuth::Utils.camelize(failed_strategy.name), reason: failure_message
set_flash_message! :alert, :failure, kind: OmniAuth::Utils.camelize(failed_strategy.name), reason: failure_message
redirect_to after_omniauth_failure_path_for(resource_name)
end
protected
def failed_strategy
env["omniauth.error.strategy"]
request.respond_to?(:get_header) ? request.get_header("omniauth.error.strategy") : request.env["omniauth.error.strategy"]
end
def failure_message
exception = env["omniauth.error"]
exception = request.respond_to?(:get_header) ? request.get_header("omniauth.error") : request.env["omniauth.error"]
error = exception.error_reason if exception.respond_to?(:error_reason)
error ||= exception.error if exception.respond_to?(:error)
error ||= env["omniauth.error.type"].to_s
error ||= (request.respond_to?(:get_header) ? request.get_header("omniauth.error.type") : request.env["omniauth.error.type"]).to_s
error.to_s.humanize if error
end

View File

@@ -1,7 +1,9 @@
# frozen_string_literal: true
class Devise::PasswordsController < DeviseController
prepend_before_filter :require_no_authentication
prepend_before_action :require_no_authentication
# Render the #edit only if coming from a reset password email link
append_before_filter :assert_reset_token_passed, only: :edit
append_before_action :assert_reset_token_passed, only: :edit
# GET /resource/password/new
def new
@@ -36,10 +38,11 @@ class Devise::PasswordsController < DeviseController
resource.unlock_access! if unlockable?(resource)
if Devise.sign_in_after_reset_password
flash_message = resource.active_for_authentication? ? :updated : :updated_not_active
set_flash_message(:notice, flash_message) if is_flashing_format?
set_flash_message!(:notice, flash_message)
resource.after_database_authentication
sign_in(resource_name, resource)
else
set_flash_message(:notice, :updated_not_active) if is_flashing_format?
set_flash_message!(:notice, :updated_not_active)
end
respond_with resource, location: after_resetting_password_path_for(resource)
else

View File

@@ -1,13 +1,15 @@
# frozen_string_literal: true
class Devise::RegistrationsController < DeviseController
prepend_before_filter :require_no_authentication, only: [:new, :create, :cancel]
prepend_before_filter :authenticate_scope!, only: [:edit, :update, :destroy]
prepend_before_action :require_no_authentication, only: [:new, :create, :cancel]
prepend_before_action :authenticate_scope!, only: [:edit, :update, :destroy]
prepend_before_action :set_minimum_password_length, only: [:new, :edit]
# GET /resource/sign_up
def new
build_resource({})
set_minimum_password_length
build_resource
yield resource if block_given?
respond_with self.resource
respond_with resource
end
# POST /resource
@@ -18,11 +20,11 @@ class Devise::RegistrationsController < DeviseController
yield resource if block_given?
if resource.persisted?
if resource.active_for_authentication?
set_flash_message :notice, :signed_up if is_flashing_format?
set_flash_message! :notice, :signed_up
sign_up(resource_name, resource)
respond_with resource, location: after_sign_up_path_for(resource)
else
set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_flashing_format?
set_flash_message! :notice, :"signed_up_but_#{resource.inactive_message}"
expire_data_after_sign_in!
respond_with resource, location: after_inactive_sign_up_path_for(resource)
end
@@ -48,15 +50,13 @@ class Devise::RegistrationsController < DeviseController
resource_updated = update_resource(resource, account_update_params)
yield resource if block_given?
if resource_updated
if is_flashing_format?
flash_key = update_needs_confirmation?(resource, prev_unconfirmed_email) ?
:update_needs_confirmation : :updated
set_flash_message :notice, flash_key
end
sign_in resource_name, resource, bypass: true
set_flash_message_for_update(resource, prev_unconfirmed_email)
bypass_sign_in resource, scope: resource_name if sign_in_after_change_password?
respond_with resource, location: after_update_path_for(resource)
else
clean_up_passwords resource
set_minimum_password_length
respond_with resource
end
end
@@ -65,7 +65,7 @@ class Devise::RegistrationsController < DeviseController
def destroy
resource.destroy
Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name)
set_flash_message :notice, :destroyed if is_flashing_format?
set_flash_message! :notice, :destroyed
yield resource if block_given?
respond_with_navigational(resource){ redirect_to after_sign_out_path_for(resource_name) }
end
@@ -96,8 +96,8 @@ class Devise::RegistrationsController < DeviseController
# Build a devise resource passing in the session. Useful to move
# temporary session data to the newly created user.
def build_resource(hash=nil)
self.resource = resource_class.new_with_session(hash || {}, session)
def build_resource(hash = {})
self.resource = resource_class.new_with_session(hash, session)
end
# Signs in a user on sign up. You can overwrite this method in your own
@@ -109,7 +109,7 @@ class Devise::RegistrationsController < DeviseController
# The path used after sign up. You need to overwrite this method
# in your own RegistrationsController.
def after_sign_up_path_for(resource)
after_sign_in_path_for(resource)
after_sign_in_path_for(resource) if is_navigational_format?
end
# The path used after sign up for inactive accounts. You need to overwrite
@@ -124,7 +124,7 @@ class Devise::RegistrationsController < DeviseController
# The default url to be used after updating a resource. You need to overwrite
# this method in your own RegistrationsController.
def after_update_path_for(resource)
signed_in_root_path(resource)
sign_in_after_change_password? ? signed_in_root_path(resource) : new_session_path(resource_name)
end
# Authenticates the current scope and gets the current resource from the session.
@@ -144,4 +144,25 @@ class Devise::RegistrationsController < DeviseController
def translation_scope
'devise.registrations'
end
private
def set_flash_message_for_update(resource, prev_unconfirmed_email)
return unless is_flashing_format?
flash_key = if update_needs_confirmation?(resource, prev_unconfirmed_email)
:update_needs_confirmation
elsif sign_in_after_change_password?
:updated
else
:updated_but_not_signed_in
end
set_flash_message :notice, flash_key
end
def sign_in_after_change_password?
return true if account_update_params[:password].blank?
Devise.sign_in_after_change_password
end
end

View File

@@ -1,8 +1,10 @@
# frozen_string_literal: true
class Devise::SessionsController < DeviseController
prepend_before_filter :require_no_authentication, only: [:new, :create]
prepend_before_filter :allow_params_authentication!, only: :create
prepend_before_filter :verify_signed_out_user, only: :destroy
prepend_before_filter only: [:create, :destroy] { request.env["devise.skip_timeout"] = true }
prepend_before_action :require_no_authentication, only: [:new, :create]
prepend_before_action :allow_params_authentication!, only: :create
prepend_before_action :verify_signed_out_user, only: :destroy
prepend_before_action(only: [:create, :destroy]) { request.env["devise.skip_timeout"] = true }
# GET /resource/sign_in
def new
@@ -15,7 +17,7 @@ class Devise::SessionsController < DeviseController
# POST /resource/sign_in
def create
self.resource = warden.authenticate!(auth_options)
set_flash_message(:notice, :signed_in) if is_flashing_format?
set_flash_message!(:notice, :signed_in)
sign_in(resource_name, resource)
yield resource if block_given?
respond_with resource, location: after_sign_in_path_for(resource)
@@ -24,7 +26,7 @@ class Devise::SessionsController < DeviseController
# DELETE /resource/sign_out
def destroy
signed_out = (Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name))
set_flash_message :notice, :signed_out if signed_out && is_flashing_format?
set_flash_message! :notice, :signed_out if signed_out
yield if block_given?
respond_to_on_destroy
end
@@ -58,7 +60,7 @@ class Devise::SessionsController < DeviseController
# to the after_sign_out path.
def verify_signed_out_user
if all_signed_out?
set_flash_message :notice, :already_signed_out if is_flashing_format?
set_flash_message! :notice, :already_signed_out
respond_to_on_destroy
end

View File

@@ -1,5 +1,7 @@
# frozen_string_literal: true
class Devise::UnlocksController < DeviseController
prepend_before_filter :require_no_authentication
prepend_before_action :require_no_authentication
# GET /resource/unlock/new
def new
@@ -24,7 +26,7 @@ class Devise::UnlocksController < DeviseController
yield resource if block_given?
if resource.errors.empty?
set_flash_message :notice, :unlocked if is_flashing_format?
set_flash_message! :notice, :unlocked
respond_with_navigational(resource){ redirect_to after_unlock_path_for(resource) }
else
respond_with_navigational(resource.errors, status: :unprocessable_entity){ render :new }

View File

@@ -1,14 +1,20 @@
# frozen_string_literal: true
# All Devise controllers are inherited from here.
class DeviseController < Devise.parent_controller.constantize
include Devise::Controllers::ScopedViews
helper DeviseHelper
if respond_to?(:helper)
helper DeviseHelper
end
helpers = %w(resource scope_name resource_name signed_in_resource
resource_class resource_params devise_mapping)
helper_method(*helpers)
if respond_to?(:helper_method)
helpers = %w(resource scope_name resource_name signed_in_resource
resource_class resource_params devise_mapping)
helper_method(*helpers)
end
prepend_before_filter :assert_is_devise_resource!
prepend_before_action :assert_is_devise_resource!
respond_to :html if mimes_for_respond_to.empty?
# Override prefixes to consider the scoped view.
@@ -16,7 +22,7 @@ class DeviseController < Devise.parent_controller.constantize
# Action Controller tests that forces _prefixes to be
# loaded before even having a request object.
#
# This method should be public as it is is in ActionPack
# This method should be public as it is in ActionPack
# itself. Changing its visibility may break other gems.
def _prefixes #:nodoc:
@_prefixes ||= if self.class.scoped_views? && request && devise_mapping
@@ -89,10 +95,10 @@ MESSAGE
instance_variable_set(:"@#{resource_name}", new_resource)
end
# Helper for use in before_filters where no authentication is required.
# Helper for use in before_actions where no authentication is required.
#
# Example:
# before_filter :require_no_authentication, only: :new
# before_action :require_no_authentication, only: :new
def require_no_authentication
assert_is_devise_resource!
return unless is_navigational_format?
@@ -106,7 +112,7 @@ MESSAGE
end
if authenticated && resource = warden.user(resource_name)
flash[:alert] = I18n.t("devise.failure.already_authenticated")
set_flash_message(:alert, 'already_authenticated', scope: 'devise.failure')
redirect_to after_sign_in_path_for(resource)
end
end
@@ -123,13 +129,13 @@ MESSAGE
end
if notice
set_flash_message :notice, notice if is_flashing_format?
set_flash_message! :notice, notice
true
end
end
# Sets the flash message with :key, using I18n. By default you are able
# to setup your messages using specific resource scope, and if no message is
# to set up your messages using specific resource scope, and if no message is
# found we look to the default scope. Set the "now" options key to a true
# value to populate the flash.now hash in lieu of the default flash hash (so
# the flash message will be available to the current action instead of the
@@ -154,6 +160,13 @@ MESSAGE
end
end
# Sets flash message if is_flashing_format? equals true
def set_flash_message!(key, kind, options = {})
if is_flashing_format?
set_flash_message(key, kind, options)
end
end
# Sets minimum password length to show to user
def set_minimum_password_length
if devise_mapping.validatable?

View File

@@ -1,25 +1,18 @@
# frozen_string_literal: true
module DeviseHelper
# A simple way to show error messages for the current devise resource. If you need
# to customize this method, you can either overwrite it in your application helpers or
# copy the views to your application.
#
# This method is intended to stay simple and it is unlikely that we are going to change
# it to add more behavior or options.
# Retain this method for backwards compatibility, deprecated in favour of modifying the
# devise/shared/error_messages partial
def devise_error_messages!
ActiveSupport::Deprecation.warn <<-DEPRECATION.strip_heredoc
[Devise] `DeviseHelper.devise_error_messages!`
is deprecated and it will be removed in the next major version.
To customize the errors styles please run `rails g devise:views` and modify the
`devise/shared/error_messages` partial.
DEPRECATION
return "" if resource.errors.empty?
messages = resource.errors.full_messages.map { |msg| content_tag(:li, msg) }.join
sentence = I18n.t("errors.messages.not_saved",
count: resource.errors.count,
resource: resource.class.model_name.human.downcase)
html = <<-HTML
<div id="error_explanation">
<h2>#{sentence}</h2>
<ul>#{messages}</ul>
</div>
HTML
html.html_safe
render "devise/shared/error_messages", resource: resource
end
end

View File

@@ -1,4 +1,6 @@
if defined?(ActionMailer)
# frozen_string_literal: true
if Object.const_defined?(Devise.parent_mailer)
class Devise::Mailer < Devise.parent_mailer.constantize
include Devise::Mailers::Helpers
@@ -17,6 +19,10 @@ if defined?(ActionMailer)
devise_mail(record, :unlock_instructions, opts)
end
def email_changed(record, opts={})
devise_mail(record, :email_changed, opts)
end
def password_change(record, opts={})
devise_mail(record, :password_change, opts)
end

View File

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

View File

@@ -0,0 +1,7 @@
<p>Hello <%= @email %>!</p>
<% if @resource.try(:unconfirmed_email?) %>
<p>We're contacting you to notify you that your email is being changed to <%= @resource.unconfirmed_email %>.</p>
<% else %>
<p>We're contacting you to notify you that your email has been changed to <%= @resource.email %>.</p>
<% end %>

View File

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

View File

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

View File

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

View File

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

View File

@@ -3,20 +3,20 @@
<%= 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 %>
<%= f.email_field :email, autofocus: true, autocomplete: "email" %>
</div>
<div class="field">
<%= f.label :password %><br />
<%= f.password_field :password, autocomplete: "off" %>
<%= f.password_field :password, autocomplete: "current-password" %>
</div>
<% if devise_mapping.rememberable? -%>
<% if devise_mapping.rememberable? %>
<div class="field">
<%= f.check_box :remember_me %>
<%= f.label :remember_me %>
</div>
<% end -%>
<% end %>
<div class="actions">
<%= f.submit "Log in" %>

View File

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

View File

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

View File

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

17
bin/test Executable file
View File

@@ -0,0 +1,17 @@
#!/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'
Rails::TestUnitReporter.executable = 'bin/test'
Rails::TestUnit::Runner.parse_options(ARGV)
Rails::TestUnit::Runner.run(ARGV)
rescue LoadError
exec 'rake'
end

View File

@@ -23,6 +23,8 @@ en:
subject: "Reset password instructions"
unlock_instructions:
subject: "Unlock instructions"
email_changed:
subject: "Email Changed"
password_change:
subject: "Password Changed"
omniauth_callbacks:
@@ -40,8 +42,9 @@ en:
signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated."
signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked."
signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account."
update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirm link to confirm your new email address."
update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirmation link to confirm your new email address."
updated: "Your account has been updated successfully."
updated_but_not_signed_in: "Your account has been updated successfully, but since your password was changed, you need to sign in again"
sessions:
signed_in: "Signed in successfully."
signed_out: "Signed out successfully."

View File

@@ -1,4 +1,6 @@
# -*- encoding: utf-8 -*-
# frozen_string_literal: true
$:.push File.expand_path("../lib", __FILE__)
require "devise/version"
@@ -13,15 +15,13 @@ Gem::Specification.new do |s|
s.description = "Flexible authentication solution for Rails with Warden"
s.authors = ['José Valim', 'Carlos Antônio']
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- test/*`.split("\n")
s.files = Dir["{app,config,lib}/**/*", "CHANGELOG.md", "MIT-LICENSE", "README.md"]
s.require_paths = ["lib"]
s.required_ruby_version = '>= 1.9.3'
s.required_ruby_version = '>= 2.1.0'
s.add_dependency("warden", "~> 1.2.3")
s.add_dependency("orm_adapter", "~> 0.1")
s.add_dependency("bcrypt", "~> 3.0")
s.add_dependency("thread_safe", "~> 0.1")
s.add_dependency("railties", ">= 3.2.6", "< 5")
s.add_dependency("railties", ">= 4.1.0")
s.add_dependency("responders")
end

View File

@@ -1,29 +0,0 @@
source "https://rubygems.org"
gemspec path: '..'
gem "rails", github: 'rails/rails', branch: '3-2-stable'
gem "omniauth", "~> 1.2.0"
gem "omniauth-oauth2", "~> 1.1.0"
gem "rdoc"
group :test do
gem "omniauth-facebook"
gem "omniauth-openid", "~> 1.0.1"
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"
end
platforms :ruby do
gem "sqlite3"
end
group :mongoid do
gem "mongoid", "~> 3.0"
end

View File

@@ -1,172 +0,0 @@
GIT
remote: git://github.com/rails/rails.git
revision: b344986bc3d94ca7821fc5e0eef1874882ac6cbb
branch: 3-2-stable
specs:
actionmailer (3.2.21)
actionpack (= 3.2.21)
mail (~> 2.5.4)
actionpack (3.2.21)
activemodel (= 3.2.21)
activesupport (= 3.2.21)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.4)
rack (~> 1.4.5)
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.2.1)
activemodel (3.2.21)
activesupport (= 3.2.21)
builder (~> 3.0.0)
activerecord (3.2.21)
activemodel (= 3.2.21)
activesupport (= 3.2.21)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activeresource (3.2.21)
activemodel (= 3.2.21)
activesupport (= 3.2.21)
activesupport (3.2.21)
i18n (~> 0.6, >= 0.6.4)
multi_json (~> 1.0)
rails (3.2.21)
actionmailer (= 3.2.21)
actionpack (= 3.2.21)
activerecord (= 3.2.21)
activeresource (= 3.2.21)
activesupport (= 3.2.21)
bundler (~> 1.0)
railties (= 3.2.21)
railties (3.2.21)
actionpack (= 3.2.21)
activesupport (= 3.2.21)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
PATH
remote: ..
specs:
devise (3.5.3)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 3.2.6, < 5)
responders
thread_safe (~> 0.1)
warden (~> 1.2.3)
GEM
remote: https://rubygems.org/
specs:
arel (3.0.3)
bcrypt (3.1.10)
builder (3.0.4)
erubis (2.7.0)
faraday (0.9.1)
multipart-post (>= 1.2, < 3)
hashie (3.4.0)
hike (1.2.3)
i18n (0.7.0)
journey (1.0.4)
json (1.8.2)
jwt (1.4.1)
mail (2.5.4)
mime-types (~> 1.16)
treetop (~> 1.4.8)
metaclass (0.0.4)
mime-types (1.25.1)
mini_portile (0.6.2)
mocha (1.1.0)
metaclass (~> 0.0.1)
mongoid (3.1.6)
activemodel (~> 3.2)
moped (~> 1.4)
origin (~> 1.0)
tzinfo (~> 0.3.29)
moped (1.5.2)
multi_json (1.11.0)
multi_xml (0.5.5)
multipart-post (2.0.0)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
oauth2 (0.9.4)
faraday (>= 0.8, < 0.10)
jwt (~> 1.0)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (~> 1.2)
omniauth (1.2.2)
hashie (>= 1.2, < 4)
rack (~> 1.0)
omniauth-facebook (1.6.0)
omniauth-oauth2 (~> 1.1)
omniauth-oauth2 (1.1.2)
faraday (>= 0.8, < 0.10)
multi_json (~> 1.3)
oauth2 (~> 0.9.3)
omniauth (~> 1.2)
omniauth-openid (1.0.1)
omniauth (~> 1.0)
rack-openid (~> 1.3.1)
origin (1.1.0)
orm_adapter (0.5.0)
polyglot (0.3.5)
rack (1.4.5)
rack-cache (1.2)
rack (>= 0.4)
rack-openid (1.3.1)
rack (>= 1.1.0)
ruby-openid (>= 2.1.8)
rack-ssl (1.3.4)
rack
rack-test (0.6.3)
rack (>= 1.0)
rake (10.4.2)
rdoc (3.12.2)
json (~> 1.4)
responders (1.1.2)
railties (>= 3.2, < 4.2)
ruby-openid (2.7.0)
sprockets (2.2.3)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.10)
thor (0.19.1)
thread_safe (0.3.5)
tilt (1.4.1)
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.43)
warden (1.2.4)
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 (~> 3.0)
omniauth (~> 1.2.0)
omniauth-facebook
omniauth-oauth2 (~> 1.1.0)
omniauth-openid (~> 1.0.1)
rails!
rdoc
sqlite3
webrat (= 0.7.3)
BUNDLED WITH
1.10.6

View File

@@ -1,29 +0,0 @@
source "https://rubygems.org"
gemspec path: '..'
gem "rails", github: 'rails/rails', branch: '4-0-stable'
gem "omniauth", "~> 1.2.0"
gem "omniauth-oauth2", "~> 1.1.0"
gem "rdoc"
group :test do
gem "omniauth-facebook"
gem "omniauth-openid", "~> 1.0.1"
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"
end
platforms :ruby do
gem "sqlite3"
end
group :mongoid do
gem "mongoid", "~> 4.0.0"
end

View File

@@ -1,166 +0,0 @@
GIT
remote: git://github.com/rails/rails.git
revision: 7ec9c9635bf4d57009135ed11e89d8bf32306d73
branch: 4-0-stable
specs:
actionmailer (4.0.13)
actionpack (= 4.0.13)
mail (~> 2.5, >= 2.5.4)
actionpack (4.0.13)
activesupport (= 4.0.13)
builder (~> 3.1.0)
erubis (~> 2.7.0)
rack (~> 1.5.2)
rack-test (~> 0.6.2)
activemodel (4.0.13)
activesupport (= 4.0.13)
builder (~> 3.1.0)
activerecord (4.0.13)
activemodel (= 4.0.13)
activerecord-deprecated_finders (~> 1.0.2)
activesupport (= 4.0.13)
arel (~> 4.0.0)
activesupport (4.0.13)
i18n (~> 0.6, >= 0.6.9)
minitest (~> 4.2)
multi_json (~> 1.3)
thread_safe (~> 0.1)
tzinfo (~> 0.3.37)
rails (4.0.13)
actionmailer (= 4.0.13)
actionpack (= 4.0.13)
activerecord (= 4.0.13)
activesupport (= 4.0.13)
bundler (>= 1.3.0, < 2.0)
railties (= 4.0.13)
sprockets-rails (~> 2.0)
railties (4.0.13)
actionpack (= 4.0.13)
activesupport (= 4.0.13)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
PATH
remote: ..
specs:
devise (3.5.3)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 3.2.6, < 5)
responders
thread_safe (~> 0.1)
warden (~> 1.2.3)
GEM
remote: https://rubygems.org/
specs:
activerecord-deprecated_finders (1.0.3)
arel (4.0.2)
bcrypt (3.1.10)
bson (2.3.0)
builder (3.1.4)
connection_pool (2.1.3)
erubis (2.7.0)
faraday (0.9.1)
multipart-post (>= 1.2, < 3)
hashie (3.4.0)
hike (1.2.3)
i18n (0.7.0)
jwt (1.4.1)
mail (2.6.3)
mime-types (>= 1.16, < 3)
metaclass (0.0.4)
mime-types (2.4.3)
mini_portile (0.6.2)
minitest (4.7.5)
mocha (1.1.0)
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.4)
bson (~> 2.2)
connection_pool (~> 2.0)
optionable (~> 0.2.0)
multi_json (1.11.0)
multi_xml (0.5.5)
multipart-post (2.0.0)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
oauth2 (0.9.4)
faraday (>= 0.8, < 0.10)
jwt (~> 1.0)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (~> 1.2)
omniauth (1.2.2)
hashie (>= 1.2, < 4)
rack (~> 1.0)
omniauth-facebook (1.6.0)
omniauth-oauth2 (~> 1.1)
omniauth-oauth2 (1.1.2)
faraday (>= 0.8, < 0.10)
multi_json (~> 1.3)
oauth2 (~> 0.9.3)
omniauth (~> 1.2)
omniauth-openid (1.0.1)
omniauth (~> 1.0)
rack-openid (~> 1.3.1)
optionable (0.2.0)
origin (2.1.1)
orm_adapter (0.5.0)
rack (1.5.2)
rack-openid (1.3.1)
rack (>= 1.1.0)
ruby-openid (>= 2.1.8)
rack-test (0.6.3)
rack (>= 1.0)
rake (10.4.2)
rdoc (4.2.0)
responders (1.1.2)
railties (>= 3.2, < 4.2)
ruby-openid (2.7.0)
sprockets (2.12.3)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sprockets-rails (2.2.4)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
sqlite3 (1.3.10)
thor (0.19.1)
thread_safe (0.3.5)
tilt (1.4.1)
tzinfo (0.3.43)
warden (1.2.4)
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.0)
omniauth (~> 1.2.0)
omniauth-facebook
omniauth-oauth2 (~> 1.1.0)
omniauth-openid (~> 1.0.1)
rails!
rdoc
sqlite3
webrat (= 0.7.3)
BUNDLED WITH
1.10.6

View File

@@ -1,17 +1,23 @@
# frozen_string_literal: true
source "https://rubygems.org"
gemspec path: '..'
gemspec path: ".."
gem "rails", github: 'rails/rails', branch: '4-1-stable'
gem "omniauth", "~> 1.2.0"
gem "omniauth-oauth2", "~> 1.1.0"
gem "rdoc"
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", "~> 1.0.1"
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
@@ -21,9 +27,9 @@ platforms :jruby do
end
platforms :ruby do
gem "sqlite3"
gem "sqlite3", "~> 1.3.6"
end
group :mongoid do
gem "mongoid", "~> 4.0.0"
gem "mongoid", "~> 4.0"
end

View File

@@ -1,148 +1,147 @@
GIT
remote: git://github.com/rails/rails.git
revision: bf32ec7b8611e6b4c7e9398f7d297a1f0221e9b9
revision: 0cad778c2605a5204a05a9f1dbd3344e39f248d8
branch: 4-1-stable
specs:
actionmailer (4.1.10)
actionpack (= 4.1.10)
actionview (= 4.1.10)
actionmailer (4.1.16)
actionpack (= 4.1.16)
actionview (= 4.1.16)
mail (~> 2.5, >= 2.5.4)
actionpack (4.1.10)
actionview (= 4.1.10)
activesupport (= 4.1.10)
rack (~> 1.5.2)
rack-test (~> 0.6.2)
actionview (4.1.10)
activesupport (= 4.1.10)
builder (~> 3.1)
erubis (~> 2.7.0)
activemodel (4.1.10)
activesupport (= 4.1.10)
builder (~> 3.1)
activerecord (4.1.10)
activemodel (= 4.1.10)
activesupport (= 4.1.10)
arel (~> 5.0.0)
activesupport (4.1.10)
i18n (~> 0.6, >= 0.6.9)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.1)
tzinfo (~> 1.1)
rails (4.1.10)
actionmailer (= 4.1.10)
actionpack (= 4.1.10)
actionview (= 4.1.10)
activemodel (= 4.1.10)
activerecord (= 4.1.10)
activesupport (= 4.1.10)
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.10)
railties (= 4.1.16)
sprockets-rails (~> 2.0)
railties (4.1.10)
actionpack (= 4.1.10)
activesupport (= 4.1.10)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
PATH
remote: ..
specs:
devise (3.5.3)
devise (4.7.1)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 3.2.6, < 5)
railties (>= 4.1.0)
responders
thread_safe (~> 0.1)
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.10)
bson (2.3.0)
builder (3.2.2)
connection_pool (2.1.3)
bcrypt (3.1.13)
bson (3.2.6)
builder (3.2.3)
concurrent-ruby (1.0.5)
connection_pool (2.2.1)
erubis (2.7.0)
faraday (0.9.1)
faraday (0.11.0)
multipart-post (>= 1.2, < 3)
hashie (3.4.0)
hike (1.2.3)
i18n (0.7.0)
json (1.8.2)
jwt (1.4.1)
mail (2.6.3)
mime-types (>= 1.16, < 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 (2.4.3)
mini_portile (0.6.2)
minitest (5.5.1)
mocha (1.1.0)
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.4)
bson (~> 2.2)
moped (2.0.7)
bson (~> 3.0)
connection_pool (~> 2.0)
optionable (~> 0.2.0)
multi_json (1.11.0)
multi_xml (0.5.5)
multi_json (1.12.1)
multi_xml (0.6.0)
multipart-post (2.0.0)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
oauth2 (0.9.4)
faraday (>= 0.8, < 0.10)
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)
omniauth (1.2.2)
rack (>= 1.2, < 3)
omniauth (1.4.2)
hashie (>= 1.2, < 4)
rack (~> 1.0)
omniauth-facebook (1.6.0)
omniauth-oauth2 (~> 1.1)
omniauth-oauth2 (1.1.2)
faraday (>= 0.8, < 0.10)
multi_json (~> 1.3)
oauth2 (~> 0.9.3)
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.1.1)
origin (2.3.0)
orm_adapter (0.5.0)
rack (1.5.2)
rack (1.5.5)
rack-openid (1.3.1)
rack (>= 1.1.0)
ruby-openid (>= 2.1.8)
rack-test (0.6.3)
rack (>= 1.0)
rake (10.4.2)
rdoc (4.2.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 (2.12.3)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sprockets-rails (2.2.4)
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.10)
thor (0.19.1)
thread_safe (0.3.5)
tilt (1.4.1)
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.4)
warden (1.2.7)
rack (>= 1.0)
webrat (0.7.3)
nokogiri (>= 1.2.0)
@@ -158,15 +157,18 @@ DEPENDENCIES
devise!
jruby-openssl
mocha (~> 1.1)
mongoid (~> 4.0.0)
omniauth (~> 1.2.0)
mongoid (~> 4.0)
nokogiri (= 1.9.1)
omniauth
omniauth-facebook
omniauth-oauth2 (~> 1.1.0)
omniauth-openid (~> 1.0.1)
omniauth-oauth2
omniauth-openid
rails!
rdoc
sqlite3
rdoc (~> 5.1)
sqlite3 (~> 1.3.6)
test_after_commit
timecop
webrat (= 0.7.3)
BUNDLED WITH
1.10.6
1.17.3

View File

@@ -1,17 +1,22 @@
# frozen_string_literal: true
source "https://rubygems.org"
gemspec path: '..'
gemspec path: ".."
gem "rails", github: 'rails/rails', branch: '4-2-stable'
gem "omniauth", "~> 1.2.2"
gem "omniauth-oauth2", "~> 1.2.0"
gem "rdoc"
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", "~> 1.0.1"
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
@@ -21,9 +26,9 @@ platforms :jruby do
end
platforms :ruby do
gem "sqlite3"
gem "sqlite3", "~> 1.3.6"
end
group :mongoid do
gem "mongoid", "~> 4.0.0"
gem "mongoid", "~> 4.0"
end

View File

@@ -1,136 +1,133 @@
GIT
remote: git://github.com/rails/rails.git
revision: f12ff8ddab7b199707ec36d72bd72f206f142c8b
revision: dc3ae21802c316e1639239d28202db7aa7fb7cac
branch: 4-2-stable
specs:
actionmailer (4.2.1)
actionpack (= 4.2.1)
actionview (= 4.2.1)
activejob (= 4.2.1)
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.1)
actionview (= 4.2.1)
activesupport (= 4.2.1)
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.1)
activesupport (= 4.2.1)
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.2)
activejob (4.2.1)
activesupport (= 4.2.1)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (4.2.8)
activesupport (= 4.2.8)
globalid (>= 0.3.0)
activemodel (4.2.1)
activesupport (= 4.2.1)
activemodel (4.2.8)
activesupport (= 4.2.8)
builder (~> 3.1)
activerecord (4.2.1)
activemodel (= 4.2.1)
activesupport (= 4.2.1)
activerecord (4.2.8)
activemodel (= 4.2.8)
activesupport (= 4.2.8)
arel (~> 6.0)
activesupport (4.2.1)
activesupport (4.2.8)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
rails (4.2.1)
actionmailer (= 4.2.1)
actionpack (= 4.2.1)
actionview (= 4.2.1)
activejob (= 4.2.1)
activemodel (= 4.2.1)
activerecord (= 4.2.1)
activesupport (= 4.2.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.1)
railties (= 4.2.8)
sprockets-rails
railties (4.2.1)
actionpack (= 4.2.1)
activesupport (= 4.2.1)
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 (3.5.3)
devise (4.7.1)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 3.2.6, < 5)
railties (>= 4.1.0)
responders
thread_safe (~> 0.1)
warden (~> 1.2.3)
GEM
remote: https://rubygems.org/
specs:
arel (6.0.0)
bcrypt (3.1.10)
bson (2.3.0)
builder (3.2.2)
connection_pool (2.1.3)
arel (6.0.4)
bcrypt (3.1.13)
bson (3.2.6)
builder (3.2.3)
concurrent-ruby (1.0.5)
connection_pool (2.2.1)
erubis (2.7.0)
faraday (0.9.1)
faraday (0.11.0)
multipart-post (>= 1.2, < 3)
globalid (0.3.3)
globalid (0.3.7)
activesupport (>= 4.1.0)
hashie (3.4.0)
hike (1.2.3)
i18n (0.7.0)
json (1.8.2)
jwt (1.4.1)
loofah (2.0.1)
hashie (3.5.5)
i18n (0.8.1)
jwt (1.5.6)
loofah (2.0.3)
nokogiri (>= 1.5.9)
mail (2.6.3)
mime-types (>= 1.16, < 3)
mail (2.6.4)
mime-types (>= 1.16, < 4)
metaclass (0.0.4)
mime-types (2.4.3)
mini_portile (0.6.2)
minitest (5.5.1)
mocha (1.1.0)
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.4)
bson (~> 2.2)
moped (2.0.7)
bson (~> 3.0)
connection_pool (~> 2.0)
optionable (~> 0.2.0)
multi_json (1.11.0)
multi_xml (0.5.5)
multi_json (1.12.1)
multi_xml (0.6.0)
multipart-post (2.0.0)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
oauth2 (1.0.0)
faraday (>= 0.8, < 0.10)
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)
omniauth (1.2.2)
hashie (>= 1.2, < 4)
rack (~> 1.0)
omniauth-facebook (2.0.1)
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.2.0)
faraday (>= 0.8, < 0.10)
multi_json (~> 1.3)
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.1.1)
origin (2.3.0)
orm_adapter (0.5.0)
rack (1.6.0)
rack (1.6.5)
rack-openid (1.3.1)
rack (>= 1.1.0)
ruby-openid (>= 2.1.8)
@@ -138,33 +135,34 @@ GEM
rack (>= 1.0)
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.6)
rails-dom-testing (1.0.8)
activesupport (>= 4.2.0.beta, < 5.0)
nokogiri (~> 1.6.0)
nokogiri (~> 1.6)
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.2)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
rake (10.4.2)
rdoc (4.2.0)
responders (2.1.0)
railties (>= 4.2.0, < 5)
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 (2.12.3)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sprockets-rails (2.2.4)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
sqlite3 (1.3.10)
thor (0.19.1)
thread_safe (0.3.5)
tilt (1.4.1)
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.4)
warden (1.2.7)
rack (>= 1.0)
webrat (0.7.3)
nokogiri (>= 1.2.0)
@@ -180,15 +178,18 @@ DEPENDENCIES
devise!
jruby-openssl
mocha (~> 1.1)
mongoid (~> 4.0.0)
omniauth (~> 1.2.2)
mongoid (~> 4.0)
nokogiri (= 1.9.1)
omniauth
omniauth-facebook
omniauth-oauth2 (~> 1.2.0)
omniauth-openid (~> 1.0.1)
omniauth-oauth2
omniauth-openid
rails!
rdoc
sqlite3
rdoc (~> 5.1)
sqlite3 (~> 1.3.6)
test_after_commit
timecop
webrat (= 0.7.3)
BUNDLED WITH
1.10.6
1.17.3

View File

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

@@ -0,0 +1,194 @@
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.7.1)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0)
responders
warden (~> 1.2.3)
GEM
remote: https://rubygems.org/
specs:
actioncable (5.0.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.13)
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.3

View File

@@ -0,0 +1,27 @@
source "https://rubygems.org"
gemspec path: ".."
gem "rails", '~> 5.2'
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

View File

@@ -0,0 +1,203 @@
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.7.1)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0)
responders
warden (~> 1.2.3)
GEM
remote: https://rubygems.org/
specs:
actioncable (5.2.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.13)
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.3

View File

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

View File

@@ -0,0 +1,219 @@
GIT
remote: git://github.com/rails/activemodel-serializers-xml.git
revision: 93689638c28525acc65afb638fce866826532641
specs:
activemodel-serializers-xml (1.0.2)
activemodel (>= 5.0.0.a)
activesupport (>= 5.0.0.a)
builder (~> 3.1)
PATH
remote: ..
specs:
devise (4.7.1)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0)
responders
warden (~> 1.2.3)
GEM
remote: https://rubygems.org/
specs:
actioncable (6.0.0)
actionpack (= 6.0.0)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (6.0.0)
actionpack (= 6.0.0)
activejob (= 6.0.0)
activerecord (= 6.0.0)
activestorage (= 6.0.0)
activesupport (= 6.0.0)
mail (>= 2.7.1)
actionmailer (6.0.0)
actionpack (= 6.0.0)
actionview (= 6.0.0)
activejob (= 6.0.0)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (6.0.0)
actionview (= 6.0.0)
activesupport (= 6.0.0)
rack (~> 2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (6.0.0)
actionpack (= 6.0.0)
activerecord (= 6.0.0)
activestorage (= 6.0.0)
activesupport (= 6.0.0)
nokogiri (>= 1.8.5)
actionview (6.0.0)
activesupport (= 6.0.0)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (6.0.0)
activesupport (= 6.0.0)
globalid (>= 0.3.6)
activemodel (6.0.0)
activesupport (= 6.0.0)
activerecord (6.0.0)
activemodel (= 6.0.0)
activesupport (= 6.0.0)
activestorage (6.0.0)
actionpack (= 6.0.0)
activejob (= 6.0.0)
activerecord (= 6.0.0)
marcel (~> 0.3.1)
activesupport (6.0.0)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
zeitwerk (~> 2.1, >= 2.1.8)
bcrypt (3.1.13)
builder (3.2.3)
concurrent-ruby (1.1.5)
crass (1.0.4)
erubi (1.8.0)
faraday (0.15.4)
multipart-post (>= 1.2, < 3)
globalid (0.4.2)
activesupport (>= 4.2.0)
hashie (3.6.0)
i18n (1.6.0)
concurrent-ruby (~> 1.0)
jwt (2.2.1)
loofah (2.2.3)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
mini_mime (>= 0.1.1)
marcel (0.3.3)
mimemagic (~> 0.3.2)
metaclass (0.0.4)
method_source (0.9.2)
mimemagic (0.3.3)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
minitest (5.11.3)
mocha (1.9.0)
metaclass (~> 0.0.1)
multi_json (1.13.1)
multi_xml (0.6.0)
multipart-post (2.1.1)
nio4r (2.4.0)
nokogiri (1.10.4)
mini_portile2 (~> 2.4.0)
oauth2 (1.4.1)
faraday (>= 0.8, < 0.16.0)
jwt (>= 1.0, < 3.0)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
omniauth (1.9.0)
hashie (>= 3.4.6, < 3.7.0)
rack (>= 1.6.2, < 3)
omniauth-facebook (5.0.0)
omniauth-oauth2 (~> 1.2)
omniauth-oauth2 (1.6.0)
oauth2 (~> 1.1)
omniauth (~> 1.9)
omniauth-openid (1.0.1)
omniauth (~> 1.0)
rack-openid (~> 1.3.1)
orm_adapter (0.5.0)
rack (2.0.7)
rack-openid (1.3.1)
rack (>= 1.1.0)
ruby-openid (>= 2.1.8)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (6.0.0)
actioncable (= 6.0.0)
actionmailbox (= 6.0.0)
actionmailer (= 6.0.0)
actionpack (= 6.0.0)
actiontext (= 6.0.0)
actionview (= 6.0.0)
activejob (= 6.0.0)
activemodel (= 6.0.0)
activerecord (= 6.0.0)
activestorage (= 6.0.0)
activesupport (= 6.0.0)
bundler (>= 1.3.0)
railties (= 6.0.0)
sprockets-rails (>= 2.0.0)
rails-controller-testing (1.0.4)
actionpack (>= 5.0.1.x)
actionview (>= 5.0.1.x)
activesupport (>= 5.0.1.x)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.2.0)
loofah (~> 2.2, >= 2.2.2)
railties (6.0.0)
actionpack (= 6.0.0)
activesupport (= 6.0.0)
method_source
rake (>= 0.8.7)
thor (>= 0.20.3, < 2.0)
rake (12.3.3)
rdoc (6.1.1)
responders (3.0.0)
actionpack (>= 5.0)
railties (>= 5.0)
ruby-openid (2.7.0)
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.1)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.4.1)
test_after_commit (1.1.0)
activerecord (>= 3.2)
thor (0.20.3)
thread_safe (0.3.6)
timecop (0.9.1)
tzinfo (1.2.5)
thread_safe (~> 0.1)
warden (1.2.8)
rack (>= 2.0.6)
webrat (0.7.3)
nokogiri (>= 1.2.0)
rack (>= 1.0)
rack-test (>= 0.5.3)
websocket-driver (0.7.1)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.4)
zeitwerk (2.1.9)
PLATFORMS
ruby
DEPENDENCIES
activemodel-serializers-xml!
devise!
mocha (~> 1.1)
omniauth
omniauth-facebook
omniauth-oauth2
omniauth-openid
rails (~> 6.0.0)
rails-controller-testing
rdoc
responders (~> 3.0)
sqlite3 (~> 1.4)
test_after_commit
timecop
webrat (= 0.7.3)
BUNDLED WITH
1.17.3

View File

@@ -0,0 +1,106 @@
# frozen_string_literal: true
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
# Activate the gem you are reporting the issue against.
gem 'rails', '~> 4.2.0'
gem 'devise', '~> 4.0'
gem 'sqlite3'
gem 'byebug'
end
require 'rack/test'
require 'action_controller/railtie'
require 'active_record'
require 'devise/rails/routes'
require 'devise/rails/warden_compat'
ActiveRecord::Base.establish_connection( adapter: :sqlite3, database: ':memory:')
class DeviseCreateUsers < ActiveRecord::Migration
def change
create_table(:users) do |t|
t.string :email, null: false
t.string :encrypted_password, null: true
t.timestamps null: false
end
end
end
Devise.setup do |config|
require 'devise/orm/active_record'
config.secret_key = 'secret_key_base'
end
class TestApp < Rails::Application
config.root = File.dirname(__FILE__)
config.session_store :cookie_store, key: 'cookie_store_key'
secrets.secret_token = 'secret_token'
secrets.secret_key_base = 'secret_key_base'
config.eager_load = false
config.middleware.use Warden::Manager do |config|
Devise.warden_config = config
end
config.logger = Logger.new($stdout)
Rails.logger = config.logger
end
Rails.application.initialize!
DeviseCreateUsers.migrate(:up)
class User < ActiveRecord::Base
devise :database_authenticatable
end
Rails.application.routes.draw do
devise_for :users
get '/' => 'test#index'
end
class ApplicationController < ActionController::Base
end
class TestController < ApplicationController
include Rails.application.routes.url_helpers
before_action :authenticate_user!
def index
render plain: 'Home'
end
end
require 'minitest/autorun'
class BugTest < ActionDispatch::IntegrationTest
include Rack::Test::Methods
include Warden::Test::Helpers
def test_returns_success
Warden.test_mode!
login_as User.create!(email: 'test@test.com', password: 'test123456', password_confirmation: 'test123456')
get '/'
assert last_response.ok?
end
private
def app
Rails.application
end
end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails'
require 'active_support/core_ext/numeric/time'
require 'active_support/dependencies'
@@ -12,19 +14,19 @@ module Devise
autoload :FailureApp, 'devise/failure_app'
autoload :OmniAuth, 'devise/omniauth'
autoload :ParameterFilter, 'devise/parameter_filter'
autoload :BaseSanitizer, 'devise/parameter_sanitizer'
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 :ScopedViews, 'devise/controllers/scoped_views'
autoload :SignInOut, 'devise/controllers/sign_in_out'
autoload :StoreLocation, 'devise/controllers/store_location'
autoload :UrlHelpers, 'devise/controllers/url_helpers'
autoload :Helpers, 'devise/controllers/helpers'
autoload :Rememberable, 'devise/controllers/rememberable'
autoload :ScopedViews, 'devise/controllers/scoped_views'
autoload :SignInOut, 'devise/controllers/sign_in_out'
autoload :StoreLocation, 'devise/controllers/store_location'
autoload :UrlHelpers, 'devise/controllers/url_helpers'
end
module Hooks
@@ -36,17 +38,22 @@ module Devise
end
module Strategies
autoload :Base, 'devise/strategies/base'
autoload :Base, 'devise/strategies/base'
autoload :Authenticatable, 'devise/strategies/authenticatable'
end
module Test
autoload :ControllerHelpers, 'devise/test/controller_helpers'
autoload :IntegrationHelpers, 'devise/test/integration_helpers'
end
# Constants which holds devise configuration for extensions. Those should
# not be modified by the "end user" (this is why they are constants).
ALL = []
CONTROLLERS = ActiveSupport::OrderedHash.new
ROUTES = ActiveSupport::OrderedHash.new
STRATEGIES = ActiveSupport::OrderedHash.new
URL_HELPERS = ActiveSupport::OrderedHash.new
CONTROLLERS = {}
ROUTES = {}
STRATEGIES = {}
URL_HELPERS = {}
# Strategies that do not require user input.
NO_INPUT = []
@@ -62,9 +69,9 @@ module Devise
mattr_accessor :rememberable_options
@@rememberable_options = {}
# The number of times to encrypt password.
# The number of times to hash the password.
mattr_accessor :stretches
@@stretches = 10
@@stretches = 12
# The default key used when authenticating over http auth.
mattr_accessor :http_authentication_key
@@ -84,7 +91,7 @@ module Devise
# Keys that should have whitespace stripped.
mattr_accessor :strip_whitespace_keys
@@strip_whitespace_keys = []
@@strip_whitespace_keys = [:email]
# If http authentication is enabled by default.
mattr_accessor :http_authenticatable
@@ -102,11 +109,11 @@ module Devise
mattr_accessor :http_authentication_realm
@@http_authentication_realm = "Application"
# Email regex used to validate email formats. It simply asserts that
# an one (and only one) @ exists in the given string. This is mainly
# to give user feedback and not to assert the e-mail validity.
# Email regex used to validate email formats. It asserts that there are no
# @ symbols or whitespaces in either the localpart or the domain, and that
# there is a single @ symbol separating the localpart and the domain.
mattr_accessor :email_regexp
@@email_regexp = /\A[^@\s]+@([^@\s]+\.)+[^@\W]+\z/
@@email_regexp = /\A[^@\s]+@[^@\s]+\z/
# Range validation for password length
mattr_accessor :password_length
@@ -138,19 +145,22 @@ module Devise
@@confirmation_keys = [:email]
# Defines if email should be reconfirmable.
# False by default for backwards compatibility.
mattr_accessor :reconfirmable
@@reconfirmable = false
@@reconfirmable = true
# Time interval to timeout the user session without activity.
mattr_accessor :timeout_in
@@timeout_in = 30.minutes
# Used to encrypt password. Please generate one with rake secret.
# Used to hash the password. Please generate one with rails secret.
mattr_accessor :pepper
@@pepper = nil
# Used to enable sending notification to user when their password is changed
# Used to send notification to the original user email when their email is changed.
mattr_accessor :send_email_changed_notification
@@send_email_changed_notification = false
# Used to enable sending notification to user when their password is changed.
mattr_accessor :send_password_change_notification
@@send_password_change_notification = false
@@ -203,7 +213,7 @@ module Devise
# Skip session storage for the following strategies
mattr_accessor :skip_session_storage
@@skip_session_storage = []
@@skip_session_storage = [:http_auth]
# Which formats should be treated as navigational.
mattr_accessor :navigational_formats
@@ -215,7 +225,7 @@ module Devise
# The default method used while signing out
mattr_accessor :sign_out_via
@@sign_out_via = :get
@@sign_out_via = :delete
# The parent controller all Devise controllers inherits from.
# Defaults to ApplicationController. This should be set early
@@ -244,15 +254,22 @@ module Devise
mattr_accessor :clean_up_csrf_token_on_authentication
@@clean_up_csrf_token_on_authentication = true
# When false, Devise will not attempt to reload routes on eager load.
# This can reduce the time taken to boot the app but if your application
# requires the Devise mappings to be loaded during boot time the application
# won't boot properly.
mattr_accessor :reload_routes
@@reload_routes = true
# PRIVATE CONFIGURATION
# Store scopes mappings.
mattr_reader :mappings
@@mappings = ActiveSupport::OrderedHash.new
@@mappings = {}
# OmniAuth configurations.
mattr_reader :omniauth_configs
@@omniauth_configs = ActiveSupport::OrderedHash.new
@@omniauth_configs = {}
# Define a set of modules that are called when a mapping is added.
mattr_reader :helpers
@@ -276,14 +293,26 @@ module Devise
mattr_accessor :token_generator
@@token_generator = nil
# Default way to setup Devise. Run rails generate devise_install to create
# When set to false, changing a password does not automatically sign in a user
mattr_accessor :sign_in_after_change_password
@@sign_in_after_change_password = true
def self.rails51? # :nodoc:
Rails.gem_version >= Gem::Version.new("5.1.x")
end
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
yield self
end
class Getter
def initialize name
def initialize(name)
@name = name
end
@@ -293,12 +322,8 @@ module Devise
end
def self.ref(arg)
if defined?(ActiveSupport::Dependencies::ClassCache)
ActiveSupport::Dependencies::reference(arg)
Getter.new(arg)
else
ActiveSupport::Dependencies.ref(arg)
end
ActiveSupport::Dependencies.reference(arg)
Getter.new(arg)
end
def self.available_router_name
@@ -419,7 +444,6 @@ module Devise
# config.omniauth :github, APP_ID, APP_SECRET
#
def self.omniauth(provider, *args)
@@helpers << Devise::OmniAuth::UrlHelpers
config = Devise::OmniAuth::Config.new(provider, args)
@@omniauth_configs[config.strategy_name.to_sym] = config
end
@@ -457,10 +481,7 @@ module Devise
mapping.to.serialize_into_session(record)
end
warden_config.serialize_from_session(mapping.name) do |key|
# Previous versions contained an additional entry at the beginning of
# key with the record's class name.
args = key[-2, 2]
warden_config.serialize_from_session(mapping.name) do |args|
mapping.to.serialize_from_session(*args)
end
end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Devise
module Controllers
# Those helpers are convenience methods added to ApplicationController.
@@ -30,8 +32,8 @@ module Devise
# current_bloggers # Currently signed in user and admin
#
# Use:
# before_filter :authenticate_blogger! # Redirects unless either a user or an admin are authenticated
# before_filter ->{ authenticate_blogger! :admin } # Redirects to the admin login page
# before_action :authenticate_blogger! # Redirects unless either a user or an admin are authenticated
# 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={})
@@ -84,7 +86,7 @@ module Devise
end
# Define authentication filters and accessor helpers based on mappings.
# These filters should be used inside the controllers as before_filters,
# These filters should be used inside the controllers as before_actions,
# so you can control the scope of the user who should be signed in to
# access that specific controller/action.
# Example:
@@ -104,8 +106,8 @@ module Devise
# admin_session # Session data available only to the admin scope
#
# Use:
# before_filter :authenticate_user! # Tell devise to use :user map
# before_filter :authenticate_admin! # Tell devise to use :admin map
# before_action :authenticate_user! # Tell devise to use :user map
# before_action :authenticate_admin! # Tell devise to use :admin map
#
def self.define_helpers(mapping) #:nodoc:
mapping = mapping.name
@@ -138,27 +140,23 @@ module Devise
# The main accessor for the warden proxy instance
def warden
request.env['warden']
request.env['warden'] or raise MissingWarden
end
# Return true if it's a devise_controller. false to all controllers unless
# the controllers defined inside devise. Useful if you want to apply a before
# filter to all controllers, except the ones in devise:
#
# before_filter :my_filter, unless: :devise_controller?
# before_action :my_filter, unless: :devise_controller?
def devise_controller?
is_a?(::DeviseController)
end
# Setup a param sanitizer to filter parameters using strong_parameters. See
# Set up a param sanitizer to filter parameters using strong_parameters. See
# lib/devise/parameter_sanitizer.rb for more info. Override this
# method in your application controller to use your own parameter sanitizer.
def devise_parameter_sanitizer
@devise_parameter_sanitizer ||= if defined?(ActionController::StrongParameters)
Devise::ParameterSanitizer.new(resource_class, resource_name, params)
else
Devise::BaseSanitizer.new(resource_class, resource_name, params)
end
@devise_parameter_sanitizer ||= Devise::ParameterSanitizer.new(resource_class, resource_name, params)
end
# Tell warden that params authentication is allowed for that specific page.
@@ -270,21 +268,26 @@ module Devise
# Check if flash messages should be emitted. Default is to do it on
# navigational formats
def is_flashing_format?
is_navigational_format?
request.respond_to?(:flash) && is_navigational_format?
end
private
def expire_session_data_after_sign_in!
ActiveSupport::Deprecation.warn "expire_session_data_after_sign_in! is deprecated " \
"in favor of expire_data_after_sign_in!"
expire_data_after_sign_in!
end
def expire_data_after_sign_out!
Devise.mappings.each { |_,m| instance_variable_set("@current_#{m.name}", nil) }
super
end
end
end
class MissingWarden < StandardError
def initialize
super "Devise could not find the `Warden::Proxy` instance on your request environment.\n" + \
"Make sure that your application is loading Devise and Warden as expected and that " + \
"the `Warden::Manager` middleware is present in your middleware stack.\n" + \
"If you are seeing this on one of your tests, ensure that your tests are either " + \
"executing the Rails middleware stack or that your tests are using the `Devise::Test::ControllerHelpers` " + \
"module to inject the `request.env['warden']` object for you."
end
end
end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Devise
module Controllers
# A module that may be optionally included in a controller in order
@@ -9,11 +11,18 @@ module Devise
Rails.configuration.session_options.slice(:path, :domain, :secure)
end
def remember_me_is_active?(resource)
return false unless resource.respond_to?(:remember_me)
scope = Devise::Mapping.find_scope!(resource)
_, token, generated_at = cookies.signed[remember_key(resource, scope)]
resource.remember_me?(token, generated_at)
end
# Remembers the given resource by setting up a cookie
def remember_me(resource)
return if env["devise.skip_storage"]
return if request.env["devise.skip_storage"]
scope = Devise::Mapping.find_scope!(resource)
resource.remember_me!(resource.extend_remember_period)
resource.remember_me!
cookies.signed[remember_key(resource, scope)] = remember_cookie_values(resource)
end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Devise
module Controllers
module ScopedViews

View File

@@ -1,10 +1,15 @@
# frozen_string_literal: true
module Devise
module Controllers
# Provide sign in and sign out functionality.
# Included by default in all controllers.
module SignInOut
# Return true if the given scope is signed in session. If no scope given, return
# true if any scope is signed in. Does not run authentication hooks.
# true if any scope is signed in. This will run authentication hooks, which may
# cause exceptions to be thrown from this method; if you simply want to check
# if a scope has already previously been authenticated without running
# authentication hooks, you can directly call `warden.authenticated?(scope: scope)`
def signed_in?(scope=nil)
[scope || Devise.mappings.keys].flatten.any? do |_scope|
warden.authenticate?(scope: _scope)
@@ -12,20 +17,18 @@ module Devise
end
# Sign in a user that already was authenticated. This helper is useful for logging
# users in after sign up.
#
# All options given to sign_in is passed forward to the set_user method in warden.
# The only exception is the :bypass option, which bypass warden callbacks and stores
# the user straight in session. This option is useful in cases the user is already
# signed in, but we want to refresh the credentials in session.
# users in after sign up. All options given to sign_in is passed forward
# to the set_user method in warden.
# If you are using a custom warden strategy and the timeoutable module, you have to
# set `env["devise.skip_timeout"] = true` in the request to use this method, like we do
# in the sessions controller: https://github.com/plataformatec/devise/blob/master/app/controllers/devise/sessions_controller.rb#L7
#
# Examples:
#
# sign_in :user, @user # sign_in(scope, resource)
# sign_in @user # sign_in(resource)
# sign_in @user, event: :authentication # sign_in(resource, options)
# sign_in @user, store: false # sign_in(resource, options)
# sign_in @user, bypass: true # sign_in(resource, options)
# sign_in @user, event: :authentication # sign_in(resource, options)
# sign_in @user, store: false # sign_in(resource, options)
#
def sign_in(resource_or_scope, *args)
options = args.extract_options!
@@ -35,6 +38,13 @@ 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)
# Do nothing. User already signed in and we are not forcing it.
@@ -44,6 +54,20 @@ module Devise
end
end
# Sign in a user bypassing the warden callbacks and stores the user
# straight in session. This option is useful in cases the user is already
# signed in, but we want to refresh the credentials in session.
#
# Examples:
#
# bypass_sign_in @user, scope: :user
# bypass_sign_in @user
def bypass_sign_in(resource, scope: nil)
scope ||= Devise::Mapping.find_scope!(resource)
expire_data_after_sign_in!
warden.session_serializer.store(resource, scope)
end
# Sign out a given user or scope. This helper is useful for signing out a user
# after deleting accounts. Returns true if there was a logout and false if there
# is no user logged in on the referred scope
@@ -58,7 +82,6 @@ module Devise
scope = Devise::Mapping.find_scope!(resource_or_scope)
user = warden.user(scope: scope, run_callbacks: false) # If there is no user
warden.raw_session.inspect # Without this inspect here. The session does not clear.
warden.logout(scope)
warden.clear_strategies_cache!(scope: scope)
instance_variable_set(:"@current_#{scope}", nil)

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require "uri"
module Devise
@@ -29,16 +31,13 @@ module Devise
# Example:
#
# store_location_for(:user, dashboard_path)
# redirect_to user_omniauth_authorize_path(:facebook)
# redirect_to user_facebook_omniauth_authorize_path
#
def store_location_for(resource_or_scope, location)
session_key = stored_location_key_for(resource_or_scope)
uri = parse_uri(location)
if uri
path = [uri.path.sub(/\A\/+/, '/'), uri.query].compact.join('?')
path = [path, uri.fragment].compact.join('#')
session[session_key] = path
end
path = extract_path_from_location(location)
session[session_key] = path if path
end
private
@@ -53,6 +52,25 @@ module Devise
scope = Devise::Mapping.find_scope!(resource_or_scope)
"#{scope}_return_to"
end
def extract_path_from_location(location)
uri = parse_uri(location)
if uri
path = remove_domain_from_uri(uri)
path = add_fragment_back_to_path(uri, path)
path
end
end
def remove_domain_from_uri(uri)
[uri.path.sub(/\A\/+/, '/'), uri.query].compact.join('?')
end
def add_fragment_back_to_path(uri, path)
[path, uri.fragment].compact.join('#')
end
end
end
end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Devise
module Controllers
# Create url helpers to be used with resource/scope configuration. Acts as

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Devise
# Checks the scope in the given environment and returns the associated failure app.
class Delegator

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'bcrypt'
module Devise
@@ -9,14 +11,14 @@ module Devise
::BCrypt::Password.create(password, cost: klass.stretches).to_s
end
def self.compare(klass, encrypted_password, password)
return false if encrypted_password.blank?
bcrypt = ::BCrypt::Password.new(encrypted_password)
def self.compare(klass, hashed_password, password)
return false if hashed_password.blank?
bcrypt = ::BCrypt::Password.new(hashed_password)
if klass.pepper.present?
password = "#{password}#{klass.pepper}"
end
password = ::BCrypt::Engine.hash_secret(password, bcrypt.salt)
Devise.secure_compare(password, encrypted_password)
Devise.secure_compare(password, hashed_password)
end
end
end

View File

@@ -1,12 +1,13 @@
# frozen_string_literal: true
require "action_controller/metal"
module Devise
# Failure application that will be called every time :warden is thrown from
# any strategy or hook. Responsible for redirect the user to the sign in
# page based on current scope and mapping. If no scope is given, redirect
# to the default_url.
# any strategy or hook. It is responsible for redirecting the user to the sign
# in page based on current scope and mapping. If no scope is given, it
# redirects to the default_url.
class FailureApp < ActionController::Metal
include ActionController::RackDelegation
include ActionController::UrlFor
include ActionController::Redirecting
@@ -22,7 +23,7 @@ module Devise
@respond.call(env)
end
# Try retrieving the URL options from the parent controller (usually
# Try retrieving the URL options from the parent controller (usually
# ApplicationController). Instance methods are not supported at the moment,
# so only the class-level attribute is used.
def self.default_url_options(*args)
@@ -51,20 +52,27 @@ module Devise
end
def recall
config = Rails.application.config
if config.try(:relative_url_root)
base_path = Pathname.new(config.relative_url_root)
header_info = if relative_url_root?
base_path = Pathname.new(relative_url_root)
full_path = Pathname.new(attempted_path)
env["SCRIPT_NAME"] = config.relative_url_root
env["PATH_INFO"] = '/' + full_path.relative_path_from(base_path).to_s
{ "SCRIPT_NAME" => relative_url_root,
"PATH_INFO" => '/' + full_path.relative_path_from(base_path).to_s }
else
env["PATH_INFO"] = attempted_path
{ "PATH_INFO" => attempted_path }
end
header_info.each do | var, value|
if request.respond_to?(:set_header)
request.set_header(var, value)
else
request.env[var] = value
end
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(env)
self.response = recall_app(warden_options[:recall]).call(request.env)
end
def redirect
@@ -95,7 +103,7 @@ 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
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"))
options = i18n_options(options)
@@ -127,23 +135,29 @@ module Devise
def scope_url
opts = {}
# Initialize script_name with nil to prevent infinite loops in
# authenticated mounted engines in rails 4.2 and 5.0
opts[:script_name] = nil
route = route(scope)
opts[:format] = request_format unless skip_format?
config = Rails.application.config
# Rails 4.2 goes into an infinite loop if opts[:script_name] is unset
if (Rails::VERSION::MAJOR >= 4) && (Rails::VERSION::MINOR >= 2)
opts[:script_name] = (config.relative_url_root if config.respond_to?(:relative_url_root))
else
if config.respond_to?(:relative_url_root) && config.relative_url_root.present?
opts[:script_name] = config.relative_url_root
end
end
router_name = Devise.mappings[scope].router_name || Devise.available_router_name
context = send(router_name)
if relative_url_root?
opts[:script_name] = relative_url_root
# We need to add the rootpath to `script_name` manually for applications that use a Rails
# version lower than 5.1. Otherwise, it is going to generate a wrong path for Engines
# that use Devise. Remove it when the support of Rails 5.0 is droped.
elsif root_path_defined?(context) && !rails_51_and_up?
rootpath = context.routes.url_helpers.root_path
opts[:script_name] = rootpath.chomp('/') if rootpath.length > 1
end
if context.respond_to?(route)
context.send(route, opts)
elsif respond_to?(:root_url)
@@ -157,12 +171,12 @@ module Devise
%w(html */*).include? request_format.to_s
end
# Choose whether we should respond in a http authentication fashion,
# Choose whether we should respond in an HTTP authentication fashion,
# including 401 and optional headers.
#
# This method allows the user to explicitly disable http authentication
# on ajax requests in case they want to redirect on failures instead of
# handling the errors on their own. This is useful in case your ajax API
# This method allows the user to explicitly disable HTTP authentication
# on AJAX requests in case they want to redirect on failures instead of
# handling the errors on their own. This is useful in case your AJAX API
# is the same as your public API and uses a format like JSON (so you
# cannot mark JSON as a navigational format).
def http_auth?
@@ -173,7 +187,7 @@ module Devise
end
end
# It does not make sense to send authenticate headers in ajax requests
# It doesn't make sense to send authenticate headers in AJAX requests
# or if the user disabled them.
def http_auth_header?
scope_class.http_authenticatable && !request.xhr?
@@ -199,11 +213,11 @@ module Devise
end
def warden
env['warden']
request.respond_to?(:get_header) ? request.get_header("warden") : request.env["warden"]
end
def warden_options
env['warden.options']
request.respond_to?(:get_header) ? request.get_header("warden.options") : request.env["warden.options"]
end
def warden_message
@@ -222,10 +236,10 @@ module Devise
warden_options[:attempted_path]
end
# Stores requested uri to redirect the user after signing in. We cannot use
# scoped session provided by warden here, since the user is not authenticated
# yet, but we still need to store the uri based on scope, so different scopes
# would never use the same uri to redirect.
# Stores requested URI to redirect the user after signing in. We can't use
# the scoped session provided by warden here, since the user is not
# authenticated yet, but we still need to store the URI based on scope, so
# different scopes would never use the same URI to redirect.
def store_location!
store_location_for(scope, attempted_path) if request.get? && !http_auth?
end
@@ -237,11 +251,35 @@ module Devise
# Check if flash messages should be emitted. Default is to do it on
# navigational formats
def is_flashing_format?
is_navigational_format?
request.respond_to?(:flash) && is_navigational_format?
end
def request_format
@request_format ||= request.format.try(:ref)
end
def relative_url_root
@relative_url_root ||= begin
config = Rails.application.config
config.try(:relative_url_root) || config.action_controller.try(:relative_url_root)
end
end
def relative_url_root?
relative_url_root.present?
end
ActiveSupport.run_load_hooks(:devise_failure_app, self)
private
def root_path_defined?(context)
defined?(context.routes) && context.routes.url_helpers.respond_to?(:root_path)
end
def rails_51_and_up?
Rails.gem_version >= Gem::Version.new("5.1")
end
end
end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
# Deny user access whenever their account is not active yet.
# We need this as hook to validate the user activity on each request
# and in case the user is using other strategies beside Devise ones.

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
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?

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
# Before logout hook to forget the user in the given scope, if it responds
# to forget_me! Also clear remember token to ensure the user won't be
# remembered again. Notice that we forget the user unless the record is not persisted.

View File

@@ -1,7 +1,12 @@
# frozen_string_literal: true
# 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])
record.update_attribute(:failed_attempts, 0) unless record.failed_attempts.to_i.zero?
unless record.failed_attempts.to_i.zero?
record.failed_attempts = 0
record.save(validate: false)
end
end
end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Devise
module Hooks
# A small warden proxy so we can remember, forget and
@@ -7,7 +9,7 @@ module Devise
include Devise::Controllers::SignInOut
attr_reader :warden
delegate :cookies, :env, to: :warden
delegate :cookies, :request, to: :warden
def initialize(warden)
@warden = warden

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
Warden::Manager.after_set_user except: :fetch do |record, warden, options|
scope = options[:scope]
if record.respond_to?(:remember_me) && options[:store] != false &&

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
# Each time a record is set we check whether its session has already timed out
# or not, based on last request time. If so, the record is logged out and
# redirected to the sign in page. Also, each time the request comes and the
@@ -19,9 +21,10 @@ 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 record.timedout?(last_request_at) &&
!env['devise.skip_timeout'] &&
!proxy.remember_me_is_active?(record)
Devise.sign_out_all_scopes ? proxy.sign_out : proxy.sign_out(scope)
throw :warden, scope: scope, message: :timeout
end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
# After each sign in, update sign in time, sign in count and sign in IP.
# This is only triggered when the user is explicitly set (with set_user)
# and on authentication. Retrieving the user from session (:fetch) does

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Devise
module Mailers
module Helpers
@@ -5,15 +7,16 @@ module Devise
included do
include Devise::Controllers::ScopedViews
attr_reader :scope_name, :resource
end
protected
attr_reader :scope_name, :resource
# Configure default email options
def devise_mail(record, action, opts={})
def devise_mail(record, action, opts = {}, &block)
initialize_from_record(record)
mail headers_for(action, opts)
mail headers_for(action, opts), &block
end
def initialize_from_record(record)
@@ -64,7 +67,7 @@ module Devise
template_path
end
# Setup a subject doing an I18n lookup. At first, it attempts to set a subject
# Set up a subject doing an I18n lookup. At first, it attempts to set a subject
# based on the current mapping:
#
# en:

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Devise
# Responsible for handling devise mappings and routes configuration. Each
# resource configured by devise_for in routes is actually creating a mapping

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Devise
module Models
class MissingAttribute < StandardError
@@ -12,7 +14,7 @@ module Devise
# Creates configuration values for Devise and for the given module.
#
# Devise::Models.config(Devise::DatabaseAuthenticatable, :stretches)
# Devise::Models.config(Devise::Models::DatabaseAuthenticatable, :stretches)
#
# The line above creates:
#

View File

@@ -1,4 +1,5 @@
require 'active_model/version'
# frozen_string_literal: true
require 'devise/hooks/activatable'
require 'devise/hooks/csrf_cleaner'
@@ -102,7 +103,7 @@ module Devise
# and passing a new list of attributes you want to exempt. All attributes
# given to :except will simply add names to exempt to Devise internal list.
def serializable_hash(options = nil)
options ||= {}
options = options.try(:dup) || {}
options[:except] = Array(options[:except])
if options[:force_except]
@@ -114,6 +115,15 @@ module Devise
super(options)
end
# Redefine inspect using serializable_hash, to ensure we don't accidentally
# leak passwords into exceptions.
def inspect
inspection = serializable_hash.collect do |k,v|
"#{k}: #{respond_to?(:attribute_for_inspect) ? attribute_for_inspect(k) : v.inspect}"
end
"#<#{self.class} #{inspection.join(", ")}>"
end
protected
def devise_mailer
@@ -123,16 +133,18 @@ module Devise
# This is an internal method called every time Devise needs
# to send a notification/mail. This can be overridden if you
# need to customize the e-mail delivery logic. For instance,
# if you are using a queue to deliver e-mails (delayed job,
# sidekiq, resque, etc), you must add the delivery to the queue
# if you are using a queue to deliver e-mails (active job, delayed
# job, sidekiq, resque, etc), you must add the delivery to the queue
# just after the transaction was committed. To achieve this,
# you can override send_devise_notification to store the
# deliveries until the after_commit callback is triggered:
# deliveries until the after_commit callback is triggered.
#
# The following example uses Active Job's `deliver_later` :
#
# class User
# devise :database_authenticatable, :confirmable
#
# after_commit :send_pending_notifications
# after_commit :send_pending_devise_notifications
#
# protected
#
@@ -140,27 +152,45 @@ module Devise
# # If the record is new or changed then delay the
# # delivery until the after_commit callback otherwise
# # send now because after_commit will not be called.
# if new_record? || changed?
# pending_notifications << [notification, args]
# # For Rails < 6 is `changed?` instead of `saved_changes?`.
# if new_record? || saved_changes?
# pending_devise_notifications << [notification, args]
# else
# devise_mailer.send(notification, self, *args).deliver
# render_and_send_devise_message(notification, *args)
# end
# end
#
# def send_pending_notifications
# pending_notifications.each do |notification, args|
# devise_mailer.send(notification, self, *args).deliver
# private
#
# def send_pending_devise_notifications
# pending_devise_notifications.each do |notification, args|
# render_and_send_devise_message(notification, *args)
# end
#
# # Empty the pending notifications array because the
# # after_commit hook can be called multiple times which
# # could cause multiple emails to be sent.
# pending_notifications.clear
# pending_devise_notifications.clear
# end
#
# def pending_notifications
# @pending_notifications ||= []
# def pending_devise_notifications
# @pending_devise_notifications ||= []
# end
#
# def render_and_send_devise_message(notification, *args)
# message = devise_mailer.send(notification, self, *args)
#
# # Deliver later with Active Job's `deliver_later`
# if message.respond_to?(:deliver_later)
# message.deliver_later
# # Remove once we move to Rails 4.2+ only, as `deliver` is deprecated.
# elsif message.respond_to?(:deliver_now)
# message.deliver_now
# else
# message.deliver
# end
# end
#
# end
#
def send_devise_notification(notification, *args)
@@ -235,7 +265,7 @@ module Devise
# end
#
# Finally, notice that Devise also queries for users in other scenarios
# besides authentication, for example when retrieving an user to send
# besides authentication, for example when retrieving a user to send
# an e-mail for password reset. In such cases, find_for_authentication
# is not called.
def find_for_authentication(tainted_conditions)
@@ -253,24 +283,20 @@ module Devise
# Find or initialize a record with group of attributes based on a list of required attributes.
def find_or_initialize_with_errors(required_attributes, attributes, error=:invalid) #:nodoc:
attributes = attributes.slice(*required_attributes).with_indifferent_access
attributes.delete_if { |key, value| value.blank? }
attributes.try(:permit!)
attributes = attributes.to_h.with_indifferent_access
.slice(*required_attributes)
.delete_if { |key, value| value.blank? }
if attributes.size == required_attributes.size
record = find_first_by_auth_conditions(attributes)
record = find_first_by_auth_conditions(attributes) and return record
end
unless record
record = new
new(devise_parameter_filter.filter(attributes)).tap do |record|
required_attributes.each do |key|
value = attributes[key]
record.send("#{key}=", value)
record.errors.add(key, value.present? ? error : :blank)
record.errors.add(key, attributes[key].blank? ? :blank : error)
end
end
record
end
protected

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Devise
module Models
# Confirmable is responsible to verify if an account is already confirmed to
@@ -24,9 +26,11 @@ module Devise
# By default allow_unconfirmed_access_for is zero, it means users always have to confirm to sign in.
# * +reconfirmable+: requires any email changes to be confirmed (exactly the same way as
# initial account confirmation) to be applied. Requires additional unconfirmed_email
# db field to be setup (t.reconfirmable in migrations). Until confirmed, new email is
# db field to be set up (t.reconfirmable in migrations). Until confirmed, new email is
# stored in unconfirmed email column, and copied to email column on successful
# confirmation.
# 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.
# * +confirm_within+: the time before a sent confirmation token becomes invalid.
# You can use this to force the user to confirm within a set period of time.
# Confirmable will not generate a new token if a repeat confirmation is requested
@@ -40,17 +44,23 @@ module Devise
#
module Confirmable
extend ActiveSupport::Concern
include ActionView::Helpers::DateHelper
included do
before_create :generate_confirmation_token, if: :confirmation_required?
after_create :send_on_create_confirmation_instructions, if: :send_confirmation_notification?
after_create :skip_reconfirmation_in_callback!, if: :send_confirmation_notification?
if defined?(ActiveRecord) && self < ActiveRecord::Base # ActiveRecord
after_commit :send_on_create_confirmation_instructions, on: :create, if: :send_confirmation_notification?
after_commit :send_reconfirmation_instructions, on: :update, if: :reconfirmation_required?
else # Mongoid
after_create :send_on_create_confirmation_instructions, if: :send_confirmation_notification?
after_update :send_reconfirmation_instructions, if: :reconfirmation_required?
end
before_update :postpone_email_change_until_confirmation_and_regenerate_confirmation_token, if: :postpone_email_change?
after_update :send_reconfirmation_instructions, if: :reconfirmation_required?
end
def initialize(*args, &block)
@bypass_confirmation_postpone = false
@skip_reconfirmation_in_callback = false
@reconfirmation_required = false
@skip_confirmation_notification = false
@raw_confirmation_token = nil
@@ -76,7 +86,7 @@ module Devise
self.confirmed_at = Time.now.utc
saved = if self.class.reconfirmable && unconfirmed_email.present?
saved = if pending_reconfirmation?
skip_reconfirmation!
self.email = unconfirmed_email
self.unconfirmed_email = nil
@@ -92,11 +102,6 @@ module Devise
end
end
def confirm!(args={})
ActiveSupport::Deprecation.warn "confirm! is deprecated in favor of confirm"
confirm(args)
end
# Verifies whether a user is confirmed or not
def confirmed?
!!confirmed_at
@@ -165,6 +170,12 @@ module Devise
protected
# To not require reconfirmation after creating with #save called in a
# callback call skip_create_confirmation!
def skip_reconfirmation_in_callback!
@skip_reconfirmation_in_callback = true
end
# A callback method used to deliver confirmation
# instructions on creation. This can be overridden
# in models to map to a nice sign up e-mail.
@@ -180,7 +191,7 @@ module Devise
# Checks if the confirmation for the user is within the limit time.
# We do this by calculating if the difference between today and the
# confirmation sent date does not exceed the confirm in time configured.
# Confirm_within is a model configuration, must always be an integer value.
# allow_unconfirmed_access_for is a model configuration, must always be an integer value.
#
# Example:
#
@@ -200,7 +211,10 @@ module Devise
# confirmation_period_valid? # will always return true
#
def confirmation_period_valid?
self.class.allow_unconfirmed_access_for.nil? || (confirmation_sent_at && confirmation_sent_at.utc >= self.class.allow_unconfirmed_access_for.ago)
return true if self.class.allow_unconfirmed_access_for.nil?
return false if self.class.allow_unconfirmed_access_for == 0.days
confirmation_sent_at && confirmation_sent_at.utc >= self.class.allow_unconfirmed_access_for.ago
end
# Checks if the user confirmation happens before the token becomes invalid
@@ -216,7 +230,7 @@ module Devise
# confirmation_period_expired? # will always return false
#
def confirmation_period_expired?
self.class.confirm_within && self.confirmation_sent_at && (Time.now > self.confirmation_sent_at + self.class.confirm_within)
self.class.confirm_within && self.confirmation_sent_at && (Time.now.utc > self.confirmation_sent_at.utc + self.class.confirm_within)
end
# Checks whether the record requires any confirmation.
@@ -235,8 +249,7 @@ module Devise
if self.confirmation_token && !confirmation_period_expired?
@raw_confirmation_token = self.confirmation_token
else
raw, _ = Devise.token_generator.generate(self.class, :confirmation_token)
self.confirmation_token = @raw_confirmation_token = raw
self.confirmation_token = @raw_confirmation_token = Devise.friendly_token
self.confirmation_sent_at = Time.now.utc
end
end
@@ -245,28 +258,64 @@ module Devise
generate_confirmation_token && save(validate: false)
end
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
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
end
def postpone_email_change?
postpone = self.class.reconfirmable && email_changed? && !@bypass_confirmation_postpone && self.email.present?
@bypass_confirmation_postpone = false
postpone
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
end
def reconfirmation_required?
self.class.reconfirmable && @reconfirmation_required && self.email.present?
self.class.reconfirmable && @reconfirmation_required && (self.email.present? || self.unconfirmed_email.present?)
end
def send_confirmation_notification?
confirmation_required? && !@skip_confirmation_notification && self.email.present?
end
# With reconfirmable, notify the original email when the user first
# requests the email change, instead of when the change is confirmed.
def send_email_changed_notification?
if self.class.reconfirmable
self.class.send_email_changed_notification && reconfirmation_required?
else
super
end
end
# A callback initiated after successfully confirming. This can be
# used to insert your own logic that is only run after the user successfully
# confirms.
@@ -299,7 +348,19 @@ module Devise
# If the user is already confirmed, create an error for the user
# Options must have the confirmation_token
def confirm_by_token(confirmation_token)
# When the `confirmation_token` parameter is blank, if there are any users with a blank
# `confirmation_token` in the database, the first one would be confirmed here.
# The error is being manually added here to ensure no users are confirmed by mistake.
# This was done in the model for convenience, since validation errors are automatically
# displayed in the view.
if confirmation_token.blank?
confirmable = new
confirmable.errors.add(:confirmation_token, :blank)
return confirmable
end
confirmable = find_first_by_auth_conditions(confirmation_token: confirmation_token)
unless confirmable
confirmation_digest = Devise.token_generator.digest(self, :confirmation_token, confirmation_token)
confirmable = find_or_initialize_with_error_by(:confirmation_token, confirmation_digest)
@@ -315,6 +376,7 @@ module Devise
# Find a record for confirmation by unconfirmed email field
def find_by_unconfirmed_email_with_errors(attributes = {})
attributes = attributes.slice(*confirmation_keys).permit!.to_h if attributes.respond_to? :permit
unconfirmed_required_attributes = confirmation_keys.map { |k| k == :email ? :unconfirmed_email : k }
unconfirmed_attributes = attributes.symbolize_keys
unconfirmed_attributes[:unconfirmed_email] = unconfirmed_attributes.delete(:email)

View File

@@ -1,24 +1,25 @@
# frozen_string_literal: true
require 'devise/strategies/database_authenticatable'
module Devise
def self.bcrypt(klass, password)
ActiveSupport::Deprecation.warn "Devise.bcrypt is deprecated; use Devise::Encryptor.digest instead"
Devise::Encryptor.digest(klass, password)
end
module Models
# Authenticatable Module, responsible for encrypting password and validating
# authenticity of a user while signing in.
# Authenticatable Module, responsible for hashing the password and
# validating the authenticity of a user while signing in.
#
# == Options
#
# DatabaseAuthenticatable adds the following options to devise_for:
#
# * +pepper+: a random string used to provide a more secure hash. Use
# `rake secret` to generate new keys.
# `rails secret` to generate new keys.
#
# * +stretches+: the cost given to bcrypt.
#
# * +send_email_changed_notification+: notify original email when it changes.
#
# * +send_password_change_notification+: notify email when password changes.
#
# == Examples
#
# User.find(1).valid_password?('password123') # returns true/false
@@ -27,17 +28,36 @@ module Devise
extend ActiveSupport::Concern
included do
after_update :send_email_changed_notification, if: :send_email_changed_notification?
after_update :send_password_change_notification, if: :send_password_change_notification?
attr_reader :password, :current_password
attr_accessor :password_confirmation
end
def initialize(*args, &block)
@skip_email_changed_notification = false
@skip_password_change_notification = false
super
end
# Skips sending the email changed notification after_update
def skip_email_changed_notification!
@skip_email_changed_notification = true
end
# Skips sending the password change notification after_update
def skip_password_change_notification!
@skip_password_change_notification = true
end
def self.required_fields(klass)
[:encrypted_password] + klass.authentication_keys
end
# Generates password encryption based on the given value.
# Generates a hashed password based on the given value.
# For legacy reasons, we use `encrypted_password` to store
# the hashed password.
def password=(new_password)
@password = new_password
self.encrypted_password = password_digest(@password) if @password.present?
@@ -61,6 +81,15 @@ module Devise
# their password). In case the password field is rejected, the confirmation
# is also rejected as long as it is also blank.
def update_with_password(params, *options)
if options.present?
ActiveSupport::Deprecation.warn <<-DEPRECATION.strip_heredoc
[Devise] The second argument of `DatabaseAuthenticatable#update_with_password`
(`options`) is deprecated and it will be removed in the next major version.
It was added to support a feature deprecated in Rails 4, so you can safely remove it
from your code.
DEPRECATION
end
current_password = params.delete(:current_password)
if params[:password].blank?
@@ -69,11 +98,11 @@ module Devise
end
result = if valid_password?(current_password)
update_attributes(params, *options)
update(params, *options)
else
self.assign_attributes(params, *options)
self.valid?
self.errors.add(:current_password, current_password.blank? ? :blank : :invalid)
assign_attributes(params, *options)
valid?
errors.add(:current_password, current_password.blank? ? :blank : :invalid)
false
end
@@ -94,10 +123,19 @@ module Devise
# end
#
def update_without_password(params, *options)
if options.present?
ActiveSupport::Deprecation.warn <<-DEPRECATION.strip_heredoc
[Devise] The second argument of `DatabaseAuthenticatable#update_without_password`
(`options`) is deprecated and it will be removed in the next major version.
It was added to support a feature deprecated in Rails 4, so you can safely remove it
from your code.
DEPRECATION
end
params.delete(:password)
params.delete(:password_confirmation)
result = update_attributes(params, *options)
result = update(params, *options)
clean_up_passwords
result
end
@@ -109,8 +147,8 @@ module Devise
result = if valid_password?(current_password)
destroy
else
self.valid?
self.errors.add(:current_password, current_password.blank? ? :blank : :invalid)
valid?
errors.add(:current_password, current_password.blank? ? :blank : :invalid)
false
end
@@ -135,27 +173,56 @@ 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
end
# Send notification to user when password changes.
def send_password_change_notification
send_devise_notification(:password_change)
end
protected
# Digests the password using bcrypt. Custom encryption should override
# 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
# of other encryption engines.
# of other hashing engines.
def password_digest(password)
Devise::Encryptor.digest(self.class, password)
end
def send_password_change_notification?
self.class.send_password_change_notification && encrypted_password_changed?
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
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
end
module ClassMethods
Devise::Models.config(self, :pepper, :stretches, :send_password_change_notification)
Devise::Models.config(self, :pepper, :stretches, :send_email_changed_notification, :send_password_change_notification)
# We assume this method already gets the sanitized values from the
# DatabaseAuthenticatable strategy. If you are using this method on

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require "devise/hooks/lockable"
module Devise
@@ -7,7 +9,7 @@ module Devise
# blocked: email and time. The former will send an email to the user when
# the lock happens, containing a link to unlock its account. The second
# will unlock the user automatically after some configured time (ie 2.hours).
# It's also possible to setup lockable to use both email and time strategies.
# It's also possible to set up lockable to use both email and time strategies.
#
# == Options
#
@@ -64,7 +66,7 @@ module Devise
def send_unlock_instructions
raw, enc = Devise.token_generator.generate(self.class, :unlock_token)
self.unlock_token = enc
self.save(validate: false)
save(validate: false)
send_devise_notification(:unlock_instructions, raw, {})
raw
end
@@ -99,8 +101,7 @@ module Devise
if super && !access_locked?
true
else
self.failed_attempts ||= 0
self.failed_attempts += 1
increment_failed_attempts
if attempts_exceeded?
lock_access! unless access_locked?
else
@@ -109,6 +110,11 @@ module Devise
false
end
end
def increment_failed_attempts
self.class.increment_counter(:failed_attempts, id)
reload
end
def unauthenticated_message
# If set to paranoid mode, do not show the locked message because it
@@ -155,6 +161,9 @@ module Devise
end
module ClassMethods
# List of strategies that are enabled/supported if :both is used.
BOTH_STRATEGIES = [:time, :email]
# Attempt to find a user by its unlock keys. If a record is found, send new
# unlock instructions to it. If not user is found, returns a new user
# with an email not found error.
@@ -181,7 +190,8 @@ module Devise
# Is the unlock enabled for the given unlock strategy?
def unlock_strategy_enabled?(strategy)
[:both, strategy].include?(self.unlock_strategy)
self.unlock_strategy == strategy ||
(self.unlock_strategy == :both && BOTH_STRATEGIES.include?(strategy))
end
# Is the lock enabled for the given lock strategy?

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'devise/omniauth'
module Devise

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Devise
module Models
@@ -27,30 +29,20 @@ module Devise
end
included do
before_update do
if (respond_to?(:email_changed?) && email_changed?) || encrypted_password_changed?
clear_reset_password_token
end
end
before_update :clear_reset_password_token, if: :clear_reset_password_token?
end
# Update password saving the record and clearing token. Returns true if
# the passwords are valid and the record was saved, false otherwise.
def reset_password(new_password, new_password_confirmation)
self.password = new_password
self.password_confirmation = new_password_confirmation
if respond_to?(:after_password_reset) && valid?
ActiveSupport::Deprecation.warn "after_password_reset is deprecated"
after_password_reset
if new_password.present?
self.password = new_password
self.password_confirmation = new_password_confirmation
save
else
errors.add(:password, :blank)
false
end
save
end
def reset_password!(new_password, new_password_confirmation)
ActiveSupport::Deprecation.warn "reset_password! is deprecated in favor of reset_password"
reset_password(new_password, new_password_confirmation)
end
# Resets reset password token and send reset password instructions by email.
@@ -83,7 +75,7 @@ module Devise
# reset_password_period_valid? # will always return false
#
def reset_password_period_valid?
reset_password_sent_at && reset_password_sent_at.utc >= self.class.reset_password_within.ago
reset_password_sent_at && reset_password_sent_at.utc >= self.class.reset_password_within.ago.utc
end
protected
@@ -99,7 +91,7 @@ module Devise
self.reset_password_token = enc
self.reset_password_sent_at = Time.now.utc
self.save(validate: false)
save(validate: false)
raw
end
@@ -107,6 +99,26 @@ 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
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
end
module ClassMethods
# Attempt to find a user by password reset token. If a user is found, return it
# If a user is not found, return nil

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Devise
module Models
# Registerable is responsible for everything related to registering a new
@@ -19,6 +21,8 @@ module Devise
def new_with_session(params, session)
new(params)
end
Devise::Models.config(self, :sign_in_after_change_password)
end
end
end

View File

@@ -1,10 +1,12 @@
# frozen_string_literal: true
require 'devise/strategies/rememberable'
require 'devise/hooks/rememberable'
require 'devise/hooks/forgetable'
module Devise
module Models
# Rememberable manages generating and clearing token for remember the user
# Rememberable manages generating and clearing token for remembering the user
# from a saved cookie. Rememberable also has utility methods for dealing
# with serializing the user into the cookie and back from the cookie, trying
# to lookup the record based on the saved information.
@@ -39,17 +41,15 @@ module Devise
module Rememberable
extend ActiveSupport::Concern
attr_accessor :remember_me, :extend_remember_period
attr_accessor :remember_me
def self.required_fields(klass)
[:remember_created_at]
end
# Generate a new remember token and save the record without validations
# if remember expired (token is no longer valid) or extend_remember_period is true
def remember_me!(extend_period=false)
self.remember_token = self.class.remember_token if generate_remember_token?
self.remember_created_at = Time.now.utc if generate_remember_timestamp?(extend_period)
def remember_me!
self.remember_token ||= self.class.remember_token if respond_to?(:remember_token)
self.remember_created_at ||= Time.now.utc
save(validate: false) if self.changed?
end
@@ -57,19 +57,17 @@ module Devise
# it exists), and save the record without validations.
def forget_me!
return unless persisted?
self.remember_token = nil if respond_to?(:remember_token=)
self.remember_token = nil if respond_to?(:remember_token)
self.remember_created_at = nil if self.class.expire_all_remember_me_on_sign_out
save(validate: false)
end
# Remember token should be expired if expiration time not overpass now.
def remember_expired?
remember_created_at.nil? || (remember_expires_at <= Time.now.utc)
def remember_expires_at
self.class.remember_for.from_now
end
# Remember token expires at created time + remember_for configuration
def remember_expires_at
remember_created_at + self.class.remember_for
def extend_remember_period
self.class.extend_remember_period
end
def rememberable_value
@@ -78,7 +76,7 @@ module Devise
elsif respond_to?(:authenticatable_salt) && (salt = authenticatable_salt.presence)
salt
else
raise "authenticable_salt returned nil for the #{self.class.name} model. " \
raise "authenticatable_salt returned nil for the #{self.class.name} model. " \
"In order to use rememberable, you must ensure a password is always set " \
"or have a remember_token column in your model or implement your own " \
"rememberable_value in the model with custom logic."
@@ -102,29 +100,47 @@ module Devise
def after_remembered
end
protected
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
if generated_at.is_a?(String)
generated_at = time_from_json(generated_at)
end
def generate_remember_token? #:nodoc:
respond_to?(:remember_token) && remember_expired?
# The token is only valid if:
# 1. we have a date
# 2. the current time does not pass the expiry period
# 3. the record has a remember_created_at date
# 4. the token date is bigger than the remember_created_at
# 5. the token matches
generated_at.is_a?(Time) &&
(self.class.remember_for.ago < generated_at) &&
(generated_at > (remember_created_at || Time.now).utc) &&
Devise.secure_compare(rememberable_value, token)
end
# Generate a timestamp if extend_remember_period is true, if no remember_token
# exists, or if an existing remember token has expired.
def generate_remember_timestamp?(extend_period) #:nodoc:
extend_period || remember_expired?
private
def time_from_json(value)
if value =~ /\A\d+\.\d+\Z/
Time.at(value.to_f)
else
Time.parse(value) rescue nil
end
end
module ClassMethods
# Create the cookie key using the record id and remember_token
def serialize_into_cookie(record)
[record.to_key, record.rememberable_value]
[record.to_key, record.rememberable_value, Time.now.utc.to_f.to_s]
end
# Recreate the user based on the stored cookie
def serialize_from_cookie(id, remember_token)
def serialize_from_cookie(*args)
id, token, generated_at = *args
record = to_adapter.get(id)
record if record && !record.remember_expired? &&
Devise.secure_compare(record.rememberable_value, remember_token)
record if record && record.remember_me?(token, generated_at)
end
# Generate a token checking if one does not already exist in the database.

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'devise/hooks/timeoutable'
module Devise
@@ -26,7 +28,6 @@ module Devise
# Checks whether the user session has expired based on configured time.
def timedout?(last_access)
return false if remember_exists_and_not_expired?
!timeout_in.nil? && last_access && last_access <= timeout_in.ago
end
@@ -36,11 +37,6 @@ module Devise
private
def remember_exists_and_not_expired?
return false unless respond_to?(:remember_created_at) && respond_to?(:remember_expired?)
remember_created_at && !remember_expired?
end
module ClassMethods
Devise::Models.config(self, :timeout_in)
end

View File

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

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Devise
module Models
# Validatable creates all needed validations for a user email and password.
@@ -10,7 +12,7 @@ module Devise
# Validatable adds the following options to devise_for:
#
# * +email_regexp+: the regular expression used to validate e-mails;
# * +password_length+: a range expressing password length. Defaults to 8..72.
# * +password_length+: a range expressing password length. Defaults to 6..128.
#
module Validatable
# All validations used by this module.
@@ -27,8 +29,13 @@ module Devise
base.class_eval do
validates_presence_of :email, if: :email_required?
validates_uniqueness_of :email, allow_blank: true, if: :email_changed?
validates_format_of :email, with: email_regexp, allow_blank: true, if: :email_changed?
if Devise.activerecord51?
validates_uniqueness_of :email, allow_blank: true, case_sensitive: true, if: :will_save_change_to_email?
validates_format_of :email, with: email_regexp, allow_blank: true, if: :will_save_change_to_email?
else
validates_uniqueness_of :email, allow_blank: true, if: :email_changed?
validates_format_of :email, with: email_regexp, allow_blank: true, if: :email_changed?
end
validates_presence_of :password, if: :password_required?
validates_confirmation_of :password, if: :password_required?

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'active_support/core_ext/object/with_options'
Devise.with_options model: true do |d|

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
begin
require "omniauth"
require "omniauth/version"

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Devise
module OmniAuth
class StrategyNotFound < NameError

View File

@@ -1,17 +1,26 @@
# frozen_string_literal: true
module Devise
module OmniAuth
module UrlHelpers
def self.define_helpers(mapping)
def omniauth_authorize_path(resource_or_scope, provider, *args)
scope = Devise::Mapping.find_scope!(resource_or_scope)
_devise_route_context.send("#{scope}_#{provider}_omniauth_authorize_path", *args)
end
def omniauth_authorize_path(resource_or_scope, *args)
def omniauth_authorize_url(resource_or_scope, provider, *args)
scope = Devise::Mapping.find_scope!(resource_or_scope)
_devise_route_context.send("#{scope}_omniauth_authorize_path", *args)
_devise_route_context.send("#{scope}_#{provider}_omniauth_authorize_url", *args)
end
def omniauth_callback_path(resource_or_scope, *args)
def omniauth_callback_path(resource_or_scope, provider, *args)
scope = Devise::Mapping.find_scope!(resource_or_scope)
_devise_route_context.send("#{scope}_omniauth_callback_path", *args)
_devise_route_context.send("#{scope}_#{provider}_omniauth_callback_path", *args)
end
def omniauth_callback_url(resource_or_scope, provider, *args)
scope = Devise::Mapping.find_scope!(resource_or_scope)
_devise_route_context.send("#{scope}_#{provider}_omniauth_callback_url", *args)
end
end
end

View File

@@ -1,3 +1,7 @@
# frozen_string_literal: true
require 'orm_adapter/adapters/active_record'
ActiveRecord::Base.extend Devise::Models
ActiveSupport.on_load(:active_record) do
extend Devise::Models
end

View File

@@ -1,3 +1,7 @@
require 'orm_adapter/adapters/mongoid'
# frozen_string_literal: true
Mongoid::Document::ClassMethods.send :include, Devise::Models
ActiveSupport.on_load(:mongoid) do
require 'orm_adapter/adapters/mongoid'
Mongoid::Document::ClassMethods.send :include, Devise::Models
end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Devise
class ParameterFilter
def initialize(case_insensitive_keys, strip_whitespace_keys)
@@ -16,6 +18,8 @@ module Devise
def filtered_hash_by_method_for_given_keys(conditions, method, condition_keys)
condition_keys.each do |k|
next unless conditions.key?(k)
value = conditions[k]
conditions[k] = value.send(method) if value.respond_to?(method)
end

View File

@@ -1,99 +1,173 @@
# frozen_string_literal: true
module Devise
class BaseSanitizer
attr_reader :params, :resource_name, :resource_class
# The +ParameterSanitizer+ deals with permitting specific parameters values
# for each +Devise+ scope in the application.
#
# The sanitizer knows about Devise default parameters (like +password+ and
# +password_confirmation+ for the `RegistrationsController`), and you can
# extend or change the permitted parameters list on your controllers.
#
# === Permitting new parameters
#
# You can add new parameters to the permitted list using the +permit+ method
# in a +before_action+ method, for instance.
#
# class ApplicationController < ActionController::Base
# before_action :configure_permitted_parameters, if: :devise_controller?
#
# protected
#
# def configure_permitted_parameters
# # Permit the `subscribe_newsletter` parameter along with the other
# # sign up parameters.
# devise_parameter_sanitizer.permit(:sign_up, keys: [:subscribe_newsletter])
# end
# end
#
# Using a block yields an +ActionController::Parameters+ object so you can
# permit nested parameters and have more control over how the parameters are
# permitted in your controller.
#
# def configure_permitted_parameters
# devise_parameter_sanitizer.permit(:sign_up) do |user|
# user.permit(newsletter_preferences: [])
# end
# end
class ParameterSanitizer
DEFAULT_PERMITTED_ATTRIBUTES = {
sign_in: [:password, :remember_me],
sign_up: [:password, :password_confirmation],
account_update: [:password, :password_confirmation, :current_password]
}
def initialize(resource_class, resource_name, params)
@resource_class = resource_class
@resource_name = resource_name
@auth_keys = extract_auth_keys(resource_class)
@params = params
@blocks = Hash.new
end
@resource_name = resource_name
@permitted = {}
def for(kind, &block)
if block_given?
@blocks[kind] = block
else
default_for(kind)
DEFAULT_PERMITTED_ATTRIBUTES.each_pair do |action, keys|
permit(action, keys: keys)
end
end
def sanitize(kind)
if block = @blocks[kind]
block.call(default_params)
# Sanitize the parameters for a specific +action+.
#
# === Arguments
#
# * +action+ - A +Symbol+ with the action that the controller is
# performing, like +sign_up+, +sign_in+, etc.
#
# === Examples
#
# # Inside the `RegistrationsController#create` action.
# resource = build_resource(devise_parameter_sanitizer.sanitize(:sign_up))
# resource.save
#
# Returns an +ActiveSupport::HashWithIndifferentAccess+ with the permitted
# attributes.
def sanitize(action)
permissions = @permitted[action]
if permissions.respond_to?(:call)
cast_to_hash permissions.call(default_params)
elsif permissions.present?
cast_to_hash permit_keys(default_params, permissions)
else
default_sanitize(kind)
unknown_action!(action)
end
end
# Add or remove new parameters to the permitted list of an +action+.
#
# === Arguments
#
# * +action+ - A +Symbol+ with the action that the controller is
# performing, like +sign_up+, +sign_in+, etc.
# * +keys:+ - An +Array+ of keys that also should be permitted.
# * +except:+ - An +Array+ of keys that shouldn't be permitted.
# * +block+ - A block that should be used to permit the action
# parameters instead of the +Array+ based approach. The block will be
# called with an +ActionController::Parameters+ instance.
#
# === Examples
#
# # Adding new parameters to be permitted in the `sign_up` action.
# devise_parameter_sanitizer.permit(:sign_up, keys: [:subscribe_newsletter])
#
# # Removing the `password` parameter from the `account_update` action.
# devise_parameter_sanitizer.permit(:account_update, except: [:password])
#
# # Using the block form to completely override how we permit the
# # parameters for the `sign_up` action.
# devise_parameter_sanitizer.permit(:sign_up) do |user|
# user.permit(:email, :password, :password_confirmation)
# end
#
#
# Returns nothing.
def permit(action, keys: nil, except: nil, &block)
if block_given?
@permitted[action] = block
end
if keys.present?
@permitted[action] ||= @auth_keys.dup
@permitted[action].concat(keys)
end
if except.present?
@permitted[action] ||= @auth_keys.dup
@permitted[action] = @permitted[action] - except
end
end
private
def default_for(kind)
raise ArgumentError, "a block is expected in Devise base sanitizer"
end
def default_sanitize(kind)
default_params
# Cast a sanitized +ActionController::Parameters+ to a +HashWithIndifferentAccess+
# that can be used elsewhere.
#
# 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
end
def default_params
params.fetch(resource_name, {})
end
end
class ParameterSanitizer < BaseSanitizer
def initialize(*)
super
@permitted = Hash.new { |h,k| h[k] = attributes_for(k) }
end
def sign_in
permit self.for(:sign_in)
end
def sign_up
permit self.for(:sign_up)
end
def account_update
permit self.for(:account_update)
end
private
# TODO: We do need to flatten so it works with strong_parameters
# gem. We should drop it once we move to Rails 4 only support.
def permit(keys)
default_params.permit(*Array(keys))
end
# Change for(kind) to return the values in the @permitted
# hash, allowing the developer to customize at runtime.
def default_for(kind)
@permitted[kind] || raise("No sanitizer provided for #{kind}")
end
def default_sanitize(kind)
if respond_to?(kind, true)
send(kind)
if hashable_resource_params?
@params.fetch(@resource_name)
else
raise NotImplementedError, "Devise doesn't know how to sanitize parameters for #{kind}"
empty_params
end
end
def attributes_for(kind)
case kind
when :sign_in
auth_keys + [:password, :remember_me]
when :sign_up
auth_keys + [:password, :password_confirmation]
when :account_update
auth_keys + [:password, :password_confirmation, :current_password]
end
def hashable_resource_params?
@params[@resource_name].respond_to?(:permit)
end
def auth_keys
@auth_keys ||= @resource_class.authentication_keys.respond_to?(:keys) ?
@resource_class.authentication_keys.keys : @resource_class.authentication_keys
def empty_params
ActionController::Parameters.new({})
end
def permit_keys(parameters, keys)
parameters.permit(*keys)
end
def extract_auth_keys(klass)
auth_keys = klass.authentication_keys
auth_keys.respond_to?(:keys) ? auth_keys.keys : auth_keys
end
def unknown_action!(action)
raise NotImplementedError, <<-MESSAGE.strip_heredoc
"Devise doesn't know how to sanitize parameters for '#{action}'".
If you want to define a new set of parameters to be sanitized use the
`permit` method first:
devise_parameter_sanitizer.permit(:#{action}, keys: [:param1, :param2, :param3])
MESSAGE
end
end
end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'devise/rails/routes'
require 'devise/rails/warden_compat'
@@ -11,7 +13,9 @@ module Devise
end
# Force routes to be loaded if we are doing any eager load.
config.before_eager_load { |app| app.reload_routes! }
config.before_eager_load do |app|
app.reload_routes! if Devise.reload_routes
end
initializer "devise.url_helpers" do
Devise.include_helpers(Devise::Controllers)
@@ -30,27 +34,14 @@ module Devise
end
initializer "devise.secret_key" do |app|
if app.respond_to?(:secrets)
Devise.secret_key ||= app.secrets.secret_key_base
elsif app.config.respond_to?(:secret_key_base)
Devise.secret_key ||= app.config.secret_key_base
end
Devise.secret_key ||= Devise::SecretKeyFinder.new(app).find
Devise.token_generator ||=
if secret_key = Devise.secret_key
Devise::TokenGenerator.new(
Devise::CachingKeyGenerator.new(Devise::KeyGenerator.new(secret_key))
ActiveSupport::CachingKeyGenerator.new(ActiveSupport::KeyGenerator.new(secret_key))
)
end
end
initializer "devise.fix_routes_proxy_missing_respond_to_bug" do
# Deprecate: Remove once we move to Rails 4 only.
ActionDispatch::Routing::RoutesProxy.class_eval do
def respond_to?(method, include_private = false)
super || routes.url_helpers.respond_to?(method)
end
end
end
end
end

View File

@@ -1,13 +1,12 @@
# frozen_string_literal: true
require "active_support/core_ext/object/try"
require "active_support/core_ext/hash/slice"
module ActionDispatch::Routing
class RouteSet #:nodoc:
# Ensure Devise modules are included only after loading routes, because we
# need devise_for mappings already declared to create filters and helpers.
def finalize_with_devise!
result = finalize_without_devise!
module Devise
module RouteSet
def finalize!
result = super
@devise_finalized ||= begin
if Devise.router_name.nil? && defined?(@devise_finalized) && self != Rails.application.try(:routes)
warn "[DEVISE] We have detected that you are using devise_for inside engine routes. " \
@@ -21,10 +20,16 @@ module ActionDispatch::Routing
Devise.regenerate_helpers!
true
end
result
end
alias_method_chain :finalize!, :devise
end
end
module ActionDispatch::Routing
class RouteSet #:nodoc:
# Ensure Devise modules are included only after loading routes, because we
# need devise_for mappings already declared to create filters and helpers.
prepend Devise::RouteSet
end
class Mapper
@@ -84,17 +89,17 @@ module ActionDispatch::Routing
#
# You can configure your routes with some options:
#
# * class_name: setup a different class to be looked up by devise, if it cannot be
# * class_name: set up a different class to be looked up by devise, if it cannot be
# properly found by the route name.
#
# devise_for :users, class_name: 'Account'
#
# * path: allows you to setup path name that will be used, as rails routes does.
# The following route configuration would setup your route as /accounts instead of /users:
# * path: allows you to set up path name that will be used, as rails routes does.
# The following route configuration would set up your route as /accounts instead of /users:
#
# devise_for :users, path: 'accounts'
#
# * singular: setup the singular name for the given resource. This is used as the helper methods
# * singular: set up the singular name for the given resource. This is used as the helper methods
# names in controller ("authenticate_#{singular}!", "#{singular}_signed_in?", "current_#{singular}"
# and "#{singular}_session"), as the scope name in routes and as the scope given to warden.
#
@@ -105,7 +110,7 @@ module ActionDispatch::Routing
# end
#
# class ManagerController < ApplicationController
# before_filter authenticate_manager!
# before_action authenticate_manager!
#
# def show
# @manager = current_manager
@@ -130,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.
#
@@ -335,7 +340,7 @@ module ActionDispatch::Routing
# Sets the devise scope to be used in the controller. If you have custom routes,
# you are required to call this method (also aliased as :as) in order to specify
# to which controller it is targetted.
# to which controller it is targeted.
#
# as :user do
# get "sign_in", to: "devise/sessions#new"
@@ -428,27 +433,29 @@ options to another `devise_for` call outside the scope. Here is an example:
end
ERROR
end
path, @scope[:path] = @scope[:path], nil
current_scope = @scope.dup
if @scope.respond_to? :new
@scope = @scope.new path: nil
else
@scope[:path] = nil
end
path_prefix = Devise.omniauth_path_prefix || "/#{mapping.fullpath}/auth".squeeze("/")
set_omniauth_path_prefix!(path_prefix)
providers = Regexp.union(mapping.to.omniauth_providers.map(&:to_s))
mapping.to.omniauth_providers.each do |provider|
match "#{path_prefix}/#{provider}",
to: "#{controllers[:omniauth_callbacks]}#passthru",
as: "#{provider}_omniauth_authorize",
via: [:get, :post]
match "#{path_prefix}/:provider",
constraints: { provider: providers },
to: "#{controllers[:omniauth_callbacks]}#passthru",
as: :omniauth_authorize,
via: [:get, :post]
match "#{path_prefix}/:action/callback",
constraints: { action: providers },
to: "#{controllers[:omniauth_callbacks]}#:action",
as: :omniauth_callback,
via: [:get, :post]
match "#{path_prefix}/#{provider}/callback",
to: "#{controllers[:omniauth_callbacks]}##{provider}",
as: "#{provider}_omniauth_callback",
via: [:get, :post]
end
ensure
@scope[:path] = path
@scope = current_scope
end
def with_devise_exclusive_scope(new_path, new_as, options) #:nodoc:
@@ -457,7 +464,11 @@ ERROR
exclusive = { as: new_as, path: new_path, module: nil }
exclusive.merge!(options.slice(:constraints, :defaults, :options))
exclusive.each_pair { |key, value| @scope[key] = value }
if @scope.respond_to? :new
@scope = @scope.new exclusive
else
exclusive.each_pair { |key, value| @scope[key] = value }
end
yield
ensure
@scope = current_scope

View File

@@ -1,19 +1,12 @@
# frozen_string_literal: true
module Warden::Mixins::Common
def request
@request ||= ActionDispatch::Request.new(env)
end
# Deprecate: Remove this check once we move to Rails 4 only.
NULL_STORE =
defined?(ActionController::RequestForgeryProtection::ProtectionMethods::NullSession::NullSessionHash) ?
ActionController::RequestForgeryProtection::ProtectionMethods::NullSession::NullSessionHash : nil
def reset_session!
# Calling reset_session on NULL_STORE causes it fail.
# This is a bug that needs to be fixed in Rails.
unless NULL_STORE && request.session.is_a?(NULL_STORE)
request.reset_session
end
request.reset_session
end
def cookies

View File

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

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'devise/strategies/base'
module Devise
@@ -26,7 +28,7 @@ module Devise
private
# Receives a resource and check if it is valid by calling valid_for_authentication?
# An optional block that will be triggered while validating can be optionally
# A block that will be triggered while validating can be optionally
# given as parameter. Check Devise::Models::Authenticatable.valid_for_authentication?
# for more information.
#

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Devise
module Strategies
# Base strategy for Devise. Responsible for verifying correct scope and mapping.

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'devise/strategies/authenticatable'
module Devise
@@ -6,16 +8,21 @@ module Devise
class DatabaseAuthenticatable < Authenticatable
def authenticate!
resource = password.present? && mapping.to.find_for_database_authentication(authentication_hash)
encrypted = false
hashed = false
if validate(resource){ encrypted = true; resource.valid_password?(password) }
if validate(resource){ hashed = true; resource.valid_password?(password) }
remember_me(resource)
resource.after_database_authentication
success!(resource)
end
mapping.to.new.password = password if !encrypted && Devise.paranoid
fail(:not_found_in_database) unless resource
# In paranoid mode, hash the password even when a resource doesn't exist for the given authentication key.
# This is necessary to prevent enumeration attacks - e.g. the request is faster when a resource doesn't
# exist in the database if the password hashing algorithm is not called.
mapping.to.new.password = password if !hashed && Devise.paranoid
unless resource
Devise.paranoid ? fail(:invalid) : fail(:not_found_in_database)
end
end
end
end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'devise/strategies/authenticatable'
module Devise
@@ -25,8 +27,7 @@ module Devise
end
if validate(resource)
remember_me(resource)
extend_remember_me_period(resource)
remember_me(resource) if extend_remember_me?(resource)
resource.after_remembered
success!(resource)
end
@@ -43,10 +44,8 @@ module Devise
private
def extend_remember_me_period(resource)
if resource.respond_to?(:extend_remember_period=)
resource.extend_remember_period = mapping.to.extend_remember_period
end
def extend_remember_me?(resource)
resource.respond_to?(:extend_remember_period) && resource.extend_remember_period
end
def remember_me?

View File

@@ -0,0 +1,165 @@
# frozen_string_literal: true
module Devise
module Test
# `Devise::Test::ControllerHelpers` provides a facility to test controllers
# in isolation when using `ActionController::TestCase` allowing you to
# quickly sign_in or sign_out a user. Do not use
# `Devise::Test::ControllerHelpers` in integration tests.
#
# Examples
#
# class PostsTest < ActionController::TestCase
# include Devise::Test::ControllerHelpers
#
# test 'authenticated users can GET index' do
# sign_in users(:bob)
#
# get :index
# assert_response :success
# end
# end
#
# Important: you should not test Warden specific behavior (like callbacks)
# using `Devise::Test::ControllerHelpers` since it is a stub of the actual
# behavior. Such callbacks should be tested in your integration suite instead.
module ControllerHelpers
extend ActiveSupport::Concern
included do
setup :setup_controller_for_warden, :warden
end
# Override process to consider warden.
def process(*)
_catch_warden { super }
@response
end
# 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
end
# Quick access to Warden::Proxy.
def warden #:nodoc:
@request.env['warden'] ||= begin
manager = Warden::Manager.new(nil) do |config|
config.merge! Devise.warden_config
end
Warden::Proxy.new(@request.env, manager)
end
end
# sign_in a given resource by storing its keys in the session.
# This method bypass any warden authentication callback.
#
# * +resource+ - The resource that should be authenticated
# * +scope+ - An optional +Symbol+ with the scope where the resource
# should be signed in with.
# Examples:
#
# 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
scope ||= Devise::Mapping.find_scope!(resource)
warden.instance_variable_get(:@users).delete(scope)
warden.session_serializer.store(resource, scope)
end
# Sign out a given resource or scope by calling logout on Warden.
# This method bypass any warden logout callback.
#
# Examples:
#
# sign_out :user # sign_out(scope)
# sign_out @user # sign_out(resource)
#
def sign_out(resource_or_scope)
scope = Devise::Mapping.find_scope!(resource_or_scope)
@controller.instance_variable_set(:"@current_#{scope}", nil)
user = warden.instance_variable_get(:@users).delete(scope)
warden.session_serializer.delete(scope, user)
end
protected
# Catch warden continuations and handle like the middleware would.
# Returns nil when interrupted, otherwise the normal result of the block.
def _catch_warden(&block)
result = catch(:warden, &block)
env = @controller.request.env
result ||= {}
# Set the response. In production, the rack result is returned
# from Warden::Manager#call, which the following is modelled on.
case result
when Array
if result.first == 401 && intercept_401?(env) # does this happen during testing?
_process_unauthenticated(env)
else
result
end
when Hash
_process_unauthenticated(env, result)
else
result
end
end
def _process_unauthenticated(env, options = {})
options[:action] ||= :unauthenticated
proxy = request.env['warden']
result = options[:result] || proxy.result
ret = case result
when :redirect
body = proxy.message || "You are being redirected to #{proxy.headers['Location']}"
[proxy.status, proxy.headers, [body]]
when :custom
proxy.custom_response
else
request.env["PATH_INFO"] = "/#{options[:action]}"
request.env["warden.options"] = options
Warden::Manager._run_callbacks(:before_failure, env, options)
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
nil # causes process return @response
end
# ensure that the controller response is set up. In production, this is
# not necessary since warden returns the results to rack. However, at
# testing time, we want the response to be available to the testing
# framework to verify what would be returned to rack.
if ret.is_a?(Array)
status, headers, body = *ret
# ensure the controller response is set to our response.
@controller.response ||= @response
@response.status = status
@response.headers.merge!(headers)
@response.body = body
end
ret
end
end
end
end

View File

@@ -0,0 +1,63 @@
# frozen_string_literal: true
module Devise
# Devise::Test::IntegrationHelpers is a helper module for facilitating
# authentication on Rails integration tests to bypass the required steps for
# signin in or signin out a record.
#
# Examples
#
# class PostsTest < ActionDispatch::IntegrationTest
# include Devise::Test::IntegrationHelpers
#
# test 'authenticated users can see posts' do
# sign_in users(:bob)
#
# get '/posts'
# assert_response :success
# end
# end
module Test
module IntegrationHelpers
def self.included(base)
base.class_eval do
include Warden::Test::Helpers
setup :setup_integration_for_devise
teardown :teardown_integration_for_devise
end
end
# Signs in a specific resource, mimicking a successfull sign in
# operation through +Devise::SessionsController#create+.
#
# * +resource+ - The resource that should be authenticated
# * +scope+ - An optional +Symbol+ with the scope where the resource
# should be signed in with.
def sign_in(resource, scope: nil)
scope ||= Devise::Mapping.find_scope!(resource)
login_as(resource, scope: scope)
end
# Signs out a specific scope from the session.
#
# * +resource_or_scope+ - The resource or scope that should be signed out.
def sign_out(resource_or_scope)
scope = Devise::Mapping.find_scope!(resource_or_scope)
logout scope
end
protected
def setup_integration_for_devise
Warden.test_mode!
end
def teardown_integration_for_devise
Warden.test_reset!
end
end
end
end

View File

@@ -1,132 +1,15 @@
# frozen_string_literal: true
module Devise
# Devise::TestHelpers provides a facility to test controllers in isolation
# when using ActionController::TestCase allowing you to quickly sign_in or
# sign_out a user. Do not use Devise::TestHelpers in integration tests.
#
# Notice you should not test Warden specific behavior (like Warden callbacks)
# using Devise::TestHelpers since it is a stub of the actual behavior. Such
# callbacks should be tested in your integration suite instead.
module TestHelpers
def self.included(base)
base.class_eval do
setup :setup_controller_for_warden, :warden if respond_to?(:setup)
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
# Override process to consider warden.
def process(*)
# Make sure we always return @response, a la ActionController::TestCase::Behaviour#process, even if warden interrupts
_catch_warden { super } || @response
end
# We need to setup the environment variables and the response in the controller.
def setup_controller_for_warden #:nodoc:
@request.env['action_controller.instance'] = @controller
end
# Quick access to Warden::Proxy.
def warden #:nodoc:
@request.env['warden'] ||= begin
manager = Warden::Manager.new(nil) do |config|
config.merge! Devise.warden_config
end
Warden::Proxy.new(@request.env, manager)
end
end
# sign_in a given resource by storing its keys in the session.
# This method bypass any warden authentication callback.
#
# Examples:
#
# sign_in :user, @user # sign_in(scope, resource)
# sign_in @user # sign_in(resource)
#
def sign_in(resource_or_scope, resource=nil)
scope ||= Devise::Mapping.find_scope!(resource_or_scope)
resource ||= resource_or_scope
warden.instance_variable_get(:@users).delete(scope)
warden.session_serializer.store(resource, scope)
end
# Sign out a given resource or scope by calling logout on Warden.
# This method bypass any warden logout callback.
#
# Examples:
#
# sign_out :user # sign_out(scope)
# sign_out @user # sign_out(resource)
#
def sign_out(resource_or_scope)
scope = Devise::Mapping.find_scope!(resource_or_scope)
@controller.instance_variable_set(:"@current_#{scope}", nil)
user = warden.instance_variable_get(:@users).delete(scope)
warden.session_serializer.delete(scope, user)
end
protected
# Catch warden continuations and handle like the middleware would.
# Returns nil when interrupted, otherwise the normal result of the block.
def _catch_warden(&block)
result = catch(:warden, &block)
env = @controller.request.env
result ||= {}
# Set the response. In production, the rack result is returned
# from Warden::Manager#call, which the following is modelled on.
case result
when Array
if result.first == 401 && intercept_401?(env) # does this happen during testing?
_process_unauthenticated(env)
else
result
end
when Hash
_process_unauthenticated(env, result)
else
result
end
end
def _process_unauthenticated(env, options = {})
options[:action] ||= :unauthenticated
proxy = env['warden']
result = options[:result] || proxy.result
ret = case result
when :redirect
body = proxy.message || "You are being redirected to #{proxy.headers['Location']}"
[proxy.status, proxy.headers, [body]]
when :custom
proxy.custom_response
else
env["PATH_INFO"] = "/#{options[:action]}"
env["warden.options"] = options
Warden::Manager._run_callbacks(:before_failure, env, options)
status, headers, response = Devise.warden_config[:failure_app].call(env).to_a
@controller.response.headers.merge!(headers)
@controller.send :render, status: status, text: response.body,
content_type: headers["Content-Type"], location: headers["Location"]
nil # causes process return @response
end
# ensure that the controller response is set up. In production, this is
# not necessary since warden returns the results to rack. However, at
# testing time, we want the response to be available to the testing
# framework to verify what would be returned to rack.
if ret.is_a?(Array)
# ensure the controller response is set to our response.
@controller.response ||= @response
@response.status = ret.first
@response.headers = ret.second
@response.body = ret.third
end
ret
end
end
end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
require "active_support/core_ext/module/delegation"
module Devise

View File

@@ -1,11 +1,10 @@
# Deprecate: Copied verbatim from Rails source, remove once we move to Rails 4 only.
require 'thread_safe'
# frozen_string_literal: true
require 'openssl'
require 'securerandom'
module Devise
class TokenGenerator
def initialize(key_generator, digest="SHA256")
def initialize(key_generator, digest = "SHA256")
@key_generator = key_generator
@digest = digest
end
@@ -30,41 +29,4 @@ module Devise
@key_generator.generate_key("Devise #{column}")
end
end
# KeyGenerator is a simple wrapper around OpenSSL's implementation of PBKDF2
# It can be used to derive a number of keys for various purposes from a given secret.
# This lets Rails applications have a single secure secret, but avoid reusing that
# key in multiple incompatible contexts.
class KeyGenerator
def initialize(secret, options = {})
@secret = secret
# The default iterations are higher than required for our key derivation uses
# on the off chance someone uses this for password storage
@iterations = options[:iterations] || 2**16
end
# Returns a derived key suitable for use. The default key_size is chosen
# to be compatible with the default settings of ActiveSupport::MessageVerifier.
# i.e. OpenSSL::Digest::SHA1#block_length
def generate_key(salt, key_size=64)
OpenSSL::PKCS5.pbkdf2_hmac_sha1(@secret, salt, @iterations, key_size)
end
end
# CachingKeyGenerator is a wrapper around KeyGenerator which allows users to avoid
# re-executing the key generation process when it's called using the same salt and
# key_size
class CachingKeyGenerator
def initialize(key_generator)
@key_generator = key_generator
@cache_keys = ThreadSafe::Cache.new
end
# Returns a derived key suitable for use. The default key_size is chosen
# to be compatible with the default settings of ActiveSupport::MessageVerifier.
# i.e. OpenSSL::Digest::SHA1#block_length
def generate_key(salt, key_size=64)
@cache_keys["#{salt}#{key_size}"] ||= @key_generator.generate_key(salt, key_size)
end
end
end

View File

@@ -1,3 +1,5 @@
# frozen_string_literal: true
module Devise
VERSION = "3.5.3".freeze
VERSION = "4.7.1".freeze
end

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