Compare commits

...

461 Commits

Author SHA1 Message Date
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
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
Lucas Mazza
032eb145df Release 3.5.3. 2015-12-10 14:36:34 -02:00
José Valim
0d941b7ba5 Merge pull request #3847 from stanhu/reset-token-only-on-update
Only clear the reset token on an update
2015-12-09 20:28:06 +01:00
Stan Hu
f71d843f93 Only clear the reset token on an update
This solves the issue where a package might do:

```
user = User.new
user.email = 'test@test.com'
token = user.generate_reset_token
user.save

send_reset_email(token)
```

Since the save clears the reset token, the user will receive a stale token that no longer works.

Closes #3774
2015-12-09 11:14:50 -08:00
Lucas Mazza
7d825c93b6 Update CHANGELOG [ci skip]. 2015-12-09 13:53:29 -02:00
José Valim
19b1e2a6bc Merge pull request #3846 from seddy/make_email_optional_on_recoverable
Allow resources with no email field to be recoverable
2015-12-09 14:39:32 +01:00
José Valim
901919f25f Revert "Merge pull request #3774 from stanhu/reset-token-only-if-not-persisted"
This reverts commit 15c38d918f, reversing
changes made to 508c3418f9.
2015-12-09 14:21:09 +01:00
Lucas Mazza
15c38d918f Merge pull request #3774 from stanhu/reset-token-only-if-not-persisted
Only clear the reset password token if the model has already been persisted
2015-12-09 10:54:36 -02:00
Lucas Mazza
508c3418f9 Merge pull request #3826 from andygeers/master
Don't error if resource doesn't need confirming
2015-12-09 10:52:35 -02:00
Ed Saunders
d98e98fe77 Add a test for when a recoverable resource has a non-AR email field 2015-12-08 16:01:39 +00:00
Ed Saunders
4a45eb9899 Allow resources with no email field to be recoverable
The current implementation is opinionated about the resource should have
an "email" column on it if it is to be recoverable, which isn't
necessarily the case.  For example, developers may decide to pull emails
out into their own model or have some other way of communicating
password resets to their users (e.g. text message)

I'm not sure there's an easy test to put together for this case, as
minitest doesn't make it very easy to stub the "email_changed?" to raise
an error. Happy to look into building another model in the
"test/rails_app" if you want to have this properly tested though? Or for
a nice way to get calls to "email_changed?" to raise; minitest isn't
a test framework I'm overly familiar with :).

As a side note, it would be nice if the Validatable module also took
this into account, I may raise another PR for that.

This comes off the back of comments on this commit:
e641b4b7b9
2015-12-07 17:01:31 +00:00
José Valim
45fc964470 Merge pull request #3739 from stanhu/support-relative-urls-in-failure-app
Account for relative_url_root in FailureApp's recall method
2015-11-25 20:03:28 +01:00
Stan Hu
56fed052f8 Wrap logic for resetting token into instance method and add comments 2015-11-24 23:23:34 -08:00
Kacper Walanus
a0cd4655ba test for save in after_create hook breaks devise confirmation [3787] 2015-11-24 01:54:03 +01:00
Andy Geers
d3f521925e Write unit test for bug fix 2015-11-18 22:21:03 +00:00
Andy Geers
8a8887ea82 Don't error if resource doesn't need confirming 2015-11-18 22:21:03 +00:00
José Valim
d22ac4a4fb Merge pull request #3813 from jlerpscher/set-minimum-password-length-on-failure
set minimum password length on reset failure
2015-11-10 09:37:59 -02:00
Julien Lerpscher
8426b12550 set minimum password length on reset failure 2015-11-10 12:17:29 +01:00
José Valim
57bf362b55 Merge pull request #3808 from blase/skip-timeoutable
Allow skipping the timeoutable hook
2015-11-04 18:15:03 -02:00
José Valim
18a8260535 Merge pull request #3805 from robuye/master
Remove outdated example from documentation
2015-11-04 00:48:35 -02:00
Błażej Pankowiak
9f32f421a5 Allow skipping the timeoutable hook 2015-11-02 23:53:09 +01:00
robuye
df6a83b27b Remove outdated example from documentation
`#reset_password` always saves the record if validation passes.
2015-11-02 23:06:38 +01:00
Lucas Mazza
4477bab1aa Update Travis CI notification settings. 2015-11-01 19:54:58 -02: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
José Valim
d6dc93ca3d Merge pull request #3792 from excid3/master
Automatically underscore and pluralize scoped views generator
2015-10-22 00:42:40 +02:00
Chris Oliver
005d514adf Automatically underscore and pluralize scoped views generator. Fixes #3790 2015-10-21 14:53:03 -04:00
Lucas Mazza
9568e28d66 Merge pull request #3783 from yui-knk/doc_singular_option
[ci skip] Write how to use `singular` option of `ActionDispatch::Rout…
2015-10-19 09:15:34 -04:00
yui-knk
4f2571a408 [ci skip] Write how to use singular option of ActionDispatch::Routing::Mapper#devise_for
* Replace "the instance variable name in controller" with "the helper methods
  names in controller".
  Devise dose not define instance variable for controllers but define helper
  methods for controllers.
* Replace "the name in routes" with "the scope name in routes".
  `singular` is used as an argument of `devise_scope`.
* Add sample codes of routing and controller.
2015-10-16 11:57:42 +09:00
Rafael Mendonça França
e33d285e4a Update the documentation to use current Rails code [ci skip] 2015-10-15 16:13:06 -03:00
Stan Hu
619128cb9b Only clear the reset password token if the model has already been persisted
If a new user is created with a reset password token, the previous behavior
would automatically clear the token even when it was desired for setting
the password for the first time.
2015-10-02 12:30:57 -07:00
George Guimarães
9f37b6eff7 Merge pull request #3769 from xymbol/fix_typos
Fix typos
2015-09-30 19:39:49 -03:00
Adrian Mugnolo
2380612b6e Fix typo: authenticatable 2015-09-30 19:32:44 -03:00
Adrian Mugnolo
c334179c95 Fix typo: successful 2015-09-30 19:31:49 -03:00
José Valim
827d009b3c Merge pull request #3766 from nambrot/patch-1
Add missing comma
2015-09-28 17:28:41 +02:00
Nam Chu Hoai
56edeec958 Add missing comma 2015-09-28 11:25:03 -04:00
Lucas Mazza
7df57d5081 Merge pull request #3732 from posgarou/refactor/respond_to_helper_method
Wrap helper_method calls in respond_to?(:helper_method)
2015-09-26 11:05:30 -03:00
George Guimarães
2ccffc80b0 Merge pull request #3743 from plataformatec/fdf-add-code-of-conduct
Add a Code of Conduct
2015-09-08 00:02:47 -03:00
Flavia Fortes
797a19352c Add a Code of Conduct 2015-09-07 23:59:51 -03:00
Stan Hu
7025f968c6 Account for relative_url_root in FailureApp's recall method
Closes #3738
2015-09-06 00:05:19 -07:00
Ryan Mitchell
04e01f49a9 Use builtin matchers in helper tests 2015-08-31 09:58:25 -04:00
Ryan Mitchell
a3da40a701 Wrap helper_method calls in respond_to?(:helper_method) 2015-08-29 05:29:05 -04:00
Lucas Mazza
40258bf100 Remove the custom OmniAuth camelization on teardown. 2015-08-28 11:26:41 -03:00
Lucas Mazza
d3baff221d Merge pull request #3730 from timoschilling/omin-auth-camelization
use OmniAuth::Utils.camelize
2015-08-28 10:57:20 -03:00
Timo Schilling
f5e984c151 use OmniAuth::Utils.camelize
This will display the provider name with the original camelization:
facebook => Facebook
github => GitHub
linkedin => LinkedIn
2015-08-28 07:51:37 +02:00
Lucas Mazza
6ed6e09bf3 Merge pull request #3642 from jphenow/add-password-change-notification
Add password change notification
2015-08-27 12:48:14 -03:00
Jon Phenow
05ccdfbacd Merge branch 'add-password-change-notification' of github.com:jphenow/devise into add-password-change-notification 2015-08-27 10:43:51 -05:00
Jon Phenow
9bcc2d1c5f CHANGELOG 2015-08-27 10:26:42 -05:00
Jon Phenow
211159f2eb translation for mailer subject 2015-08-27 10:26:12 -05:00
Jon Phenow
ab141a8779 move model stubs 2015-08-27 10:26:12 -05:00
Jon Phenow
e9c82472ff quick comment touch-ups 2015-08-27 10:26:12 -05:00
Jon Phenow
48ed2fd1aa templates, config documentation 2015-08-27 10:26:12 -05:00
Jon Phenow
0fa74d863d functionality 2015-08-27 10:26:12 -05:00
Jon Phenow
c744dcf07a tests 2015-08-27 10:26:12 -05:00
Lucas Mazza
eb091b867f Fix rails g devise:views -v mailer with the Simple Form generator.
Our Simple Form generator shouldn't be responsible for generating the `mailer`
view directory, so we should skip it and let the Erb generator do the job.

Closes #3254.
2015-08-27 12:12:13 -03:00
Lucas Mazza
fb3568308e Merge pull request #3707 from LimeBlast/master
modifys markerb templates to use markdown links, not html ones.
2015-08-27 10:28:02 -03:00
Lucas Mazza
93b8f01583 Merge pull request #3719 from dgynn/doc_api_change
Update docs for Devise::Models.config
2015-08-26 14:56:22 -03:00
Dave Gynn
068da8045b update api docs for Models.config
config no longer takes a default value since 80699c58b4.
also, :streches was moved to DatabaseAuthenticatable.
2015-08-21 00:50:31 -07:00
José Valim
b12658782f Merge pull request #3717 from MarkMT/patch-2
Update comment on Devise.add_module
2015-08-21 09:18:19 +02:00
José Valim
3e87489c5b Merge pull request #3715 from evopark/feature/enhance_failure_app_url_options
Use default_url_options from parent_controller
2015-08-21 09:15:56 +02:00
Marcus Ilgner
8aa0e2655e Use default_url_options from parent_controller
Use a configured Devise.parent_controller, not ApplicationController
Also remove passing `*args` since it's a class-level attribute, not
a method.
2015-08-21 08:32:43 +02:00
MarkMT
155e23a73e Update comment on Devise.add_module
The existing comment suggests that add_module is used only for modules that are not provided by Devise itself.
2015-08-20 19:17:52 -05:00
José Valim
359fba970e Merge pull request #3713 from MarkMT/patch-1
Update comment on Devise.configure_warden
2015-08-19 10:04:31 +02:00
MarkMT
3a056f6d10 Update comment on Devise.configure_warden
The existing comment seems to be either outdated or obscure. I interpret it as meaning that configure_warden! is invoked by an 'initializer' block in class Devise::Engine, i.e. in lib/devise/rails.rb. However, as far as I can tell the only time the method is invoked is when ActionDispatch::Routing::RouteSet#finalize! is called, and this is aliased by devise to finalize_with_devise!.
2015-08-18 22:41:58 -05:00
José Valim
213aa51126 Merge pull request #3708 from dayweek/patch-1
Add removed method to CHANGELOG
2015-08-14 14:12:01 +02:00
David Hrachovy
8588387fad Add removed method to CHANGELOG
my app failed to start because the method was removed. I think it makes sense to mention it here.
2015-08-14 14:02:57 +02:00
Daniel Hollands
8c6de852c6 modifys markerb templates to use markdown links, not html ones. 2015-08-13 13:57:01 +01:00
Carlos Antonio da Silva
52e35f69c5 Fix typo in changelo [ci skip]
Thanks @reedloden.
2015-08-10 20:39:22 -03:00
José Valim
d9939d1ea0 Release v3.5.2 2015-08-10 14:46:36 +02:00
José Valim
703a0e0240 Merge pull request #3678 from OliveTreeBible/dctrotz-basic-auth-patch
Basic auth case insensitive pattern match
2015-08-10 14:14:06 +02:00
José Valim
48d8285344 Merge pull request #3699 from NeilvB/fix-line-break-edit-password
Remove unnecessary line break on edit password page.
2015-08-06 19:53:52 +02:00
Neil van Beinum
710496b6a8 Remove unnecessary line break on edit password page. 2015-08-06 18:21:34 +01:00
José Valim
2f45755e6c Merge pull request #3695 from yakovenkodenis/minor_grammar_improvements_at_readme
Improve grammar on lines 189 and 352 in readme
2015-08-02 13:53:24 +02:00
Denis Yakovenko
021f2da1e4 Improve grammar on lines 189 and 352 in readme 2015-08-02 13:48:31 +03:00
José Valim
bc6361ab9b Merge pull request #3661 from vincentwoo/plain_confirmation
Do not use digests for confirmation tokens
2015-07-30 11:43:10 +02:00
Vincent Woo
eb640ed344 Do not use digests for confirmation tokens 2015-07-30 01:55:50 -07:00
David Trotz
5c244d9e2b Basic auth case insensitive pattern match
Allow basic authentication to be case insensitive as per the HTTP 1.1 spec RFC 2068 Section 11
> It uses an extensible, case-insensitive token to identify the authentication scheme, followed by a comma-separated list of attribute-value pairs which carry the parameters necessary for achieving authentication via that scheme.

We have a particular client in production that has basic auth hard-coded as `basic` rather than `Basic` and devise is rejecting perfectly fine credentials. Making this small change has allowed us to authenticate this client with no issues.
2015-07-16 10:58:59 -07:00
José Valim
e538f02f30 Merge pull request #3672 from deivid-rodriguez/remove_obsolete_unused_config
Remove obsolete unused `expire_auth_token_on_timeout` config
2015-07-11 19:35:29 +02:00
David Rodríguez
4064641967 Remove obsolete expire_auth_token_on_timeout
This should have been removed in dff7891b97
when token authentication (and the reset_authentication_token! method)
were removed.
2015-07-11 09:01:22 -03:00
David Rodríguez
c72be1531c Keep Gemfile.lock in sync
Forgotten in b23f5223dd
2015-07-11 08:57:40 -03:00
José Valim
f0a168da5a Merge pull request #3670 from fengye87/master
redirect to after_resetting_password_path always
2015-07-10 17:32:37 +02:00
Feng Ye
4d89c709a5 redirect to after_resetting_password_path always 2015-07-10 20:01:42 +08:00
José Valim
737a55f9e1 Merge pull request #3659 from abevoelker/fix-auth-route-redirect
Fix infinite redirect in Rails 4.2 authenticated routes. Closes #3643
2015-07-04 11:38:21 +02:00
Carlos Antonio da Silva
fe5b7db6ab Merge pull request #3662 from vincentwoo/fix_mongo_dep
Just use regular 4.x mongoid gem
2015-06-30 22:33:45 -03:00
Vincent Woo
b23f5223dd just use regular 4.x mongoid gem 2015-06-30 16:02:06 -07:00
Abe Voelker
aa675f7f66 Fix infinite redirect in Rails 4.2 authenticated routes. Closes #3643 2015-06-27 14:25:09 -05:00
José Valim
181920886e Merge pull request #3653 from Envek/fix_routes_dynamic_segment_message
Provided another solution in error message when using omniauth callbacks under a dynamic segment
2015-06-24 19:41:28 +02:00
Andrey Novikov
4d8bec435d Provided another solution in error message when using omniauth callbacks under a dynamic segment
Previous solution was too complex and wasn't worked for everyone. See discussion at https://github.com/plataformatec/devise/pull/2227

Fixes #3651 [ci skip]
2015-06-24 20:39:25 +03:00
Jon Phenow
89dbbfd0fd CHANGELOG 2015-06-24 11:13:06 -05:00
Jon Phenow
0164f5862c translation for mailer subject 2015-06-24 11:01:46 -05:00
Jon Phenow
e966ba72b1 move model stubs 2015-06-24 10:50:54 -05:00
Jon Phenow
464edd5e5f quick comment touch-ups 2015-06-24 10:50:43 -05:00
Lucas Mazza
5ba8f36958 Merge pull request #3641 from camelmasa/fix-cve
Update rails gem for security
2015-06-23 11:21:48 -03:00
José Valim
e2041d02e8 Merge pull request #3648 from samdec11/master
Fix default email_regexp config to disallow trailing non-word characters
2015-06-22 16:05:34 +02:00
Sean Marzug-McCarthy
d49533bedc Fix default email_regexp config to disallow trailing non-word characters 2015-06-22 15:41:49 +02:00
José Valim
3dc15c03a7 Merge pull request #3644 from takiy33/patch-1
Remove rubyforge_project option
2015-06-21 11:19:59 +02:00
takiy33
954767d456 Remove rubyforge_project option
rubyforge_project option is deprecated.
2015-06-21 18:12:28 +09:00
Jon Phenow
6c993beb22 templates, config documentation 2015-06-19 14:22:54 -05:00
Jon Phenow
cc9a4e3edc functionality 2015-06-19 14:22:37 -05:00
Jon Phenow
0d59781ea8 tests 2015-06-19 14:21:10 -05:00
camelmasa
1aaf6345a4 Update rails gem for security
See. http://weblog.rubyonrails.org/2015/6/16/Rails-3-2-22-4-1-11-and-4-2-2-have-been-released-and-more/
2015-06-17 15:42:42 +09:00
Carlos Antonio da Silva
15b99977a2 Fix count of starting with rails resources
After 055f67e414. [ci skip]
2015-06-16 07:22:55 -03:00
José Valim
055f67e414 Update README.md
See discussion in #3607
2015-06-15 22:58:25 +02:00
Carlos Antonio da Silva
099aee5c5b Merge pull request #3630 from NAndreasson/fix/autoload-encryptor
Autoload Encryptor
2015-06-12 08:38:24 -03:00
Niklas Andréasson
65dc208ad7 Rm require 'devise/encryptor' in database_authenticable.rb 2015-06-12 13:18:34 +02:00
Niklas Andréasson
e3244b2c31 Autoload Encryptor 2015-06-12 10:36:45 +02:00
Carlos Antonio da Silva
aa49dd53b5 Merge pull request #3627 from vishaldeepak/master
Add codecademy authorization tutorial
2015-06-09 07:32:02 -03:00
VISHAL DEEPAK
916c0fc60b Add codecademy authorization tutorial
A really good , learn by doing, tutorial at codecademy
2015-06-09 15:51:45 +05:30
José Valim
4acb504324 Merge pull request #3616 from yui-knk/refactor/alias
Refactoring `expire_data_after_sign_out!`
2015-06-03 09:01:43 +02:00
yui-knk
3207c73d4b Refactoring expire_data_after_sign_out!
This method is same to `expire_data_after_sign_in!`,
so alias it
2015-06-03 13:14:18 +09:00
Carlos Antonio da Silva
2510c949e5 Merge pull request #3615 from Dbz/fixed_typo
fixed typo referring to routes.rb file
2015-06-02 23:03:51 -03:00
Danny Burt
29e257e8ba fixed typo referring to routes.rb file 2015-06-02 18:10:22 -07:00
José Valim
1a0192201b Merge pull request #3607 from rodrigoargumedo/patch-1
Add GoRails resource into README.md
2015-05-27 09:43:57 +02:00
Rodrigo Argumedo
8db50f4377 Add GoRails resource into README.md 2015-05-26 17:53:10 -06:00
José Valim
42c1ad3c78 Release v3.5.1 2015-05-26 15:10:29 +02:00
José Valim
e641b4b7b9 Also reset password token on email change 2015-05-26 15:09:07 +02:00
José Valim
fe49e625e8 Do not accept empty authentication_salt too 2015-05-26 15:04:27 +02:00
José Valim
31901bc862 Clear up reset password token whenever encrypted password changes 2015-05-26 15:00:12 +02:00
José Valim
b14995167b Do not mark _prefixes as protected 2015-05-26 09:53:38 +02:00
José Valim
4c137c4806 Release v3.5.0 2015-05-23 22:44:49 +02:00
José Valim
e5c3462a62 Merge pull request #3539 from rubyengineer/formatting
Formatting
2015-05-23 22:23:52 +02:00
José Valim
7952f1336d Merge pull request #3541 from cipater/fix-failureapp
Use router_name from scope if available
2015-05-23 22:23:40 +02:00
José Valim
55ef8004e6 Merge pull request #3542 from lboix/patch-1
Adding link to wiki + include clarification
2015-05-23 22:23:09 +02:00
José Valim
4b41dab11b Merge pull request #3601 from Angelmmiguel/master
Allow the user to set the length of friendly token
2015-05-23 22:15:48 +02:00
José Valim
1f3638aaa5 Do not clean up CSRF on rememberable 2015-05-23 22:13:59 +02:00
Angel M de Miguel
db63df7a8f Calculate real characters based on SecureRandom.urlsafe_base64 method 2015-05-21 14:41:34 +02:00
Angel M de Miguel
b89537936b Allow the user to set the length of friendly token 2015-05-21 13:46:31 +02:00
José Valim
ac4a89a511 Merge pull request #3597 from glittershark/define-method-not-class-eval
Use `define_method`, not `class_eval`, for url_helpers
2015-05-12 22:06:59 +02:00
Griffin Smith
741df732dc Use define_method, not class_eval, for url_helpers
I'm not hugely familiar with ruby internals vis a vis sclass semantics,
but this *probably* serves as a workaround for the MRI thread-safety
bug mentioned in #3505.
Beyond that, and even if this doesn't fix the thread-safety issue, per
[this blog post][1], `define_method` is recommended over `class_eval`
for performance (and, fwiw, readability) reasons anyway.

[1]: http://tenderlovemaking.com/2013/03/03/dynamic_method_definitions.html
2015-05-12 15:05:31 -04:00
Carlos Antonio da Silva
d701ed764f Fix wrong comment about http validation method [ci skip] 2015-05-12 14:34:56 -03:00
José Valim
369a5011f8 Merge pull request #3596 from jsanders/confusing-comments-in-generated-controllers
Change comments on registration and session controller configure methods
2015-05-11 20:57:22 +02:00
James Sanders
35de859e28 Change comments on registration and session controller configure methods 2015-05-11 12:12:10 -06:00
José Valim
280c247b2f Merge pull request #3594 from bonobos/feature/split-out-encryptor
Split out BCrypt hashing to make it reusable
2015-05-07 12:26:04 +02:00
Magnus von Koeller
a8769933d1 Split out BCrypt hashing to make it reusable
This logic is generic and reusable -- hash a secret; and take an
unhashed secret and compare it to a hashed secret. This breaks this out
to make it reusable in other places. Specifically, we use this in our
own token auth at Bonobos that we plan to split out as a Devise
extension. This will make that possible without copy & pasting this
code.
2015-05-06 12:11:09 -07:00
José Valim
74679bf3bc Merge pull request #3592 from adacosta/document/confirmable-columns
Add confirmable column documentation
2015-05-06 09:42:59 +02:00
Alan Da Costa
26492b3c50 Add confirmable column documentation 2015-05-05 16:04:15 -07:00
José Valim
a29fee1644 Merge pull request #3575 from alex88/failure_flashes
Conditionally use flashes in failure_app
2015-04-21 19:50:43 +02:00
Alessandro Tagliapietra
eac6c743fd Conditionally use flashes in failure_app
Fixes #3574
2015-04-21 16:27:44 +02:00
José Valim
bc38b044a4 Merge pull request #3573 from kroky/master
improve error message when using omniauth callbacks under a dynamic segment
2015-04-21 12:46:31 +02:00
Victor Emanouilov
85d75702ed improve error message when using omniauth callbacks under a dynamic segment 2015-04-21 13:02:28 +03:00
José Valim
7ca70a47ce Merge pull request #3570 from nviennot/no_more_bang
Removes the bang in confirm! and reset_password!
2015-04-21 10:30:44 +02:00
Nicolas Viennot
c22e7133b6 Removes the bang in confirm! and reset_password!
Closes #3412 and #3570.
2015-04-19 11:47:44 -04:00
Carlos Antonio da Silva
2f0002a449 Simplify serializable_hash implementation
Now that Rails 3.1 is not supported anymore, we don't need to implement
to_xml, since it does the right thing by calling serializable_hash.

This removes the class_eval need that existed to simplify the
implementation of both to_xml and serializable_hash.
2015-03-31 14:11:13 -03:00
cipater
15d3fc497c Use router_name from scope if available
Devise.available_router_name currently returns either
Devise.router_name or :main_app. As such, any redirecting is done
within either of those contexts. Which leads to undesirable redirects
for scopes that reside in an isolate_namespace mounted engine.

This commit makes it possible for FailureApp’s redirect behavior to be
performed in the context of the router_name given to devise_for.

Test case added to cover undesirable behavior. Without change to
lib/devise/failure_app.rb, test case throws exception.
2015-03-30 16:18:05 -07:00
Lucien Boix
e5400bc709 Adding link to wiki + include clarification
Like discussed at the bottom of this ticket : https://github.com/plataformatec/devise/issues/1029
2015-03-29 19:05:24 -04:00
pythogorian
7c309f9b91 Formatting 2015-03-26 23:47:20 +01:00
Carlos Antonio da Silva
79c6f47ad3 Bundle update 2015-03-24 09:00:38 -03:00
José Valim
885597025a Merge pull request #3520 from ianks/valid_password
Valid password
2015-03-17 22:54:40 +01:00
Ian Ker-Seymer
8743ce6cf8 Clearly comment on the functionality of valid_password? 2015-03-17 15:21:59 -06:00
Ian Ker-Seymer
70ab38839f Use password.present? in DatabaseAuthenticatable strategy
In order to be more clear about the expectations of for authenticating, we use
`password.present?` so there is no confusion about the role of the `valid_password?`
method.

More info: https://github.com/plataformatec/devise/issues/3519
2015-03-17 15:19:23 -06:00
Vasiliy Ermolovich
9aa72db365 Remove extra space.
[ci skip]
2015-03-15 02:09:46 +03:00
Carlos Antonio da Silva
18b6064d74 Merge branch 'ca-rm-spaces'
Closes #3480.
2015-03-13 14:00:07 -03:00
Carlos Antonio da Silva
868d3d82a0 Do a final pass removing spaces around square brackets
Keep plataformatec guidelines and review tools happy.
Related to #3480.
2015-03-13 13:59:19 -03:00
Kosmas Chatzimichalis
1ab2d51308 removed spaces inside square brackets 2015-03-13 13:59:19 -03:00
Carlos Antonio da Silva
d1d5996b6b Remove deprecated methods related to token authentication
These methods have no effect since Devise 3.2.0, released in Nov 2013.
2015-03-13 13:54:32 -03:00
José Valim
ef28bf2814 Merge pull request #3504 from scottjacobsen/devise_scope_override
Allow objects to specify their devise scope
2015-03-04 09:27:07 +01:00
Scott Jacobsen
4837bb0a4e Allow objects to specify their devise scope.
Introspecting the scope of an object can make it difficult to use
wrapper patterns. See issue plataformatec/devise#3307 for an example.

Allow objects to specify their scope explicitly by implementing
`devise_scope`.
2015-03-03 22:37:25 -07:00
Carlos Antonio da Silva
b02cd547e2 Merge pull request #3503 from arnvald/remove-redundant-condition
Remove redundant `remember_created_at.nil?`
2015-03-03 13:42:31 -03:00
Grzegorz Witek
8d5c2c4fd9 Remove redundant remember_created_at.nil?
`remember_expired?` already calls this method
2015-03-03 23:51:10 +08:00
José Valim
0a0b4e00ea Merge pull request #3502 from davetron5000/remove-hide-action
remove use of hide_action in favor of protected
2015-03-01 21:48:57 +01:00
Dave Copeland
e1b9dc860f remove use of hide_action in favor of protected
Rails 5 will [not have `hide_action` any longer](https://github.com/rails/rails/pull/18371/files), as the Rails convention is to not expose private or protected methods as actions, thus obviating the need for `hide_action`.

Presumably, there is code inheriting from `DeviseController` that is
calling these helpers, so they cannot be private, so protected seems to
be the only way to get Devise working with Rails 5.
2015-03-01 15:05:20 -05:00
Lauro Caetano
5802a57c76 Merge pull request #3478 from killthekitten/patch-1
Update message after rails g devise:controllers
2015-03-01 16:03:14 -03:00
Lucas Mazza
f038c36161 Use SVG badges in the README. 2015-02-27 14:16:54 -03:00
Rafael Mendonça França
4bb457ff6d Merge pull request #3493 from betesh/master
allow Devise::Models::Authenticatable to be loaded before Rails
2015-02-25 11:46:37 -03:00
Isaac Betesh
ac79f1e114 allow Devise::Models::Authenticatable to be loaded before Rails 2015-02-24 16:29:06 -05:00
José Valim
61ec44b76e Rollback mongoid fix as 4.0.2 will be out soon 2015-02-19 12:13:57 +01:00
Nikolay Shebanov
5e12508b96 Update message after rails g devise:controllers 2015-02-16 19:46:01 +03:00
José Valim
737ae3632a Merge pull request #3473 from georgemillo/test-yield
adding test for RegistrationsController#new yielding the resource
2015-02-14 18:49:59 +01:00
George Millo
a6a1524146 adding test for RegistrationsController#new yielding the resource 2015-02-14 15:37:21 +01:00
José Valim
2992b411a2 Update authenticatable.rb 2015-02-14 11:02:13 +01:00
José Valim
d2658c6e35 Merge pull request #2882 from hauleth/fix-mongoid-10068
Devise + Mongoid store wrong data in session
2015-02-14 11:00:48 +01:00
José Valim
893a0222ef Update new.html.erb 2015-02-14 10:59:01 +01:00
José Valim
fbb7a21abc Merge pull request #3468 from redbar0n/patch-2
Fix potential security leak in email reconfirmation flow
2015-02-14 10:58:25 +01:00
redbar0n
ee8c13435f Fix potential security leak in email reconfirmation flow
Ref. bug/issue: https://github.com/plataformatec/devise/issues/3457
2015-02-13 21:43:06 +01:00
José Valim
c19f1f27ce Merge pull request #3467 from borski/feature/recoverable_autologin_option
Added an option to not automatically sign in a user after a password res...
2015-02-13 13:32:35 +01:00
Michael Borohovski
f0992e4a96 Added an option to not automatically sign in a user after a password reset. This is useful for cases where additional strategies might be needed (such as two-factor authentication, e.g.), or generally if it is considered a security risk to automatically log in a user after a password is reset. 2015-02-13 02:29:11 -08:00
José Valim
baef67cee7 Merge pull request #3452 from jaume-prat/master
workaround for mountable Engines with Rails 4.2
2015-02-13 09:50:30 +01:00
José Valim
00dc3932c6 Merge pull request #3465 from mattbrictson/logging-leaks-readme
Add warning about logged tokens to the README
2015-02-13 09:20:59 +01:00
Matt Brictson
7acc7a6659 Add warning about logged tokens to the README 2015-02-12 16:05:58 -08:00
José Valim
fea2b95c5f Merge pull request #3463 from LunarLogic/master
Extracted route to separate method to be able to override in child class
2015-02-12 13:13:26 +01:00
Ania Slimak
8461234483 Extracted route to separate method to be able to override in child class 2015-02-12 13:07:57 +01:00
Jaume Prat
af8d38e45b do not set :script_name option with nil 2015-02-05 14:33:09 +01:00
Lucas Mazza
a2e0e9c187 Merge pull request #3449 from gaganawhad/patch-1
Add comments re: secret_key on Rails 4+ apps
2015-02-04 19:39:48 -02:00
Gagan Awhad
90f1d4d37a Add helpful comments re: 'secret_key' in devise initializer template
Adding a couple comments that explain that Devise will use
'secret_key_base' on Rails 4+ applications as its 'secret_key' by default.
2015-02-04 14:48:25 -06:00
Lucas Mazza
51c621ef51 Merge pull request #3447 from nitis-intelligence/warning/rails5
removing deprecation warning from rails 5
2015-02-03 19:03:37 -02:00
Luciano Sousa
9177bd70cf removing optional commas 2015-02-02 23:02:52 -03:00
Luciano Sousa
252a57d9b3 removing deprecation warning from rails 5 2015-02-02 22:54:46 -03:00
Lucas Mazza
394d69d958 Merge pull request #3407 from rosenfeld/inherited-controllers-translations
Use Devise translations when inheriting from core controllers
2015-01-26 20:03:11 -02:00
José Valim
65700b22ba Merge pull request #3440 from davestevens/pepper-password
Only add pepper if needed
2015-01-26 19:46:32 +01:00
Dave Stevens
8d48bcd594 Only add pepper if needed
Due to bug in Ruby 2.2.0; The bug has been acknowledged and fixed in trunk.

When password comes in FormEncoded the result of `gsub` breaks when
peppered with `nil`.
This only adds pepper if defined on the model and works around this
bug.

See: 622f3f14b6
2015-01-26 18:06:11 +00:00
José Valim
6dd4444582 Merge pull request #3432 from ronalchn/remember.used.tokens
Keep used confirmation tokens for more user friendly error message (issue #3429)
2015-01-19 13:04:30 +01:00
Ronald Chan
3f95ac8fec Keep used confirmation tokens for more user friendly error message (fixes #3429) 2015-01-19 22:30:13 +13:00
José Valim
c9fb1ebbfe Merge pull request #3428 from erdostom/master
updating copyrights to 2015
2015-01-18 22:38:29 +01:00
Tamas Erdos
bf2b37a39c updating copyrights to 2015 2015-01-18 16:21:59 -05:00
José Valim
8d3e0fddd3 Merge pull request #3425 from kbullaughey/master
get rid of config.serve_static_assets deprecation warning from production.rb
2015-01-16 21:31:38 +01:00
Kevin Bullaughey
1118762ce7 apply the same change to production.rb that was put into test.rb to get rid of the depracation warning related to the config.serve_static_assets -> config.serve_static_files in Rails 4.2.0 2015-01-16 15:29:08 -05:00
Rodrigo Rosenfeld Rosas
7e5d0ac736 Add tests for translation scope being preserved when inheriting a controller
issue #3367
2015-01-12 17:28:02 -02:00
Rodrigo Rosenfeld Rosas
c2fb80d4d9 Use Devise translations when inheriting from core controllers
closes #3367
2015-01-12 17:24:17 -02:00
José Valim
5eb9f18743 Merge pull request #3414 from georgemillo/patch-1
Remove unnecessary local variable from RegistrationsController
2015-01-11 16:35:48 +01:00
George Millo
5bb479052c Remove local variable from RegistrationsController 2015-01-11 15:10:44 +00:00
José Valim
8523801459 Merge pull request #3411 from nviennot/master
Revert "Better error message in case a trackable module can't be saved."
2015-01-10 16:18:30 +01:00
Nicolas Viennot
620478cc5f Revert "Better error message in case a trackable module can't be saved."
This reverts commit 43d0715238.

save() returns false only when validations failed. In this case, validations are
not performed. Therefore save() may never return a falsy value.
If save() fails, the appropriate exception is raised.

With certain ORMs, such as NoBrainer, save() never returns true/false, but
always raise an exception. This commit lift the incompatiblity.
2015-01-10 09:38:43 -05:00
José Valim
710efe557d Merge pull request #3405 from Dinuz/master
Update find_message to accept scope
2015-01-07 23:39:00 +01:00
Massimiliano
6c5323c574 Update devise_controller.rb 2015-01-07 14:46:02 -05:00
Massimiliano
c92ef26b94 Update find_message to accept scope
This should still keep the devise lookup in the case that a customed scope is not passed as option, but if instead the custom scope is passed, then the find_message method will use it.

This is kind of useful, if i don't want overwrite the devise locale, and use different locale files, but keeping still the fallback of my devise locale.
2015-01-06 21:06:09 -05:00
Carlos Antonio da Silva
d6972ab264 Tidy up
* Fix test class name
* No need for line breaks
2015-01-06 14:23:06 -02:00
José Valim
5dc0f8dab9 Merge pull request #3404 from vimutter/rails-initializers-order
Added devise.omniauth initializer explicit position requirements.
2015-01-06 17:15:39 +01:00
Mark Guk
b223ddeb35 Added devise.omniauth initializer explicit position requirements.
It is obvious that this initializer should be executed before Rails build_middleware_stack as Omniauth is build on middleware.
Also it is obvious that we need that initializer to be executed after all config/initializers/* files (that is where devise.rb usually is).
2015-01-06 18:05:38 +03:00
José Valim
1094ba65aa Merge pull request #3400 from eugeneius/test_helper_memoize_warden_per_request
Allow warden proxy to change with request in tests
2015-01-05 09:27:21 +01:00
Eugene Kenny
8d9dd50e4a Allow warden proxy to change with request in tests
The warden method in the Devise::TestHelpers module adds a Warden proxy
object to the request environment hash under the 'warden' key. Including
this module in your test case registers that method as a callback, which
runs before every test:
https://github.com/plataformatec/devise/blob/v3.4.1/lib/devise/test_helpers.rb#L12

The request object itself is created in a callback added by Rails:
https://github.com/rails/rails/blob/v4.2.0/actionpack/lib/action_controller/test_case.rb#L687

So before each test runs, the Rails callback creates the request object,
and then the Devise callback adds a Warden proxy object to it.

I was using the rspec-retry gem (https://github.com/y310/rspec-retry),
and noticed that my controller specs would always fail whenever they
were retried with this error:

NoMethodError: undefined method `authenticate!' for nil:NilClass

When rspec-retry re-runs a failed test, it runs the setup callbacks
again. The Rails callback creates a new request object, but because of
the memoization that was here before, the Devise callback wouldn't add a
Warden proxy to it, which was causing the error.

With this change, the Warden setup code will still only run once as long
as the request object stays the same, but if it changes a new Warden
proxy will be added to the new request object.
2015-01-05 00:34:54 +00:00
José Valim
7946f681a9 Merge pull request #3394 from JuanitoFatas/patch/fix-warning
Suppress test.rb configuration warning for Rails 4.2.
2014-12-31 09:52:21 +01:00
Juanito Fatas
b2a66732cf Suppress test.rb config warning for Rails 4.2. 2014-12-31 11:35:18 +08:00
Carlos Antonio da Silva
71861ab0bf Merge pull request #3389 from JuanitoFatas/patch/travis-ruby-2-2
Test against Ruby 2.2 on Travis.
2014-12-29 09:00:36 -02:00
Juanito Fatas
bb05314c8f Test against Ruby 2.2 on Travis.
* Add 4.2 stable to matrix.
* Exclude test against Ruby 2.2 for Rails 3.2.
2014-12-29 01:03:07 +08:00
Carlos Antonio da Silva
bebf0ecbbe Simplify the logic to display the minimum password length hint
There's no real need to pass 2 variables to the view to figure that out,
we can simply display the message relying on whether or not the
`@minimum_password_length` variable is present.
2014-12-27 11:22:40 -02:00
Carlos Antonio da Silva
5c5200b5d9 Update dependencies with the released 4.2.0 2014-12-27 11:15:08 -02:00
José Valim
5badce5e8e Merge pull request #3372 from Katee/show-min-password-length-on-edit-password
Show minimum password length on edit password
2014-12-17 21:18:48 +01:00
Katee
d0a30d485d Moves minimum_password_length to DeviseController. 2014-12-16 16:14:32 -05:00
Lucas Mazza
2c8e242000 Use Rails 4.2.0.rc3. 2014-12-16 11:03:26 -02:00
Katee
5e12b158d1 Fixes accidentally removed autofocus. 2014-12-15 20:05:46 -05:00
Katee
607bf70674 Shows min password length on edit password view. 2014-12-15 19:52:58 -05:00
José Valim
bf30ddddc0 Merge pull request #3369 from prathamesh-sonpatki/devise-fixes
Fix description of find_or_initialize_with_error methods
2014-12-12 08:21:55 +01:00
Prathamesh Sonpatki
13c2d4e807 Fix description of find_or_initialize_with_error methods
[ci skip]
2014-12-12 09:26:17 +05:30
José Valim
a9d90503e9 Merge pull request #3318 from BrentWheeldon/bugfix/clear-reset-token
Only set token back if password reset fails.
2014-12-02 11:12:12 +01:00
José Valim
c4dfd465d1 Merge pull request #3353 from psgs/readme-update
Improve README.md flow
2014-12-02 11:06:38 +01:00
psgs
0522b1eb46 Improve README.md flow
Improve the way in which the README.md file flows when read.
2014-12-02 11:41:11 +10:00
Brent Wheeldon
cb89e4435c Only set token back if password reset fails.
This prevents the digested version of the token being saved when a reset
is successful.
2014-12-01 17:58:18 -05:00
Lucas Mazza
6fb466eb1e Use Rails 4.2.0.rc1 2014-12-01 10:18:00 -02:00
Vasiliy Ermolovich
9e93b9d700 Merge pull request #3351 from gajon/master
Trivial doc text correction in authenticatable.rb
2014-12-01 10:36:43 +03:00
Jorge Gajon
640dd97149 Trivial doc text correction in authenticatable.rb 2014-11-30 22:56:44 -06:00
José Valim
681094663b Merge pull request #3342 from rubyrider/test_reset_password_token_should_match
ensuse generated token for reset password token is valid
2014-11-25 15:04:31 +01:00
Irfan Ahmed
0e218d8a01 ensuse digested token for reset password token is valid 2014-11-25 18:32:58 +06:00
Rafael Mendonça França
16005ebcfe Merge pull request #3333 from rosenfeld/master
Remove old references to removed remember_across_browsers option
2014-11-21 19:25:46 -02:00
Rodrigo Rosenfeld Rosas
ae00e0bb20 Remove old references to removed remember_across_browsers option 2014-11-21 17:33:58 -02:00
José Valim
d3d9fba201 Merge pull request #3328 from stephenbaldwin/master
Ability to load modules in specific order
2014-11-20 22:39:43 +01:00
Rafael Mendonça França
bb24d18869 Merge pull request #3325 from joshk/patch-2
Use the new build env on Travis
2014-11-20 19:16:20 -02:00
Stephen Baldwin
06e0f8adca Update devise.rb 2014-11-20 16:01:21 -05:00
Stephen Baldwin
a9e87f067a Ability to load modules in specific order
Allow modules to be inserted at set positions
2014-11-20 15:16:46 -05:00
José Valim
840ecb63a2 Merge pull request #3324 from timscott/patch-1
Option to validate upon #confirm!
2014-11-20 10:18:44 +01:00
Tim Scott
e9bf72be6a Use args hash instead of named parameters for confirm! 2014-11-19 18:38:58 -06:00
Tim Scott
3b882dadac Made ensure valid a named param for confirm!, and added a test. 2014-11-19 16:48:35 -06:00
Josh Kalderimis
3015ac458d use built in travis caching
make sure bundle update is run so that the latest gems are used
2014-11-19 17:08:07 -05:00
Josh Kalderimis
4599b57798 remove the relevant Gemfile.lock 2014-11-19 14:54:31 -05:00
Josh Kalderimis
cf53131ed6 there is no rails-head Gemfile 2014-11-19 14:51:42 -05:00
Josh Kalderimis
04561542b1 Use the new build env on Travis
- use the new build env on Travis (sudo: false) (docs coming soon)
  faster vms, more cpu, more ram, faster vm boot time
- remove the custom caching for now as the new setup has a far better network
- add rails-head to the gemfile list as it wasn't there

caching is generally not recommended for libs like Devise as you want to test against the latest gem versions. Caching will use the min requirements available on the system instead of retrieving the latest.

On that note, it is also recommended to remove the Gemfile.lock from the repo. For now I have just 'rm'd it before 'bundle install'
2014-11-19 13:49:55 -05:00
Tim Scott
4ba84eeb27 Option to validate upon #confirm!
Allow to ensure valid upon confirming.
We might want to consider confirmation status in validations. For example, maybe we want to require certain fields upon confirmation, but not at registration.
2014-11-19 12:29:08 -06:00
Lucas Mazza
c54e9863a6 Update Gemfiles. 2014-11-19 15:43:47 -02:00
Lucas Mazza
adc031b214 Update CHANGELOG [ci skip] 2014-11-19 14:26:44 -02:00
José Valim
a76dfd6552 Merge pull request #3319 from lleger/lleger-fix-password-length
Update password length validation to 72 characters max
2014-11-19 10:25:27 +01:00
José Valim
0efd9244bf Merge pull request #3320 from deivid-rodriguez/yield_the_resource_in_registrations_controller_new_action
Yield the resource in RegistrationsController#new
2014-11-19 10:24:44 +01:00
David Rodríguez
1bbcc54026 Yield the resource in RegistrationsController#new 2014-11-19 09:32:51 +01:00
Logan Leger
c7cc91cb65 Update password length validation to 72 characters max
BCrypt has a limit of 72 characters for the password. Anything beyond 72
characters is truncated. This commit updates the validation to limit
passwords to less than 72 characters, keeping within the limitation.
2014-11-18 23:10:01 -06:00
José Valim
e54326c19c Merge pull request #3314 from djpowers/update_omniauth_casing
Update casing of 'OmniAuth' to match that of official OmniAuth documentation
2014-11-14 20:56:30 +01:00
Dave Powers
63ae9701b4 Update casing of 'OmniAuth' to match that of official OmniAuth documentation 2014-11-14 14:45:09 -05:00
Carlos Antonio da Silva
c47ab5e6cf Merge pull request #3310 from djpowers/patch-1
Fix link to Michael Hartl's Rails Tutorial
2014-11-14 08:18:04 -02:00
Dave Powers
9e083c9689 Fix link to Michael Hartl's Rails Tutorial
Update link to go to authentication chapter of latest edition (3rd) of online book
2014-11-13 23:08:42 -05:00
Lucas Mazza
12b5439f84 Merge pull request #3308 from mtarnovan/master
Yield the resource in SessionsController#new
2014-11-12 11:23:07 -02:00
José Valim
c7a135d6ba Merge pull request #3303 from BM5k/callbacks
add Rememerable#after_remembered callback
2014-11-09 10:01:26 -02:00
BM5k
8c3c6ac10f add docs to other callbacks 2014-11-08 16:51:08 -07:00
BM5k
b5713a8ddf add Rememerable#after_remembered callback 2014-11-08 16:39:24 -07:00
BM5k
6f88df3453 add test for after_database_authentication 2014-11-08 16:00:07 -07:00
José Valim
910868785c Merge pull request #3295 from jbourassa/stored_location_fragment
Include URI's fragment in `store_location_for`
2014-11-05 20:06:28 -02:00
José Valim
13e1a8fd8c Merge pull request #3296 from adelevie/fix_comment_typo
Fix small typo in devise_authenticatable.rb
2014-11-05 20:06:04 -02:00
Jimmy Bourassa
5dedd8c4cf Add fragment support for store_location_for 2014-11-05 16:52:40 -05:00
Alan deLevie
09f433691a Fix small typo in devise_authenticatable.rb 2014-11-05 16:51:29 -05:00
Mihai Târnovan
3902e0702c Yield the resource in SessionsController#new 2014-11-05 15:47:10 +02:00
Lucas Mazza
d67388ad98 Merge pull request #3290 from olivierlacan/patch-1
Add release dates to each version in CHANGELOG
2014-11-03 11:02:37 -02:00
Olivier Lacan
2a5ae0200d Add release dates to each version in CHANGELOG
As I've described [here](http://keepachangelog.com), it's quite useful to associate release version numbers with dates to get situated in a change log. 

Hope you find this useful.

PS: While doing this I did notice that a release marked as yanked in the CHANGELOG was not showing up as yanked on RubyGems, hence #3289.
2014-11-03 13:52:03 +01:00
Lucas Mazza
13e07b4b61 Merge pull request #3279 from Sinbadsoft/activesurppot_load_hooks
Add ActiveSupport load hook for DeviseController
2014-11-03 10:07:07 -02:00
Chaker Nakhli
e46a21be16 remove dynamically added method to DeviseController by active support load hook test 2014-10-29 16:14:38 +01:00
Lucas Mazza
e3f794f369 Release 3.4.1 2014-10-29 12:59:33 -02:00
Chaker Nakhli
8a7796aea9 Add ActiveSupport load hook for DeviseController 2014-10-28 13:41:55 +01:00
Lucas Mazza
05d8d81ff4 Update CHANGELOG 2014-10-27 22:58:24 -02:00
Lucas Mazza
a93edc72fd Check for a Hash when using the authentication_keys to generate the FailureApp flash message.
Fixes #3270.
2014-10-27 22:32:19 -02:00
José Valim
b910f5eb83 Merge pull request #3276 from michaelmoulsdale/patch-1
Update README.md - Updated Configuring controllers section
2014-10-26 16:36:01 -02:00
Michael Moulsdale
2c2e366500 Update README.md
Updated decsription of Configuring controllers to use Users rather than Admins. This is purely to be consistent with the previous documentation
2014-10-26 18:33:27 +00:00
José Valim
11060fb8da Merge pull request #3269 from cllns/fix-field-class-on-views
Change views from class="fields" to class="field" to be same as rails scaffolding
2014-10-22 15:39:41 -02:00
Sean Collins
cfe0dc1ee1 change class="fields" to class="field" to be same as rails scaffolding 2014-10-22 12:44:01 -04:00
José Valim
2c0186e090 Merge pull request #3266 from udaysinghcode/fix-issue-3256
Fixed Issue #3256 - View Reformatting
2014-10-22 06:58:14 -02:00
Uday Singh
51263f995b updated confirmation views with the same formatting and added fields and actions to tag 2014-10-22 04:25:33 -04:00
Uday Singh
f9ca733e68 updated passwords views with proper formatting akin to scaffolding and classes for fields and actions 2014-10-22 04:23:51 -04:00
Uday Singh
9c221e2418 updated new.html.erb unlock views 2014-10-22 04:12:28 -04:00
Uday Singh
ef016b448e reformatted and updated sessions views with proper fields and action classes 2014-10-22 04:10:01 -04:00
Uday Singh
a5bab11321 reformatted fields, added fields and actions class like rails scaffolding, changed <i> html tag for updated <em> html5 tag 2014-10-22 04:08:33 -04:00
José Valim
dae49f836a Merge pull request #3263 from gdpelican/feature/localize-confirmable-tests
Localize confirmable tests
2014-10-20 15:08:08 -02:00
James Kiesel
c1864663aa Localize confirmable tests 2014-10-21 02:28:58 +13:00
José Valim
e96c9c961b Merge pull request #3260 from hbriggs/master
allow set_flash_message to set flash.now messages
2014-10-19 14:12:54 -02:00
Rafael Mendonça França
5e58b1abfa Merge pull request #3261 from seuros/patch-1
require ruby 1.9.3+
2014-10-19 13:40:55 -02:00
Abdelkader Boudih
f91dbd1b8b require ruby 1.9.3+ 2014-10-19 15:36:22 +00:00
Hannah Briggs
f80ebea0e6 allow set_flash_message to set flash.now messages 2014-10-18 21:28:20 -07:00
José Valim
2bae9da287 Merge pull request #3259 from janpantel/typo-controller-generator
Fix typo in controller generators help message
2014-10-18 17:39:53 +02:00
Jan Pantel
d6c8aef15f Fix typo in controller generators help message 2014-10-18 17:34:38 +02:00
Lucas Mazza
f246f62b10 Remove CHANGELOG entry since #3195 was reverted. 2014-10-03 14:31:01 -03:00
Łukasz Niemier
4064155312 Small refactoring 2014-03-15 16:13:57 +01:00
Łukasz Niemier
2c5126dc42 Temporary, and ugly hack. But works now 2014-02-23 21:19:53 +01:00
Łukasz Niemier
a05548110f Should fix #2882 2014-02-23 20:43:16 +01:00
158 changed files with 3101 additions and 3084 deletions

View File

@@ -1,35 +1,44 @@
language: ruby
script: "bundle exec rake test"
install: script/cached-bundle install --deployment --path vendor/bundle
rvm:
- 1.9.3
- 2.0.0
- 2.1.2
env:
matrix:
- DEVISE_ORM=mongoid
- DEVISE_ORM=active_record
global:
# AMAZON_S3_BUCKET
- secure: "qkeYGn2mpgsgU5tKS9GWvFp/utUF/9O8++Shch24DMnq8OB01TrV5QQ2Elj7sSjMWqw2Pbe56nUCA9eOWXhPglGyIq2AI9E0umsEGZxdRlqqobpiMWs5wl8KZ0cFD1rZm6CwfL8atmcNfTt5TnvsaQ2l/k3TerOT2e66R/Mibk8="
# AMAZON_ACCESS_KEY_ID
- secure: "rTYGUFH9SPN0L7QtdE6Liyy/1z7nGKxqDF9LMRsmNsIfsqxoTPKZ8bCctQ4ksuk9svynGQsLfsda5pA+YvuALzjdWmGcID6ENgOGvoFnhZO5LuJ5f6t0k8gFpV9oBquQgDWzhzrcPYvCUrUYg3GSlHjFSXdPdht3SoYn7PiDaNs="
# AMAZON_SECRET_ACCESS_KEY
- secure: "VJ4qiWMzoleLojCcluX+w0RtaFVc9ybRNo6NODkGhHSaao8+4EX4rETBQG67tNSInk1iuNqCcZAGwC8V/12RXdao3PguRSLD5IiKeT+D78dqFEoP0+yHg4PbmZ6TJXADW3gUv/IOqkW7f/UYGinRaPu7hloyiC498FpQdmMWSNI="
- 2.3.0
- 2.2.4
- 2.1.8
gemfile:
- gemfiles/Gemfile.rails-4.1-stable
- gemfiles/Gemfile.rails-4.0-stable
- gemfiles/Gemfile.rails-3.2-stable
- Gemfile
- gemfiles/Gemfile.rails-5.0-beta
- gemfiles/Gemfile.rails-4.2-stable
- gemfiles/Gemfile.rails-4.1-stable
matrix:
allow_failures:
- gemfile: gemfiles/Gemfile.rails-head
exclude:
- rvm: 2.1.8
gemfile: gemfiles/Gemfile.rails-5.0-beta
- env: DEVISE_ORM=mongoid
gemfile: gemfiles/Gemfile.rails-5.0-beta
services:
- mongodb
sudo: false
cache: bundler
env:
matrix:
- DEVISE_ORM=active_record
- DEVISE_ORM=mongoid
before_install: "rm ${BUNDLE_GEMFILE}.lock"
before_script: "bundle update"
script: "bin/test"
notifications:
email: false
campfire:
slack:
on_pull_requests: false
on_success: change
on_failure: always
rooms:
- secure: "TRiqvuM4i/QmRDWjUSNitE5/P91BOzDkNl53+bZjjtxcISCswZtmECWBR7n9\n3xwqCOU1o2lfohxZ32OHOj/Nj7o+90zWJfWxcv+if0hIXRiil62M5pg0lZUd\nyJ4M5VQ0lSWo5he1OUrXhSabPJeaK3B8yT/tdh+qO5yzR+vb/jc="
secure: Q3M+kmude3FjisibEeeGe0wSMXgvwLH+vL7Zrx9//q4QtkfnrQ/BBMvY9KXxPEsNF+eys4YopYjTkJ8uRmeboUATW/oQ4Jrv3+u3zkIHK2sFn/Q2cQWpK5w+CbgEnHPjKYnUu34b09njXTgDlr/mqtbPqrKeZ1dLlpKXCB/q4GY=

File diff suppressed because it is too large Load Diff

22
CODE_OF_CONDUCT.md Normal file
View File

@@ -0,0 +1,22 @@
# Contributor Code of Conduct
As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, or nationality.
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery
* Personal attacks
* Trolling or insulting/derogatory comments
* Public or private harassment
* Publishing other's private information, such as physical or electronic addresses, without explicit permission
* Other unethical or unprofessional conduct.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. By adopting this Code of Conduct, project maintainers commit themselves to fairly and consistently applying these principles to every aspect of managing this project. Project maintainers who do not follow or enforce the Code of Conduct may be permanently removed from the project team.
This code of conduct applies both within project spaces and in public spaces when an individual is representing the project or its community.
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by sending an email to [conduct@plataformatec.com.br](conduct@plataformatec.com.br) or contacting one or more of the project maintainers.
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0, available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/)

View File

@@ -8,6 +8,8 @@
4) When reporting an issue, include Rails, Devise and Warden versions. If you are getting exceptions, please include the full backtrace.
5) Notice that all of your interactions in the project are expected to follow our [Code of Conduct](CODE_OF_CONDUCT.md)
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.

View File

@@ -2,9 +2,9 @@ source "https://rubygems.org"
gemspec
gem "rails", "4.2.0.beta2"
gem "omniauth", "~> 1.2.0"
gem "omniauth-oauth2", "~> 1.1.0"
gem "rails", "~> 4.2.6"
gem "omniauth", "~> 1.3"
gem "omniauth-oauth2", "~> 1.4"
gem "rdoc"
group :test do
@@ -12,6 +12,7 @@ group :test do
gem "omniauth-openid", "~> 1.0.1"
gem "webrat", "0.7.3", require: false
gem "mocha", "~> 1.1", require: false
gem 'test_after_commit', require: false
end
platforms :jruby do
@@ -25,5 +26,5 @@ platforms :ruby do
end
group :mongoid do
gem "mongoid", github: "mongoid/mongoid", branch: "master"
gem "mongoid", "~> 5.0"
end

View File

@@ -1,171 +1,157 @@
GIT
remote: git://github.com/mongoid/mongoid.git
revision: 5ba2e1fb4cb8189c9890e29c19cf4e16c25e4bc5
branch: master
specs:
mongoid (4.0.0)
activemodel (~> 4.0)
moped (~> 2.0.0)
origin (~> 2.1)
tzinfo (>= 0.3.37)
PATH
remote: .
specs:
devise (3.4.0)
devise (4.1.0)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 3.2.6, < 5)
railties (>= 4.1.0, < 5.1)
responders
thread_safe (~> 0.1)
warden (~> 1.2.3)
GEM
remote: https://rubygems.org/
specs:
actionmailer (4.2.0.beta2)
actionpack (= 4.2.0.beta2)
actionview (= 4.2.0.beta2)
activejob (= 4.2.0.beta2)
actionmailer (4.2.6)
actionpack (= 4.2.6)
actionview (= 4.2.6)
activejob (= 4.2.6)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 1.0, >= 1.0.3)
actionpack (4.2.0.beta2)
actionview (= 4.2.0.beta2)
activesupport (= 4.2.0.beta2)
rack (~> 1.6.0.beta)
rails-dom-testing (~> 1.0, >= 1.0.5)
actionpack (4.2.6)
actionview (= 4.2.6)
activesupport (= 4.2.6)
rack (~> 1.6)
rack-test (~> 0.6.2)
rails-dom-testing (~> 1.0, >= 1.0.3)
rails-html-sanitizer (~> 1.0, >= 1.0.1)
actionview (4.2.0.beta2)
activesupport (= 4.2.0.beta2)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (4.2.6)
activesupport (= 4.2.6)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 1.0, >= 1.0.3)
rails-html-sanitizer (~> 1.0, >= 1.0.1)
activejob (4.2.0.beta2)
activesupport (= 4.2.0.beta2)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
activejob (4.2.6)
activesupport (= 4.2.6)
globalid (>= 0.3.0)
activemodel (4.2.0.beta2)
activesupport (= 4.2.0.beta2)
activemodel (4.2.6)
activesupport (= 4.2.6)
builder (~> 3.1)
activerecord (4.2.0.beta2)
activemodel (= 4.2.0.beta2)
activesupport (= 4.2.0.beta2)
arel (>= 6.0.0.beta1, < 6.1)
activesupport (4.2.0.beta2)
i18n (>= 0.7.0.beta1, < 0.8)
activerecord (4.2.6)
activemodel (= 4.2.6)
activesupport (= 4.2.6)
arel (~> 6.0)
activesupport (4.2.6)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
arel (6.0.0.beta1)
bcrypt (3.1.7)
bson (2.3.0)
arel (6.0.3)
bcrypt (3.1.11)
bson (4.0.0)
builder (3.2.2)
connection_pool (2.0.0)
concurrent-ruby (1.0.1)
erubis (2.7.0)
faraday (0.9.0)
faraday (0.9.2)
multipart-post (>= 1.2, < 3)
globalid (0.3.0)
globalid (0.3.6)
activesupport (>= 4.1.0)
hashie (3.2.0)
hike (1.2.3)
i18n (0.7.0.beta1)
json (1.8.1)
jwt (1.0.0)
loofah (2.0.1)
hashie (3.4.3)
i18n (0.7.0)
json (1.8.3)
jwt (1.5.1)
loofah (2.0.3)
nokogiri (>= 1.5.9)
mail (2.6.1)
mail (2.6.3)
mime-types (>= 1.16, < 3)
metaclass (0.0.4)
mime-types (2.3)
mini_portile (0.6.0)
minitest (5.4.2)
mime-types (2.99.1)
mini_portile2 (2.0.0)
minitest (5.8.4)
mocha (1.1.0)
metaclass (~> 0.0.1)
moped (2.0.0)
bson (~> 2.2)
connection_pool (~> 2.0)
optionable (~> 0.2.0)
multi_json (1.10.1)
mongo (2.2.0)
bson (~> 4.0)
mongoid (5.0.1)
activemodel (~> 4.0)
mongo (~> 2.1)
origin (~> 2.1)
tzinfo (>= 0.3.37)
multi_json (1.11.2)
multi_xml (0.5.5)
multipart-post (2.0.0)
nokogiri (1.6.3.1)
mini_portile (= 0.6.0)
oauth2 (0.9.4)
nokogiri (1.6.7.2)
mini_portile2 (~> 2.0.0.rc2)
oauth2 (1.1.0)
faraday (>= 0.8, < 0.10)
jwt (~> 1.0)
jwt (~> 1.0, < 1.5.2)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (~> 1.2)
omniauth (1.2.2)
rack (>= 1.2, < 3)
omniauth (1.3.1)
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 (3.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.2.0)
orm_adapter (0.5.0)
rack (1.6.0.beta)
rack (1.6.4)
rack-openid (1.3.1)
rack (>= 1.1.0)
ruby-openid (>= 2.1.8)
rack-test (0.6.2)
rack-test (0.6.3)
rack (>= 1.0)
rails (4.2.0.beta2)
actionmailer (= 4.2.0.beta2)
actionpack (= 4.2.0.beta2)
actionview (= 4.2.0.beta2)
activejob (= 4.2.0.beta2)
activemodel (= 4.2.0.beta2)
activerecord (= 4.2.0.beta2)
activesupport (= 4.2.0.beta2)
rails (4.2.6)
actionmailer (= 4.2.6)
actionpack (= 4.2.6)
actionview (= 4.2.6)
activejob (= 4.2.6)
activemodel (= 4.2.6)
activerecord (= 4.2.6)
activesupport (= 4.2.6)
bundler (>= 1.3.0, < 2.0)
railties (= 4.2.0.beta2)
sprockets-rails (~> 3.0.0.beta1)
railties (= 4.2.6)
sprockets-rails
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.3)
activesupport
rails-dom-testing (1.0.7)
activesupport (>= 4.2.0.beta, < 5.0)
nokogiri (~> 1.6.0)
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.1)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
railties (4.2.0.beta2)
actionpack (= 4.2.0.beta2)
activesupport (= 4.2.0.beta2)
railties (4.2.6)
actionpack (= 4.2.6)
activesupport (= 4.2.6)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.3.2)
rdoc (4.1.1)
rake (11.0.1)
rdoc (4.2.2)
json (~> 1.4)
responders (2.0.0)
railties (>= 4.2.0.alpha, < 5)
ruby-openid (2.5.0)
sprockets (2.12.2)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sprockets-rails (3.0.0.beta1)
responders (2.2.0)
railties (>= 4.2.0, < 5.1)
ruby-openid (2.7.0)
sprockets (3.5.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.0.4)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (~> 2.8)
sqlite3 (1.3.9)
sprockets (>= 3.0.0)
sqlite3 (1.3.11)
test_after_commit (1.0.0)
activerecord (>= 3.2)
thor (0.19.1)
thread_safe (0.3.4)
tilt (1.4.1)
thread_safe (0.3.5)
tzinfo (1.2.2)
thread_safe (~> 0.1)
warden (1.2.3)
warden (1.2.6)
rack (>= 1.0)
webrat (0.7.3)
nokogiri (>= 1.2.0)
@@ -181,12 +167,16 @@ DEPENDENCIES
devise!
jruby-openssl
mocha (~> 1.1)
mongoid!
omniauth (~> 1.2.0)
mongoid (~> 5.0)
omniauth (~> 1.3)
omniauth-facebook
omniauth-oauth2 (~> 1.1.0)
omniauth-oauth2 (~> 1.4)
omniauth-openid (~> 1.0.1)
rails (= 4.2.0.beta2)
rails (~> 4.2.6)
rdoc
sqlite3
test_after_commit
webrat (= 0.7.3)
BUNDLED WITH
1.11.2

View File

@@ -1,4 +1,4 @@
Copyright 2009-2014 Plataformatec. http://plataformatec.com.br
Copyright 2009-2016 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

142
README.md
View File

@@ -2,9 +2,8 @@
By [Plataformatec](http://plataformatec.com.br/).
[![Build Status](https://api.travis-ci.org/plataformatec/devise.png?branch=master)](http://travis-ci.org/plataformatec/devise)
[![Code Climate](https://codeclimate.com/github/plataformatec/devise.png)](https://codeclimate.com/github/plataformatec/devise)
[![Security](https://hakiri.io/github/plataformatec/devise/master.svg)](https://hakiri.io/github/plataformatec/devise/master)
[![Build Status](https://api.travis-ci.org/plataformatec/devise.svg?branch=master)](http://travis-ci.org/plataformatec/devise)
[![Code Climate](https://codeclimate.com/github/plataformatec/devise.svg)](https://codeclimate.com/github/plataformatec/devise)
This README is [also available in a friendly navigable format](http://devise.plataformatec.com.br/).
@@ -13,23 +12,21 @@ Devise is a flexible authentication solution for Rails based on Warden. It:
* Is Rack based;
* Is a complete MVC solution based on Rails engines;
* Allows you to have multiple models signed in at the same time;
* Is based on a modularity concept: use just what you really need.
* Is based on a modularity concept: use only what you really need.
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.
* [Database Authenticatable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/DatabaseAuthenticatable): hashes and stores a password in the database to validate the authenticity of a user while signing in. The authentication can be done both through POST requests or HTTP Basic Authentication.
* [Omniauthable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Omniauthable): adds OmniAuth (https://github.com/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 no activity in a specified period of time.
* [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.
Devise is guaranteed to be thread-safe on YARV. Thread-safety support on JRuby is in progress.
## Information
### The Devise wiki
@@ -44,7 +41,7 @@ If you discover a problem with Devise, we would like to know about it. However,
https://github.com/plataformatec/devise/wiki/Bug-reports
If you found a security bug, do *NOT* use the GitHub issue tracker. Send an email to opensource@plataformatec.com.br.
If you have discovered a security related bug, please do *NOT* use the GitHub issue tracker. Send an email to opensource@plataformatec.com.br.
### Mailing list
@@ -82,16 +79,17 @@ You will usually want to write tests for your changes. To run the test suite, g
## Starting with Rails?
If you are building your first Rails application, we recommend you to *not* use Devise. Devise requires a good understanding of the Rails Framework. In such cases, we advise you to start a simple authentication system from scratch, today we have two resources:
If you are building your first Rails application, we recommend you *do not* use Devise. Devise requires a good understanding of the Rails Framework. In such cases, we advise you to start a simple authentication system from scratch. Today, we have three resources that should help you get started:
* Michael Hartl's online book: http://www.railstutorial.org/book/demo_app#sec-modeling_demo_users
* 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
Once you have solidified your understanding of Rails and authentication mechanisms, we assure you Devise will be very pleasant to work with. :)
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.2 onwards. You can add it to your Gemfile with:
```ruby
gem 'devise'
@@ -105,13 +103,13 @@ After you install Devise and add it to your Gemfile, you need to run the generat
rails generate devise:install
```
The generator will install an initializer which describes ALL Devise's configuration options and you MUST take a look at it. When you are done, you are ready to add Devise to any of your models using the generator:
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.
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.
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`
@@ -121,7 +119,7 @@ Next, you need to set up the default URL options for the Devise mailer in each e
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
```
You should restart your application after changing Devise's configuration options. Otherwise you'll run into strange errors like users being unable to login and route helpers being undefined.
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.
### Controller filters and helpers
@@ -131,6 +129,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:
@@ -151,7 +151,7 @@ You can access the session for this scope:
user_session
```
After signing in a user, confirming the account or updating the password, Devise will look for a scoped root path to redirect. For instance, for 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:
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"
@@ -173,25 +173,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
```
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.
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 allows 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 with 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 filter in your `ApplicationController`:
```ruby
class ApplicationController < ActionController::Base
@@ -200,7 +204,7 @@ 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
```
@@ -211,27 +215,32 @@ 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
```
If you have some checkboxes that express the roles a user may take on registration, the browser will send those selected checkboxes as an array. An array is not one of Strong Parameters permitted scalars, so we need to configure Devise thusly:
If you have some checkboxes that express the roles a user may take on registration, the browser will send those selected checkboxes as an array. An array is not one of Strong Parameters' permitted scalars, so we need to configure Devise in the following way:
```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
https://github.com/rails/strong_parameters#nested-parameters
If you have multiple Devise models, you may want to set up different parameter sanitizer per model. In this case, we recommend inheriting from `Devise::ParameterSanitizer` and add your own logic:
If you have multiple Devise models, you may want to set up a different parameter sanitizer per model. In this case, we recommend inheriting from `Devise::ParameterSanitizer` and adding your own logic:
```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
```
@@ -272,7 +281,7 @@ After doing so, you will be able to have views based on the role like `users/ses
rails generate devise:views users
```
If you want to generate only a few set of views, like the ones for the `registrable` and `confirmable` module,
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
@@ -289,11 +298,11 @@ If the customization at the views level is not enough, you can customize each co
rails generate devise:controllers [scope]
```
If you specify `admins` as the scope, controllers will be created in `app/controllers/admins/`.
If you specify `users` as the scope, controllers will be created in `app/controllers/users/`.
And the sessions controller will look like this:
```ruby
class Admins::SessionsController < Devise::SessionsController
class Users::SessionsController < Devise::SessionsController
# GET /resource/sign_in
# def new
# super
@@ -305,17 +314,17 @@ If the customization at the views level is not enough, you can customize each co
2. Tell the router to use this controller:
```ruby
devise_for :admins, controllers: { sessions: "admins/sessions" }
devise_for :users, controllers: { sessions: "users/sessions" }
```
3. Copy the views from `devise/sessions` to `admins/sessions`. Since the controller was changed, it won't use the default views located in `devise/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`.
4. Finally, change or extend the desired controller actions.
You can completely override a controller action:
```ruby
class Admins::SessionsController < Devise::SessionsController
class Users::SessionsController < Devise::SessionsController
def create
# custom sign-in code
end
@@ -325,7 +334,7 @@ If the customization at the views level is not enough, you can customize each co
Or you can simply add new behaviour to it:
```ruby
class Admins::SessionsController < Devise::SessionsController
class Users::SessionsController < Devise::SessionsController
def create
super do |resource|
BackgroundWorker.trigger(resource)
@@ -336,7 +345,7 @@ If the customization at the views level is not enough, you can customize each co
This is useful for triggering background jobs or logging events during certain actions.
Remember that Devise uses flash messages to let users know if sign in was successful or failed. Devise expects your application to call `flash[:notice]` and `flash[:alert]` as appropriate. Do not print the entire flash hash, print only specific keys. In some circumstances, Devise adds a `:timedout` key to the flash hash, which is not meant for display. Remove this key from the hash if you intend to print the entire hash.
Remember that Devise uses flash messages to let users know if sign in was successful or unsuccessful. Devise expects your application to call `flash[:notice]` and `flash[:alert]` as appropriate. Do not print the entire flash hash, print only specific keys. In some circumstances, Devise adds a `:timedout` key to the flash hash, which is not meant for display. Remove this key from the hash if you intend to print the entire hash.
### Configuring routes
@@ -346,9 +355,9 @@ Devise also ships with default routes. If you need to customize them, you should
devise_for :users, path: "auth", path_names: { sign_in: 'login', sign_out: 'logout', password: 'secret', confirmation: 'verification', unlock: 'unblock', registration: 'register', sign_up: 'cmon_let_me_in' }
```
Be sure to check `devise_for` documentation 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 to create your routes normally and wrap them in a `devise_scope` block in the router:
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
@@ -356,11 +365,11 @@ devise_scope :user do
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.
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.
### I18n
Devise uses flash messages with I18n with the flash keys :notice and :alert. To customize your app, you can set up your locale file:
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:
```yaml
en:
@@ -398,11 +407,11 @@ Take a look at our locale file to check all available messages. You may also be
https://github.com/plataformatec/devise/wiki/I18n
Caution: Devise Controllers inherit from ApplicationController. If your app uses multiple locales, you should be sure to set I18n.locale in ApplicationController
Caution: Devise Controllers inherit from ApplicationController. If your app uses multiple locales, you should be sure to set I18n.locale in ApplicationController.
### 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 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 (make sure you place it out of scope of `ActiveSupport::TestCase` which is the default class inside of `test/test_helper.rb`):
```ruby
class ActionController::TestCase
@@ -415,9 +424,12 @@ If you're using RSpec, you can put the following inside a file named `spec/suppo
```ruby
RSpec.configure do |config|
config.include Devise::TestHelpers, type: :controller
config.include Devise::TestHelpers, 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:
```ruby
@@ -430,24 +442,28 @@ sign_out @user # sign_out(resource)
There are two things that are important to keep in mind:
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;
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. It is undesirable even to include `Devise::TestHelpers` during integration tests. Instead, fill in the form or explicitly set the user in session;
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 told explicitly. For example, if you are testing the user scope, simply do:
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:
```ruby
@request.env["devise.mapping"] = Devise.mappings[:user]
get :new
```
### Omniauth
You can read more about testing your Rails 3 - Rails 4 controllers with RSpec in the wiki:
Devise comes with Omniauth support out of the box to authenticate with other providers. To use it, just specify your omniauth configuration in `config/initializers/devise.rb`:
* https://github.com/plataformatec/devise/wiki/How-To:-Test-controllers-with-Rails-3-and-4-%28and-RSpec%29
### OmniAuth
Devise comes with OmniAuth support out of the box to authenticate with other providers. To use it, simply specify your OmniAuth configuration in `config/initializers/devise.rb`:
```ruby
config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
```
You can read more about Omniauth support in the wiki:
You can read more about OmniAuth support in the wiki:
* https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview
@@ -460,7 +476,7 @@ Devise allows you to set up as many Devise models as you want. If you want to ha
create_table :admins do |t|
t.string :email
t.string :encrypted_password
t.timestamps
t.timestamps null: false
end
# Inside your Admin model
@@ -470,7 +486,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?
@@ -480,12 +496,12 @@ admin_session
Alternatively, you can simply run the Devise generator.
Keep in mind that those models will have completely different routes. They **do not** and **cannot** share the same controller for sign in, sign out and so on. In case you want to have different roles sharing the same actions, we recommend you to use a role-based approach, by either providing a role column or using a dedicated gem for authorization.
Keep in mind that those models will have completely different routes. They **do not** and **cannot** share the same controller for sign in, sign out and so on. In case you want to have different roles sharing the same actions, we recommend that you use a role-based approach, by either providing a role column or using a dedicated gem for authorization.
### ActiveJob Integration
If you are using Rails 4.2 and ActiveJob to deliver ActionMailer messages in the
background through a queueing backend, you can send Devise emails through your
background through a queuing back-end, you can send Devise emails through your
existing queue by overriding the `send_devise_notification` method in your model.
```ruby
@@ -494,15 +510,29 @@ def send_devise_notification(notification, *args)
end
```
### Password reset tokens and Rails logs
If you enable the [Recoverable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Recoverable) module, note that a stolen password reset token could give an attacker access to your application. Devise takes effort to generate random, secure tokens, and stores only token digests in the database, never plaintext. However the default logging behavior in Rails can cause plaintext tokens to leak into log files:
1. Action Mailer logs the entire contents of all outgoing emails to the DEBUG level. Password reset tokens delivered to users in email will be leaked.
2. Active Job logs all arguments to every enqueued job at the INFO level. If you configure Devise to use `deliver_later` to send password reset emails, password reset tokens will be leaked.
Rails sets the production logger level to DEBUG by default. Consider changing your production logger level to WARN if you wish to prevent tokens from being leaked into your logs. In `config/environments/production.rb`:
```ruby
config.log_level = :warn
```
### Other ORMs
Devise supports ActiveRecord (default) and Mongoid. To choose other ORM, you just need to require it in the initializer file.
Devise supports ActiveRecord (default) and Mongoid. To select another ORM, simply require it in the initializer file.
## Additional information
### Heroku
Using Devise on Heroku with Ruby on Rails 3.1 requires setting:
Using Devise on Heroku with Ruby on Rails 3.2 requires setting:
```ruby
config.assets.initialize_on_precompile = false
@@ -524,6 +554,6 @@ https://github.com/plataformatec/devise/graphs/contributors
## License
MIT License. Copyright 2009-2014 Plataformatec. http://plataformatec.com.br
MIT License. Copyright 2009-2016 Plataformatec. http://plataformatec.com.br
You are not granted rights or licenses to the trademarks of the Plataformatec, including without limitation the Devise name or logo.
You are not granted rights or licenses to the trademarks of Plataformatec, including without limitation the Devise name or logo.

View File

@@ -1,5 +1,6 @@
# encoding: UTF-8
require "bundler/gem_tasks"
require 'bundler/gem_tasks'
require 'rake/testtask'
require 'rdoc/task'

View File

@@ -22,7 +22,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 }
@@ -44,4 +44,8 @@ class Devise::ConfirmationsController < DeviseController
new_session_path(resource_name)
end
end
def translation_scope
'devise.confirmations'
end
end

View File

@@ -1,5 +1,5 @@
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."
@@ -13,18 +13,22 @@ class Devise::OmniauthCallbacksController < DeviseController
protected
def failed_strategy
env["omniauth.error.strategy"]
request.respond_to?(:get_header) ? request.get_header("omniauth.error.strategy") : env["omniauth.error.strategy"]
end
def failure_message
exception = env["omniauth.error"]
exception = request.respond_to?(:get_header) ? request.get_header("omniauth.error") : 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") : env["omniauth.error.type"]).to_s
error.to_s.humanize if error
end
def after_omniauth_failure_path_for(scope)
new_session_path(scope)
end
def translation_scope
'devise.omniauth_callbacks'
end
end

View File

@@ -1,7 +1,7 @@
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
@@ -23,6 +23,7 @@ class Devise::PasswordsController < DeviseController
# GET /resource/password/edit?reset_password_token=abcdef
def edit
self.resource = resource_class.new
set_minimum_password_length
resource.reset_password_token = params[:reset_password_token]
end
@@ -33,18 +34,23 @@ class Devise::PasswordsController < DeviseController
if resource.errors.empty?
resource.unlock_access! if unlockable?(resource)
flash_message = resource.active_for_authentication? ? :updated : :updated_not_active
set_flash_message(:notice, flash_message) if is_flashing_format?
sign_in(resource_name, resource)
if Devise.sign_in_after_reset_password
flash_message = resource.active_for_authentication? ? :updated : :updated_not_active
set_flash_message!(:notice, flash_message)
sign_in(resource_name, resource)
else
set_flash_message!(:notice, :updated_not_active)
end
respond_with resource, location: after_resetting_password_path_for(resource)
else
set_minimum_password_length
respond_with resource
end
end
protected
def after_resetting_password_path_for(resource)
after_sign_in_path_for(resource)
Devise.sign_in_after_reset_password ? after_sign_in_path_for(resource) : new_session_path(resource_name)
end
# The path used after sending reset password instructions
@@ -67,4 +73,8 @@ class Devise::PasswordsController < DeviseController
resource.respond_to?(:unlock_strategy_enabled?) &&
resource.unlock_strategy_enabled?(:email)
end
def translation_scope
'devise.passwords'
end
end

View File

@@ -1,14 +1,12 @@
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]
# GET /resource/sign_up
def new
build_resource({})
@validatable = devise_mapping.validatable?
if @validatable
@minimum_password_length = resource_class.password_length.min
end
set_minimum_password_length
yield resource if block_given?
respond_with self.resource
end
@@ -16,24 +14,21 @@ class Devise::RegistrationsController < DeviseController
def create
build_resource(sign_up_params)
resource_saved = resource.save
resource.save
yield resource if block_given?
if resource_saved
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
else
clean_up_passwords resource
@validatable = devise_mapping.validatable?
if @validatable
@minimum_password_length = resource_class.password_length.min
end
set_minimum_password_length
respond_with resource
end
end
@@ -70,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
@@ -145,4 +140,8 @@ class Devise::RegistrationsController < DeviseController
def account_update_params
devise_parameter_sanitizer.sanitize(:account_update)
end
def translation_scope
'devise.registrations'
end
end

View File

@@ -1,20 +1,21 @@
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
self.resource = resource_class.new(sign_in_params)
clean_up_passwords(resource)
yield resource if block_given?
respond_with(resource, serialize_options(resource))
end
# 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)
@@ -23,7 +24,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
@@ -45,6 +46,10 @@ class Devise::SessionsController < DeviseController
{ scope: resource_name, recall: "#{controller_path}#new" }
end
def translation_scope
'devise.sessions'
end
private
# Check if there is no signed in user before doing the sign out.
@@ -53,7 +58,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,5 @@
class Devise::UnlocksController < DeviseController
prepend_before_filter :require_no_authentication
prepend_before_action :require_no_authentication
# GET /resource/unlock/new
def new
@@ -24,7 +24,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 }
@@ -43,4 +43,7 @@ class Devise::UnlocksController < DeviseController
new_session_path(resource) if is_navigational_format?
end
def translation_scope
'devise.unlocks'
end
end

View File

@@ -2,16 +2,36 @@
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)
hide_action(*helpers)
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.
# Notice we need to check for the request due to a bug in
# 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
# itself. Changing its visibility may break other gems.
def _prefixes #:nodoc:
@_prefixes ||= if self.class.scoped_views? && request && devise_mapping
["#{devise_mapping.scoped_path}/#{controller_name}"] + super
else
super
end
end
protected
# Gets the actual resource stored in the instance variable
def resource
instance_variable_get(:"@#{resource_name}")
@@ -38,22 +58,6 @@ class DeviseController < Devise.parent_controller.constantize
@devise_mapping ||= request.env["devise.mapping"]
end
# Override prefixes to consider the scoped view.
# Notice we need to check for the request due to a bug in
# Action Controller tests that forces _prefixes to be
# loaded before even having a request object.
def _prefixes #:nodoc:
@_prefixes ||= if self.class.scoped_views? && request && devise_mapping
["#{devise_mapping.scoped_path}/#{controller_name}"] + super
else
super
end
end
hide_action :_prefixes
protected
# Checks whether it's a devise mapped resource or not.
def assert_is_devise_resource! #:nodoc:
unknown_action! <<-MESSAGE unless devise_mapping
@@ -89,10 +93,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?
@@ -123,14 +127,17 @@ 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 one is
# found we look to default scope.
# 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
# next action).
# Example (i18n locale file):
#
# en:
@@ -144,7 +151,25 @@ MESSAGE
# available.
def set_flash_message(key, kind, options = {})
message = find_message(kind, options)
flash[key] = message if message.present?
if options[:now]
flash.now[key] = message if message.present?
else
flash[key] = message if message.present?
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?
@minimum_password_length = resource_class.password_length.min
end
end
def devise_i18n_options(options)
@@ -153,13 +178,20 @@ MESSAGE
# Get message for given
def find_message(kind, options = {})
options[:scope] = "devise.#{controller_name}"
options[:scope] ||= translation_scope
options[:default] = Array(options[:default]).unshift(kind.to_sym)
options[:resource_name] = resource_name
options = devise_i18n_options(options)
I18n.t("#{options[:resource_name]}.#{kind}", options)
end
# Controllers inheriting DeviseController are advised to override this
# method so that other controllers inheriting from them would use
# existing translations.
def translation_scope
"devise.#{controller_name}"
end
def clean_up_passwords(object)
object.clean_up_passwords if object.respond_to?(:clean_up_passwords)
end
@@ -173,4 +205,6 @@ MESSAGE
def resource_params
params.fetch(resource_name, {})
end
ActiveSupport.run_load_hooks(:devise_controller, self)
end

View File

@@ -16,5 +16,9 @@ if defined?(ActionMailer)
@token = token
devise_mail(record, :unlock_instructions, opts)
end
def password_change(record, opts={})
devise_mail(record, :password_change, opts)
end
end
end

View File

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

View File

@@ -0,0 +1,3 @@
<p>Hello <%= @resource.email %>!</p>
<p>We're contacting you to notify you that your password has been changed.</p>

View File

@@ -4,13 +4,22 @@
<%= devise_error_messages! %>
<%= f.hidden_field :reset_password_token %>
<div><%= f.label :password, "New password" %><br />
<%= f.password_field :password, autofocus: true, autocomplete: "off" %></div>
<div class="field">
<%= f.label :password, "New password" %><br />
<% if @minimum_password_length %>
<em>(<%= @minimum_password_length %> characters minimum)</em><br />
<% end %>
<%= f.password_field :password, autofocus: true, autocomplete: "off" %>
</div>
<div><%= f.label :password_confirmation, "Confirm new password" %><br />
<%= f.password_field :password_confirmation, autocomplete: "off" %></div>
<div class="field">
<%= f.label :password_confirmation, "Confirm new password" %><br />
<%= f.password_field :password_confirmation, autocomplete: "off" %>
</div>
<div><%= f.submit "Change my password" %></div>
<div class="actions">
<%= f.submit "Change my password" %>
</div>
<% end %>
<%= render "devise/shared/links" %>

View File

@@ -3,10 +3,14 @@
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %>
<%= devise_error_messages! %>
<div><%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %></div>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
</div>
<div><%= f.submit "Send me reset password instructions" %></div>
<div class="actions">
<%= f.submit "Send me reset password instructions" %>
</div>
<% end %>
<%= render "devise/shared/links" %>

View File

@@ -3,23 +3,33 @@
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
<%= devise_error_messages! %>
<div><%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %></div>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
</div>
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
<div>Currently waiting confirmation for: <%= resource.unconfirmed_email %></div>
<% end %>
<div><%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
<%= f.password_field :password, autocomplete: "off" %></div>
<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" %>
</div>
<div><%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation, autocomplete: "off" %></div>
<div class="field">
<%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation, autocomplete: "off" %>
</div>
<div><%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
<%= f.password_field :current_password, autocomplete: "off" %></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" %>
</div>
<div><%= f.submit "Update" %></div>
<div class="actions">
<%= f.submit "Update" %>
</div>
<% end %>
<h3>Cancel my account</h3>

View File

@@ -3,16 +3,27 @@
<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<div><%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %></div>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
</div>
<div><%= f.label :password %> <% if @validatable %><i>(<%= @minimum_password_length %> characters minimum)</i><% end %><br />
<%= f.password_field :password, autocomplete: "off" %></div>
<div class="field">
<%= f.label :password %>
<% if @minimum_password_length %>
<em>(<%= @minimum_password_length %> characters minimum)</em>
<% end %><br />
<%= f.password_field :password, autocomplete: "off" %>
</div>
<div><%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation, autocomplete: "off" %></div>
<div class="field">
<%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation, autocomplete: "off" %>
</div>
<div><%= f.submit "Sign up" %></div>
<div class="actions">
<%= f.submit "Sign up" %>
</div>
<% end %>
<%= render "devise/shared/links" %>

View File

@@ -1,17 +1,26 @@
<h2>Log in</h2>
<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
<div><%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %></div>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
</div>
<div><%= f.label :password %><br />
<%= f.password_field :password, autocomplete: "off" %></div>
<div class="field">
<%= f.label :password %><br />
<%= f.password_field :password, autocomplete: "off" %>
</div>
<% if devise_mapping.rememberable? -%>
<div><%= f.check_box :remember_me %> <%= f.label :remember_me %></div>
<div class="field">
<%= f.check_box :remember_me %>
<%= f.label :remember_me %>
</div>
<% end -%>
<div><%= f.submit "Log in" %></div>
<div class="actions">
<%= f.submit "Log in" %>
</div>
<% end %>
<%= render "devise/shared/links" %>

View File

@@ -20,6 +20,6 @@
<%- if devise_mapping.omniauthable? %>
<%- resource_class.omniauth_providers.each do |provider| %>
<%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %><br />
<%= link_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider) %><br />
<% end -%>
<% end -%>

View File

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

13
bin/test Executable file
View File

@@ -0,0 +1,13 @@
#!/usr/bin/env ruby
$: << File.expand_path(File.expand_path('../../test', __FILE__))
require 'bundler/setup'
begin
require 'rails/test_unit/minitest_plugin'
rescue LoadError
exec 'rake'
end
Rails::TestUnitReporter.executable = 'bin/test'
exit Minitest.run(ARGV)

View File

@@ -23,6 +23,8 @@ en:
subject: "Reset password instructions"
unlock_instructions:
subject: "Unlock instructions"
password_change:
subject: "Password Changed"
omniauth_callbacks:
failure: "Could not authenticate you from %{kind} because \"%{reason}\"."
success: "Successfully authenticated from %{kind} account."

View File

@@ -13,16 +13,14 @@ Gem::Specification.new do |s|
s.description = "Flexible authentication solution for Rails with Warden"
s.authors = ['José Valim', 'Carlos Antônio']
s.rubyforge_project = "devise"
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- test/*`.split("\n")
s.require_paths = ["lib"]
s.required_ruby_version = '>= 2.1.0'
s.add_dependency("warden", "~> 1.2.3")
s.add_dependency("orm_adapter", "~> 0.1")
s.add_dependency("bcrypt", "~> 3.0")
s.add_dependency("thread_safe", "~> 0.1")
s.add_dependency("railties", ">= 3.2.6", "< 5")
s.add_dependency("railties", ">= 4.1.0", "< 5.1")
s.add_dependency("responders")
end

View File

@@ -1,169 +0,0 @@
GIT
remote: git://github.com/rails/rails.git
revision: 11fd052aa815ae0255ea5b2463e88138fb3fec61
branch: 3-2-stable
specs:
actionmailer (3.2.19)
actionpack (= 3.2.19)
mail (~> 2.5.4)
actionpack (3.2.19)
activemodel (= 3.2.19)
activesupport (= 3.2.19)
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.19)
activesupport (= 3.2.19)
builder (~> 3.0.0)
activerecord (3.2.19)
activemodel (= 3.2.19)
activesupport (= 3.2.19)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activeresource (3.2.19)
activemodel (= 3.2.19)
activesupport (= 3.2.19)
activesupport (3.2.19)
i18n (~> 0.6, >= 0.6.4)
multi_json (~> 1.0)
rails (3.2.19)
actionmailer (= 3.2.19)
actionpack (= 3.2.19)
activerecord (= 3.2.19)
activeresource (= 3.2.19)
activesupport (= 3.2.19)
bundler (~> 1.0)
railties (= 3.2.19)
railties (3.2.19)
actionpack (= 3.2.19)
activesupport (= 3.2.19)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
PATH
remote: ..
specs:
devise (3.4.0)
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.7)
builder (3.0.4)
erubis (2.7.0)
faraday (0.9.0)
multipart-post (>= 1.2, < 3)
hashie (3.2.0)
hike (1.2.3)
i18n (0.6.11)
journey (1.0.4)
json (1.8.1)
jwt (1.0.0)
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.0)
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.10.1)
multi_xml (0.5.5)
multipart-post (2.0.0)
nokogiri (1.6.3.1)
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.2)
rack (>= 1.0)
rake (10.3.2)
rdoc (3.12.2)
json (~> 1.4)
responders (1.1.1)
railties (>= 3.2, < 4.2)
ruby-openid (2.5.0)
sprockets (2.2.2)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.9)
thor (0.19.1)
thread_safe (0.3.4)
tilt (1.4.1)
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.41)
warden (1.2.3)
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)

View File

@@ -1,165 +0,0 @@
GIT
remote: git://github.com/rails/rails.git
revision: 2d8886e05104316273a0f95dfbcd171d3b12678b
branch: 4-0-stable
specs:
actionmailer (4.0.9)
actionpack (= 4.0.9)
mail (~> 2.5, >= 2.5.4)
actionpack (4.0.9)
activesupport (= 4.0.9)
builder (~> 3.1.0)
erubis (~> 2.7.0)
rack (~> 1.5.2)
rack-test (~> 0.6.2)
activemodel (4.0.9)
activesupport (= 4.0.9)
builder (~> 3.1.0)
activerecord (4.0.9)
activemodel (= 4.0.9)
activerecord-deprecated_finders (~> 1.0.2)
activesupport (= 4.0.9)
arel (~> 4.0.0)
activesupport (4.0.9)
i18n (~> 0.6, >= 0.6.9)
minitest (~> 4.2)
multi_json (~> 1.3)
thread_safe (~> 0.1)
tzinfo (~> 0.3.37)
rails (4.0.9)
actionmailer (= 4.0.9)
actionpack (= 4.0.9)
activerecord (= 4.0.9)
activesupport (= 4.0.9)
bundler (>= 1.3.0, < 2.0)
railties (= 4.0.9)
sprockets-rails (~> 2.0)
railties (4.0.9)
actionpack (= 4.0.9)
activesupport (= 4.0.9)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
PATH
remote: ..
specs:
devise (3.4.0)
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.7)
bson (2.3.0)
builder (3.1.4)
connection_pool (2.0.0)
erubis (2.7.0)
faraday (0.9.0)
multipart-post (>= 1.2, < 3)
hashie (3.2.0)
hike (1.2.3)
i18n (0.6.11)
json (1.8.1)
jwt (1.0.0)
mail (2.6.1)
mime-types (>= 1.16, < 3)
metaclass (0.0.4)
mime-types (2.3)
mini_portile (0.6.0)
minitest (4.7.5)
mocha (1.1.0)
metaclass (~> 0.0.1)
mongoid (4.0.0)
activemodel (~> 4.0)
moped (~> 2.0.0)
origin (~> 2.1)
tzinfo (>= 0.3.37)
moped (2.0.0)
bson (~> 2.2)
connection_pool (~> 2.0)
optionable (~> 0.2.0)
multi_json (1.10.1)
multi_xml (0.5.5)
multipart-post (2.0.0)
nokogiri (1.6.3.1)
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.2)
rack (>= 1.0)
rake (10.3.2)
rdoc (4.1.1)
json (~> 1.4)
responders (1.1.1)
railties (>= 3.2, < 4.2)
ruby-openid (2.5.0)
sprockets (2.12.1)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sprockets-rails (2.1.3)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (~> 2.8)
sqlite3 (1.3.9)
thor (0.19.1)
thread_safe (0.3.4)
tilt (1.4.1)
tzinfo (0.3.41)
warden (1.2.3)
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)

View File

@@ -1,10 +1,10 @@
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 "rails", github: "rails/rails", branch: "4-1-stable"
gem "omniauth", "~> 1.3"
gem "omniauth-oauth2", "~> 1.4"
gem "rdoc"
group :test do
@@ -12,6 +12,7 @@ group :test do
gem "omniauth-openid", "~> 1.0.1"
gem "webrat", "0.7.3", require: false
gem "mocha", "~> 1.1", require: false
gem 'test_after_commit', require: false
end
platforms :jruby do

View File

@@ -1,149 +1,145 @@
GIT
remote: git://github.com/rails/rails.git
revision: 90b70cd453e6b88b2ad484861ad9913f70bd15c9
revision: 41b4d81b4fd14cbf43060c223bea0f461256d099
branch: 4-1-stable
specs:
actionmailer (4.1.5)
actionpack (= 4.1.5)
actionview (= 4.1.5)
actionmailer (4.1.15)
actionpack (= 4.1.15)
actionview (= 4.1.15)
mail (~> 2.5, >= 2.5.4)
actionpack (4.1.5)
actionview (= 4.1.5)
activesupport (= 4.1.5)
actionpack (4.1.15)
actionview (= 4.1.15)
activesupport (= 4.1.15)
rack (~> 1.5.2)
rack-test (~> 0.6.2)
actionview (4.1.5)
activesupport (= 4.1.5)
actionview (4.1.15)
activesupport (= 4.1.15)
builder (~> 3.1)
erubis (~> 2.7.0)
activemodel (4.1.5)
activesupport (= 4.1.5)
activemodel (4.1.15)
activesupport (= 4.1.15)
builder (~> 3.1)
activerecord (4.1.5)
activemodel (= 4.1.5)
activesupport (= 4.1.5)
activerecord (4.1.15)
activemodel (= 4.1.15)
activesupport (= 4.1.15)
arel (~> 5.0.0)
activesupport (4.1.5)
activesupport (4.1.15)
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.5)
actionmailer (= 4.1.5)
actionpack (= 4.1.5)
actionview (= 4.1.5)
activemodel (= 4.1.5)
activerecord (= 4.1.5)
activesupport (= 4.1.5)
rails (4.1.15)
actionmailer (= 4.1.15)
actionpack (= 4.1.15)
actionview (= 4.1.15)
activemodel (= 4.1.15)
activerecord (= 4.1.15)
activesupport (= 4.1.15)
bundler (>= 1.3.0, < 2.0)
railties (= 4.1.5)
railties (= 4.1.15)
sprockets-rails (~> 2.0)
railties (4.1.5)
actionpack (= 4.1.5)
activesupport (= 4.1.5)
railties (4.1.15)
actionpack (= 4.1.15)
activesupport (= 4.1.15)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
PATH
remote: ..
specs:
devise (3.4.0)
devise (4.0.1)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 3.2.6, < 5)
railties (>= 4.1.0, < 5.1)
responders
thread_safe (~> 0.1)
warden (~> 1.2.3)
GEM
remote: https://rubygems.org/
specs:
arel (5.0.1.20140414130214)
bcrypt (3.1.7)
bson (2.3.0)
bcrypt (3.1.11)
bson (3.2.6)
builder (3.2.2)
connection_pool (2.0.0)
concurrent-ruby (1.0.1)
connection_pool (2.2.0)
erubis (2.7.0)
faraday (0.9.0)
faraday (0.9.2)
multipart-post (>= 1.2, < 3)
hashie (3.2.0)
hike (1.2.3)
i18n (0.6.11)
json (1.8.1)
jwt (1.0.0)
mail (2.6.1)
hashie (3.4.3)
i18n (0.7.0)
json (1.8.3)
jwt (1.5.1)
mail (2.6.3)
mime-types (>= 1.16, < 3)
metaclass (0.0.4)
mime-types (2.3)
mini_portile (0.6.0)
minitest (5.4.0)
mime-types (2.99.1)
mini_portile2 (2.0.0)
minitest (5.8.4)
mocha (1.1.0)
metaclass (~> 0.0.1)
mongoid (4.0.0)
mongoid (4.0.2)
activemodel (~> 4.0)
moped (~> 2.0.0)
origin (~> 2.1)
tzinfo (>= 0.3.37)
moped (2.0.0)
bson (~> 2.2)
moped (2.0.7)
bson (~> 3.0)
connection_pool (~> 2.0)
optionable (~> 0.2.0)
multi_json (1.10.1)
multi_json (1.11.2)
multi_xml (0.5.5)
multipart-post (2.0.0)
nokogiri (1.6.3.1)
mini_portile (= 0.6.0)
oauth2 (0.9.4)
nokogiri (1.6.7.2)
mini_portile2 (~> 2.0.0.rc2)
oauth2 (1.1.0)
faraday (>= 0.8, < 0.10)
jwt (~> 1.0)
jwt (~> 1.0, < 1.5.2)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (~> 1.2)
omniauth (1.2.2)
rack (>= 1.2, < 3)
omniauth (1.3.1)
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 (3.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.2.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.2)
rack-test (0.6.3)
rack (>= 1.0)
rake (10.3.2)
rdoc (4.1.1)
rake (11.0.1)
rdoc (4.2.2)
json (~> 1.4)
responders (1.1.1)
responders (1.1.2)
railties (>= 3.2, < 4.2)
ruby-openid (2.5.0)
sprockets (2.12.1)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sprockets-rails (2.1.3)
ruby-openid (2.7.0)
sprockets (3.5.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (2.3.3)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (~> 2.8)
sqlite3 (1.3.9)
sprockets (>= 2.8, < 4.0)
sqlite3 (1.3.11)
test_after_commit (1.0.0)
activerecord (>= 3.2)
thor (0.19.1)
thread_safe (0.3.4)
tilt (1.4.1)
thread_safe (0.3.5)
tzinfo (1.2.2)
thread_safe (~> 0.1)
warden (1.2.3)
warden (1.2.6)
rack (>= 1.0)
webrat (0.7.3)
nokogiri (>= 1.2.0)
@@ -160,11 +156,15 @@ DEPENDENCIES
jruby-openssl
mocha (~> 1.1)
mongoid (~> 4.0.0)
omniauth (~> 1.2.0)
omniauth (~> 1.3)
omniauth-facebook
omniauth-oauth2 (~> 1.1.0)
omniauth-oauth2 (~> 1.4)
omniauth-openid (~> 1.0.1)
rails!
rdoc
sqlite3
test_after_commit
webrat (= 0.7.3)
BUNDLED WITH
1.11.2

View File

@@ -1,10 +1,10 @@
source "https://rubygems.org"
gemspec path: '..'
gemspec path: ".."
gem "rails", github: 'rails/rails', branch: '4-0-stable'
gem "omniauth", "~> 1.2.0"
gem "omniauth-oauth2", "~> 1.1.0"
gem "rails", github: "rails/rails", branch: "4-2-stable"
gem "omniauth", "~> 1.3"
gem "omniauth-oauth2", "~> 1.4"
gem "rdoc"
group :test do
@@ -12,6 +12,7 @@ group :test do
gem "omniauth-openid", "~> 1.0.1"
gem "webrat", "0.7.3", require: false
gem "mocha", "~> 1.1", require: false
gem 'test_after_commit', require: false
end
platforms :jruby do

View File

@@ -0,0 +1,192 @@
GIT
remote: git://github.com/rails/rails.git
revision: 2aa27582c202148296bb169159b0bf9a47a7bd80
branch: 4-2-stable
specs:
actionmailer (4.2.6)
actionpack (= 4.2.6)
actionview (= 4.2.6)
activejob (= 4.2.6)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 1.0, >= 1.0.5)
actionpack (4.2.6)
actionview (= 4.2.6)
activesupport (= 4.2.6)
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.6)
activesupport (= 4.2.6)
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.6)
activesupport (= 4.2.6)
globalid (>= 0.3.0)
activemodel (4.2.6)
activesupport (= 4.2.6)
builder (~> 3.1)
activerecord (4.2.6)
activemodel (= 4.2.6)
activesupport (= 4.2.6)
arel (~> 6.0)
activesupport (4.2.6)
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.6)
actionmailer (= 4.2.6)
actionpack (= 4.2.6)
actionview (= 4.2.6)
activejob (= 4.2.6)
activemodel (= 4.2.6)
activerecord (= 4.2.6)
activesupport (= 4.2.6)
bundler (>= 1.3.0, < 2.0)
railties (= 4.2.6)
sprockets-rails
railties (4.2.6)
actionpack (= 4.2.6)
activesupport (= 4.2.6)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
PATH
remote: ..
specs:
devise (4.0.1)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0, < 5.1)
responders
warden (~> 1.2.3)
GEM
remote: https://rubygems.org/
specs:
arel (6.0.3)
bcrypt (3.1.11)
bson (3.2.6)
builder (3.2.2)
concurrent-ruby (1.0.1)
connection_pool (2.2.0)
erubis (2.7.0)
faraday (0.9.2)
multipart-post (>= 1.2, < 3)
globalid (0.3.6)
activesupport (>= 4.1.0)
hashie (3.4.3)
i18n (0.7.0)
json (1.8.3)
jwt (1.5.1)
loofah (2.0.3)
nokogiri (>= 1.5.9)
mail (2.6.3)
mime-types (>= 1.16, < 3)
metaclass (0.0.4)
mime-types (2.99.1)
mini_portile2 (2.0.0)
minitest (5.8.4)
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.7)
bson (~> 3.0)
connection_pool (~> 2.0)
optionable (~> 0.2.0)
multi_json (1.11.2)
multi_xml (0.5.5)
multipart-post (2.0.0)
nokogiri (1.6.7.2)
mini_portile2 (~> 2.0.0.rc2)
oauth2 (1.1.0)
faraday (>= 0.8, < 0.10)
jwt (~> 1.0, < 1.5.2)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
omniauth (1.3.1)
hashie (>= 1.2, < 4)
rack (>= 1.0, < 3)
omniauth-facebook (3.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.2.0)
orm_adapter (0.5.0)
rack (1.6.4)
rack-openid (1.3.1)
rack (>= 1.1.0)
ruby-openid (>= 2.1.8)
rack-test (0.6.3)
rack (>= 1.0)
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.7)
activesupport (>= 4.2.0.beta, < 5.0)
nokogiri (~> 1.6.0)
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
rake (11.0.1)
rdoc (4.2.2)
json (~> 1.4)
responders (2.1.2)
railties (>= 4.2.0, < 5.1)
ruby-openid (2.7.0)
sprockets (3.5.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.0.4)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.3.11)
test_after_commit (1.0.0)
activerecord (>= 3.2)
thor (0.19.1)
thread_safe (0.3.5)
tzinfo (1.2.2)
thread_safe (~> 0.1)
warden (1.2.6)
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.3)
omniauth-facebook
omniauth-oauth2 (~> 1.4)
omniauth-openid (~> 1.0.1)
rails!
rdoc
sqlite3
test_after_commit
webrat (= 0.7.3)
BUNDLED WITH
1.11.2

View File

@@ -1,12 +1,19 @@
source "https://rubygems.org"
gemspec path: '..'
gemspec path: ".."
gem "rails", github: 'rails/rails', branch: '3-2-stable'
gem "omniauth", "~> 1.2.0"
gem "omniauth-oauth2", "~> 1.1.0"
gem "rails", "5.0.0.beta3"
gem "omniauth", " ~>1.3"
gem "oauth2"
gem "omniauth-oauth2", ">= 1.2.0", "< 1.5.0"
gem "rdoc"
gem "activemodel-serializers-xml", github: "rails/activemodel-serializers-xml"
gem "rails-controller-testing"
gem "responders", "~> 2.1.1"
group :test do
gem "omniauth-facebook"
gem "omniauth-openid", "~> 1.0.1"
@@ -24,6 +31,7 @@ platforms :ruby do
gem "sqlite3"
end
group :mongoid do
gem "mongoid", "~> 3.0"
end
# TODO:
# group :mongoid do
# gem "mongoid", "~> 4.0.0"
# end

View File

@@ -0,0 +1,199 @@
GIT
remote: git://github.com/rails/activemodel-serializers-xml.git
revision: f380ea5ddefcb9a37f4fbc47606ed6fbecdb2b2a
specs:
activemodel-serializers-xml (1.0.0)
activemodel (> 5.x)
activerecord (> 5.x)
activesupport (> 5.x)
builder (~> 3.1)
PATH
remote: ..
specs:
devise (4.0.0.rc2)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0, < 5.1)
responders
warden (~> 1.2.3)
GEM
remote: https://rubygems.org/
specs:
actioncable (5.0.0.beta3)
actionpack (= 5.0.0.beta3)
nio4r (~> 1.2)
websocket-driver (~> 0.6.1)
actionmailer (5.0.0.beta3)
actionpack (= 5.0.0.beta3)
actionview (= 5.0.0.beta3)
activejob (= 5.0.0.beta3)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 1.0, >= 1.0.5)
actionpack (5.0.0.beta3)
actionview (= 5.0.0.beta3)
activesupport (= 5.0.0.beta3)
rack (~> 2.x)
rack-test (~> 0.6.3)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.0.0.beta3)
activesupport (= 5.0.0.beta3)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
activejob (5.0.0.beta3)
activesupport (= 5.0.0.beta3)
globalid (>= 0.3.6)
activemodel (5.0.0.beta3)
activesupport (= 5.0.0.beta3)
activerecord (5.0.0.beta3)
activemodel (= 5.0.0.beta3)
activesupport (= 5.0.0.beta3)
arel (~> 7.0)
activesupport (5.0.0.beta3)
concurrent-ruby (~> 1.0)
i18n (~> 0.7)
minitest (~> 5.1)
tzinfo (~> 1.1)
arel (7.0.0)
bcrypt (3.1.11)
builder (3.2.2)
concurrent-ruby (1.0.1)
erubis (2.7.0)
faraday (0.9.2)
multipart-post (>= 1.2, < 3)
globalid (0.3.6)
activesupport (>= 4.1.0)
hashie (3.4.3)
i18n (0.7.0)
json (1.8.3)
jwt (1.5.1)
loofah (2.0.3)
nokogiri (>= 1.5.9)
mail (2.6.4)
mime-types (>= 1.16, < 4)
metaclass (0.0.4)
method_source (0.8.2)
mime-types (3.0)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0221)
mini_portile2 (2.0.0)
minitest (5.8.4)
mocha (1.1.0)
metaclass (~> 0.0.1)
multi_json (1.11.2)
multi_xml (0.5.5)
multipart-post (2.0.0)
nio4r (1.2.1)
nokogiri (1.6.7.2)
mini_portile2 (~> 2.0.0.rc2)
oauth2 (1.1.0)
faraday (>= 0.8, < 0.10)
jwt (~> 1.0, < 1.5.2)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
omniauth (1.3.1)
hashie (>= 1.2, < 4)
rack (>= 1.0, < 3)
omniauth-facebook (3.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.0.alpha)
json
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.0.beta3)
actioncable (= 5.0.0.beta3)
actionmailer (= 5.0.0.beta3)
actionpack (= 5.0.0.beta3)
actionview (= 5.0.0.beta3)
activejob (= 5.0.0.beta3)
activemodel (= 5.0.0.beta3)
activerecord (= 5.0.0.beta3)
activesupport (= 5.0.0.beta3)
bundler (>= 1.3.0, < 2.0)
railties (= 5.0.0.beta3)
sprockets-rails (>= 2.0.0)
rails-controller-testing (0.1.1)
actionpack (~> 5.x)
actionview (~> 5.x)
activesupport (~> 5.x)
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.7)
activesupport (>= 4.2.0.beta, < 5.0)
nokogiri (~> 1.6.0)
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
railties (5.0.0.beta3)
actionpack (= 5.0.0.beta3)
activesupport (= 5.0.0.beta3)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (11.1.2)
rdoc (4.2.2)
json (~> 1.4)
responders (2.1.2)
railties (>= 4.2.0, < 5.1)
ruby-openid (2.7.0)
sprockets (3.6.0)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.0.4)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.3.11)
thor (0.19.1)
thread_safe (0.3.5)
tzinfo (1.2.2)
thread_safe (~> 0.1)
warden (1.2.6)
rack (>= 1.0)
webrat (0.7.3)
nokogiri (>= 1.2.0)
rack (>= 1.0)
rack-test (>= 0.5.3)
websocket-driver (0.6.3)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2)
PLATFORMS
ruby
DEPENDENCIES
activemodel-serializers-xml!
activerecord-jdbc-adapter
activerecord-jdbcsqlite3-adapter
devise!
jruby-openssl
mocha (~> 1.1)
oauth2
omniauth (~> 1.3)
omniauth-facebook
omniauth-oauth2 (>= 1.2.0, < 1.5.0)
omniauth-openid (~> 1.0.1)
rails (= 5.0.0.beta3)
rails-controller-testing
rdoc
responders (~> 2.1.1)
sqlite3
webrat (= 0.7.3)
BUNDLED WITH
1.11.2

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

@@ -8,22 +8,22 @@ require 'responders'
module Devise
autoload :Delegator, 'devise/delegator'
autoload :Encryptor, 'devise/encryptor'
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'
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
@@ -35,7 +35,7 @@ module Devise
end
module Strategies
autoload :Base, 'devise/strategies/base'
autoload :Base, 'devise/strategies/base'
autoload :Authenticatable, 'devise/strategies/authenticatable'
end
@@ -57,29 +57,13 @@ module Devise
mattr_accessor :secret_key
@@secret_key = nil
[ :allow_insecure_token_lookup,
:allow_insecure_sign_in_after_confirmation,
:token_authentication_key ].each do |method|
class_eval <<-RUBY
def self.#{method}
ActiveSupport::Deprecation.warn "Devise.#{method} is deprecated " \
"and has no effect"
end
def self.#{method}=(val)
ActiveSupport::Deprecation.warn "Devise.#{method}= is deprecated " \
"and has no effect"
end
RUBY
end
# Custom domain or key for cookies. Not set by default
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 = 11
# The default key used when authenticating over http auth.
mattr_accessor :http_authentication_key
@@ -87,7 +71,7 @@ module Devise
# Keys used when authenticating a user.
mattr_accessor :authentication_keys
@@authentication_keys = [ :email ]
@@authentication_keys = [:email]
# Request keys used when authenticating a user.
mattr_accessor :request_keys
@@ -95,11 +79,11 @@ module Devise
# Keys that should be case-insensitive.
mattr_accessor :case_insensitive_keys
@@case_insensitive_keys = [ :email ]
@@case_insensitive_keys = [:email]
# 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
@@ -117,11 +101,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]+\.)+[^@\s]+\z/
@@email_regexp = /\A[^@\s]+@[^@\s]+\z/
# Range validation for password length
mattr_accessor :password_length
@@ -150,25 +134,24 @@ module Devise
# Defines which key will be used when confirming an account.
mattr_accessor :confirmation_keys
@@confirmation_keys = [ :email ]
@@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
# Authentication token expiration on timeout
mattr_accessor :expire_auth_token_on_timeout
@@expire_auth_token_on_timeout = false
# Used to encrypt password. Please generate one with rake secret.
# Used to hash the password. Please generate one with rake secret.
mattr_accessor :pepper
@@pepper = nil
# Used to enable sending notification to user when their password is changed
mattr_accessor :send_password_change_notification
@@send_password_change_notification = false
# Scoped views. Since it relies on fallbacks to render default views, it's
# turned off by default.
mattr_accessor :scoped_views
@@ -181,7 +164,7 @@ module Devise
# Defines which key will be used when locking and unlocking an account
mattr_accessor :unlock_keys
@@unlock_keys = [ :email ]
@@unlock_keys = [:email]
# Defines which strategy can be used to unlock an account.
# Values: :email, :time, :both
@@ -198,12 +181,16 @@ module Devise
# Defines which key will be used when recovering the password for an account
mattr_accessor :reset_password_keys
@@reset_password_keys = [ :email ]
@@reset_password_keys = [:email]
# Time interval you can reset your password with a reset password key
mattr_accessor :reset_password_within
@@reset_password_within = 6.hours
# When set to false, resetting a password does not automatically sign in a user
mattr_accessor :sign_in_after_reset_password
@@sign_in_after_reset_password = true
# The default scope which is used by warden.
mattr_accessor :default_scope
@@default_scope = nil
@@ -214,7 +201,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
@@ -226,7 +213,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
@@ -246,7 +233,7 @@ module Devise
mattr_accessor :router_name
@@router_name = nil
# Set the omniauth path prefix so it can be overridden when
# Set the OmniAuth path prefix so it can be overridden when
# Devise is used in a mountable engine
mattr_accessor :omniauth_path_prefix
@@omniauth_path_prefix = nil
@@ -261,7 +248,7 @@ module Devise
mattr_reader :mappings
@@mappings = ActiveSupport::OrderedHash.new
# Omniauth configurations.
# OmniAuth configurations.
mattr_reader :omniauth_configs
@@omniauth_configs = ActiveSupport::OrderedHash.new
@@ -287,7 +274,7 @@ module Devise
mattr_accessor :token_generator
@@token_generator = nil
# Default way to setup Devise. Run rails generate devise_install to create
# 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
@@ -340,7 +327,12 @@ module Devise
mapping
end
# Make Devise aware of an 3rd party Devise-module (like invitable). For convenience.
# Register available devise modules. For the standard modules that Devise provides, this method is
# called from lib/devise/modules.rb. Third-party modules need to be added explicitly using this method.
#
# Note that adding a module using this method does not cause it to be used in the authentication
# process. That requires that the module be listed in the arguments passed to the 'devise' method
# in the model class definition.
#
# == Options:
#
@@ -348,6 +340,7 @@ module Devise
# +controller+ - Symbol representing the name of an existing or custom *controller* for this module.
# +route+ - Symbol representing the named *route* helper for this module.
# +strategy+ - Symbol representing if this module got a custom *strategy*.
# +insert_at+ - Integer representing the order in which this module's model will be included
#
# All values, except :model, accept also a boolean and will have the same name as the given module
# name.
@@ -357,10 +350,12 @@ module Devise
# Devise.add_module(:party_module)
# Devise.add_module(:party_module, strategy: true, controller: :sessions)
# Devise.add_module(:party_module, model: 'party_module/model')
# Devise.add_module(:party_module, insert_at: 0)
#
def self.add_module(module_name, options = {})
ALL << module_name
options.assert_valid_keys(:strategy, :model, :controller, :route, :no_input)
options.assert_valid_keys(:strategy, :model, :controller, :route, :no_input, :insert_at)
ALL.insert (options[:insert_at] || -1), module_name
if strategy = options[:strategy]
strategy = (strategy == true ? module_name : strategy)
@@ -417,7 +412,7 @@ module Devise
@@warden_config_blocks << block
end
# Specify an omniauth provider.
# Specify an OmniAuth provider.
#
# config.omniauth :github, APP_ID, APP_SECRET
#
@@ -445,8 +440,8 @@ module Devise
Devise::Controllers::UrlHelpers.generate_helpers!
end
# A method used internally to setup warden manager from the Rails initialize
# block.
# A method used internally to complete the setup of warden manager after routes are loaded.
# See lib/devise/rails/routes.rb - ActionDispatch::Routing::RouteSet#finalize_with_devise!
def self.configure_warden! #:nodoc:
@@warden_configured ||= begin
warden_config.failure_app = Devise::Delegator.new
@@ -460,10 +455,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
@@ -474,8 +466,12 @@ module Devise
end
# Generate a friendly string randomly to be used as token.
def self.friendly_token
SecureRandom.urlsafe_base64(15).tr('lIO0', 'sxyz')
# By default, length is 20 characters.
def self.friendly_token(length = 20)
# To calculate real characters, we must perform this operation.
# See SecureRandom.urlsafe_base64
rlength = (length * 3) / 4
SecureRandom.urlsafe_base64(rlength).tr('lIO0', 'sxyz')
end
# constant-time comparison algorithm to prevent timing attacks

View File

@@ -7,7 +7,9 @@ module Devise
include Devise::Controllers::StoreLocation
included do
helper_method :warden, :signed_in?, :devise_controller?
if respond_to?(:helper_method)
helper_method :warden, :signed_in?, :devise_controller?
end
end
module ClassMethods
@@ -28,8 +30,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={})
@@ -69,7 +71,9 @@ module Devise
end.compact
end
helper_method "current_#{group_name}", "current_#{group_name.to_s.pluralize}", "#{group_name}_signed_in?"
if respond_to?(:helper_method)
helper_method "current_#{group_name}", "current_#{group_name.to_s.pluralize}", "#{group_name}_signed_in?"
end
METHODS
end
@@ -80,7 +84,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:
@@ -100,8 +104,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
@@ -126,7 +130,9 @@ module Devise
METHODS
ActiveSupport.on_load(:action_controller) do
helper_method "current_#{mapping}", "#{mapping}_signed_in?", "#{mapping}_session"
if respond_to?(:helper_method)
helper_method "current_#{mapping}", "#{mapping}_signed_in?", "#{mapping}_session"
end
end
end
@@ -139,20 +145,16 @@ module Devise
# 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.
@@ -190,10 +192,10 @@ module Devise
# root path. For a user scope, you can define the default url in
# the following way:
#
# map.user_root '/users', controller: 'users' # creates user_root_path
# get '/users' => 'users#index', as: :user_root # creates user_root_path
#
# map.namespace :user do |user|
# user.root controller: 'users' # creates user_root_path
# namespace :user do
# root 'users#index' # creates user_root_path
# end
#
# If the resource root path is not defined, root_path is used. However,
@@ -269,12 +271,6 @@ module Devise
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

View File

@@ -2,18 +2,25 @@ module Devise
module Controllers
# A module that may be optionally included in a controller in order
# to provide remember me behavior. Useful when signing in is done
# through a callback, like in Omniauth.
# through a callback, like in OmniAuth.
module Rememberable
# Return default cookie values retrieved from session options.
def self.cookie_values
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"]
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

@@ -6,7 +6,7 @@ module Devise
# Return true if the given scope is signed in session. If no scope given, return
# true if any scope is signed in. Does not run authentication hooks.
def signed_in?(scope=nil)
[ scope || Devise.mappings.keys ].flatten.any? do |_scope|
[scope || Devise.mappings.keys].flatten.any? do |_scope|
warden.authenticate?(scope: _scope)
end
end
@@ -90,13 +90,7 @@ module Devise
session.keys.grep(/^devise\./).each { |k| session.delete(k) }
end
def expire_data_after_sign_out!
# session.keys will return an empty array if the session is not yet loaded.
# This is a bug in both Rack and Rails.
# A call to #empty? forces the session to be loaded.
session.empty?
session.keys.grep(/^devise\./).each { |k| session.delete(k) }
end
alias :expire_data_after_sign_out! :expire_data_after_sign_in!
end
end
end

View File

@@ -35,7 +35,9 @@ module Devise
session_key = stored_location_key_for(resource_or_scope)
uri = parse_uri(location)
if uri
session[session_key] = [uri.path.sub(/\A\/+/, '/'), uri.query].compact.join('?')
path = [uri.path.sub(/\A\/+/, '/'), uri.query].compact.join('?')
path = [path, uri.fragment].compact.join('#')
session[session_key] = path
end
end

View File

@@ -42,16 +42,14 @@ module Devise
[:path, :url].each do |path_or_url|
actions.each do |action|
action = action ? "#{action}_" : ""
method = "#{action}#{module_name}_#{path_or_url}"
method = :"#{action}#{module_name}_#{path_or_url}"
class_eval <<-URL_HELPERS, __FILE__, __LINE__ + 1
def #{method}(resource_or_scope, *args)
scope = Devise::Mapping.find_scope!(resource_or_scope)
router_name = Devise.mappings[scope].router_name
context = router_name ? send(router_name) : _devise_route_context
context.send("#{action}\#{scope}_#{module_name}_#{path_or_url}", *args)
end
URL_HELPERS
define_method method do |resource_or_scope, *args|
scope = Devise::Mapping.find_scope!(resource_or_scope)
router_name = Devise.mappings[scope].router_name
context = router_name ? send(router_name) : _devise_route_context
context.send("#{action}#{scope}_#{module_name}_#{path_or_url}", *args)
end
end
end
end

22
lib/devise/encryptor.rb Normal file
View File

@@ -0,0 +1,22 @@
require 'bcrypt'
module Devise
module Encryptor
def self.digest(klass, password)
if klass.pepper.present?
password = "#{password}#{klass.pepper}"
end
::BCrypt::Password.create(password, cost: klass.stretches).to_s
end
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, hashed_password)
end
end
end

View File

@@ -6,7 +6,6 @@ module Devise
# page based on current scope and mapping. If no scope is given, redirect
# to the default_url.
class FailureApp < ActionController::Metal
include ActionController::RackDelegation
include ActionController::UrlFor
include ActionController::Redirecting
@@ -22,9 +21,12 @@ module Devise
@respond.call(env)
end
# 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)
if defined?(ApplicationController)
ApplicationController.default_url_options(*args)
if defined?(Devise.parent_controller.constantize)
Devise.parent_controller.constantize.try(:default_url_options) || {}
else
{}
end
@@ -48,18 +50,40 @@ module Devise
end
def recall
env["PATH_INFO"] = attempted_path
flash.now[:alert] = i18n_message(:invalid)
self.response = recall_app(warden_options[:recall]).call(env)
config = Rails.application.config
header_info = if config.try(:relative_url_root)
base_path = Pathname.new(config.relative_url_root)
full_path = Pathname.new(attempted_path)
{ "SCRIPT_NAME" => config.relative_url_root,
"PATH_INFO" => '/' + full_path.relative_path_from(base_path).to_s }
else
{ "PATH_INFO" => attempted_path }
end
header_info.each do | var, value|
if request.respond_to?(:set_header)
request.set_header(var, value)
else
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(request.env)
end
def redirect
store_location!
if flash[:timedout] && flash[:alert]
flash.keep(:timedout)
flash.keep(:alert)
else
flash[:alert] = i18n_message
if is_flashing_format?
if flash[:timedout] && flash[:alert]
flash.keep(:timedout)
flash.keep(:alert)
else
flash[:alert] = i18n_message
end
end
redirect_to redirect_url
end
@@ -78,7 +102,9 @@ module Devise
options[:resource_name] = scope
options[:scope] = "devise.failure"
options[:default] = [message]
options[:authentication_keys] = scope_class.authentication_keys.join(I18n.translate(:"support.array.words_connector"))
auth_keys = scope_class.authentication_keys
keys = (auth_keys.respond_to?(:keys) ? auth_keys.keys : auth_keys).map { |key| scope_class.human_attribute_name(key) }
options[:authentication_keys] = keys.join(I18n.translate(:"support.array.words_connector"))
options = i18n_options(options)
I18n.t(:"#{scope}.#{message}", options)
@@ -89,7 +115,7 @@ module Devise
def redirect_url
if warden_message == :timeout
flash[:timedout] = true
flash[:timedout] = true if is_flashing_format?
path = if request.get?
attempted_path
@@ -103,15 +129,27 @@ module Devise
end
end
def route(scope)
:"new_#{scope}_session_url"
end
def scope_url
opts = {}
route = :"new_#{scope}_session_url"
route = route(scope)
opts[:format] = request_format unless skip_format?
config = Rails.application.config
opts[:script_name] = (config.relative_url_root if config.respond_to?(:relative_url_root))
context = send(Devise.available_router_name)
if config.respond_to?(:relative_url_root)
# Rails 4.2 goes into an infinite loop if opts[:script_name] is unset
rails_4_2 = (Rails::VERSION::MAJOR >= 4) && (Rails::VERSION::MINOR >= 2)
if config.relative_url_root.present? || rails_4_2
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 context.respond_to?(route)
context.send(route, opts)
@@ -168,11 +206,11 @@ module Devise
end
def warden
env['warden']
request.respond_to?(:get_header) ? request.get_header("warden") : env["warden"]
end
def warden_options
env['warden.options']
request.respond_to?(:get_header) ? request.get_header("warden.options") : env["warden.options"]
end
def warden_message
@@ -203,6 +241,12 @@ module Devise
Devise.navigational_formats.include?(request_format)
end
# Check if flash messages should be emitted. Default is to do it on
# navigational formats
def is_flashing_format?
is_navigational_format?
end
def request_format
@request_format ||= request.format.try(:ref)
end

View File

@@ -7,7 +7,8 @@ Warden::Manager.after_set_user do |record, warden, options|
scope = options[:scope]
env = warden.request.env
if record && record.respond_to?(:timedout?) && warden.authenticated?(scope) && options[:store] != false
if record && record.respond_to?(:timedout?) && warden.authenticated?(scope) &&
options[:store] != false && !env['devise.skip_timeoutable']
last_request_at = warden.session(scope)['last_request_at']
if last_request_at.is_a? Integer
@@ -18,13 +19,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)
if record.respond_to?(:expire_auth_token_on_timeout) && record.expire_auth_token_on_timeout
record.reset_authentication_token!
end
throw :warden, scope: scope, message: :timeout
end

View File

@@ -64,7 +64,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

@@ -31,6 +31,7 @@ module Devise
# Receives an object and find a scope for it. If a scope cannot be found,
# raises an error. If a symbol is given, it's considered to be the scope.
def self.find_scope!(obj)
obj = obj.devise_scope if obj.respond_to?(:devise_scope)
case obj
when String, Symbol
return obj.to_sym

View File

@@ -12,7 +12,7 @@ module Devise
# Creates configuration values for Devise and for the given module.
#
# Devise::Models.config(Devise::Authenticatable, :stretches, 10)
# Devise::Models.config(Devise::DatabaseAuthenticatable, :stretches)
#
# The line above creates:
#

View File

@@ -1,3 +1,4 @@
require 'active_model/version'
require 'devise/hooks/activatable'
require 'devise/hooks/csrf_cleaner'
@@ -37,7 +38,7 @@ module Devise
# calling model.active_for_authentication?. This method is overwritten by other devise modules. For instance,
# :confirmable overwrites .active_for_authentication? to only return true if your model was confirmed.
#
# You overwrite this method yourself, but if you do, don't forget to call super:
# You can overwrite this method yourself, but if you do, don't forget to call super:
#
# def active_for_authentication?
# super && special_condition_is_valid?
@@ -95,29 +96,22 @@ module Devise
def authenticatable_salt
end
array = %w(serializable_hash)
# to_xml does not call serializable_hash on 3.1
array << "to_xml" if Rails::VERSION::STRING[0,3] == "3.1"
# Redefine serializable_hash in models for more secure defaults.
# By default, it removes from the serializable model all attributes that
# are *not* accessible. You can remove this default by using :force_except
# 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[:except] = Array(options[:except])
array.each do |method|
class_eval <<-RUBY, __FILE__, __LINE__
# Redefine to_xml and serializable_hash in models for more secure defaults.
# By default, it removes from the serializable model all attributes that
# are *not* accessible. You can remove this default by using :force_except
# 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 #{method}(options=nil)
options ||= {}
options[:except] = Array(options[:except])
if options[:force_except]
options[:except].concat Array(options[:force_except])
else
options[:except].concat BLACKLIST_FOR_SERIALIZATION
end
if options[:force_except]
options[:except].concat Array(options[:force_except])
else
options[:except].concat BLACKLIST_FOR_SERIALIZATION
end
super(options)
end
RUBY
super(options)
end
protected
@@ -252,14 +246,18 @@ module Devise
to_adapter.find_first(devise_parameter_filter.filter(tainted_conditions).merge(opts))
end
# Find an initialize a record setting an error if it can't be found.
# Find or initialize a record setting an error if it can't be found.
def find_or_initialize_with_error_by(attribute, value, error=:invalid) #:nodoc:
find_or_initialize_with_errors([attribute], { attribute => value }, error)
end
# Find an initialize a group of attributes based on a list of required attributes.
# 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 = if attributes.respond_to? :permit!
attributes.slice(*required_attributes).permit!.to_h.with_indifferent_access
else
attributes.with_indifferent_access.slice(*required_attributes)
end
attributes.delete_if { |key, value| value.blank? }
if attributes.size == required_attributes.size

View File

@@ -5,6 +5,14 @@ module Devise
# Confirmation instructions are sent to the user email after creating a
# record and when manually requested by a new confirmation instruction request.
#
# Confirmable tracks the following columns:
#
# * confirmation_token - A unique random token
# * confirmed_at - A timestamp when the user clicked the confirmation link
# * confirmation_sent_at - A timestamp when the confirmation_token was generated (not sent)
# * unconfirmed_email - An email address copied from the email attr. After confirmation
# this value is copied to the email attr then cleared
#
# == Options
#
# Confirmable adds the following options to +devise+:
@@ -16,27 +24,34 @@ 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.
# * +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
# during this time frame, unless the user's email changed too.
#
# == Examples
#
# User.find(1).confirm! # returns true unless it's already confirmed
# User.find(1).confirm # returns true unless it's already confirmed
# User.find(1).confirmed? # true/false
# User.find(1).send_confirmation_instructions # manually send instructions
#
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!, if: :send_confirmation_notification?
if respond_to?(:after_commit) # 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)
@@ -56,7 +71,7 @@ module Devise
# Confirm a user by setting it's confirmed_at to actual time. If the user
# is already confirmed, add an error to email field. If the user is invalid
# add errors
def confirm!
def confirm(args={})
pending_any_confirmation do
if confirmation_period_expired?
self.errors.add(:email, :confirmation_period_expired,
@@ -64,10 +79,9 @@ module Devise
return false
end
self.confirmation_token = nil
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
@@ -75,7 +89,7 @@ module Devise
# We need to validate in such cases to enforce e-mail uniqueness
save(validate: true)
else
save(validate: false)
save(validate: args[:ensure_valid] == true)
end
after_confirmation if saved
@@ -83,6 +97,11 @@ 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
@@ -166,7 +185,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:
#
@@ -202,7 +221,7 @@ module Devise
# confirmation_period_expired? # will always return false
#
def confirmation_period_expired?
self.class.confirm_within && (Time.now > self.confirmation_sent_at + self.class.confirm_within )
self.class.confirm_within && self.confirmation_sent_at && (Time.now > self.confirmation_sent_at + self.class.confirm_within)
end
# Checks whether the record requires any confirmation.
@@ -216,12 +235,14 @@ module Devise
end
# Generates a new random token for confirmation, and stores
# the time this token is being generated
# the time this token is being generated in confirmation_sent_at
def generate_confirmation_token
raw, enc = Devise.token_generator.generate(self.class, :confirmation_token)
@raw_confirmation_token = raw
self.confirmation_token = enc
self.confirmation_sent_at = Time.now.utc
if self.confirmation_token && !confirmation_period_expired?
@raw_confirmation_token = self.confirmation_token
else
self.confirmation_token = @raw_confirmation_token = Devise.friendly_token
self.confirmation_sent_at = Time.now.utc
end
end
def generate_confirmation_token!
@@ -232,6 +253,7 @@ module Devise
@reconfirmation_required = true
self.unconfirmed_email = self.email
self.email = self.email_was
self.confirmation_token = nil
generate_confirmation_token
end
@@ -242,13 +264,23 @@ module Devise
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
# A callback initiated after successfully confirming. This can be
# used to insert your own logic that is only run after the user successfully
# confirms.
#
# Example:
#
# def after_confirmation
# self.update_attribute(:invite_code, nil)
# end
#
def after_confirmation
end
@@ -271,17 +303,23 @@ 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)
original_token = confirmation_token
confirmation_token = Devise.token_generator.digest(self, :confirmation_token, confirmation_token)
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)
end
confirmable = find_or_initialize_with_error_by(:confirmation_token, confirmation_token)
confirmable.confirm! if confirmable.persisted?
confirmable.confirmation_token = original_token
# TODO: replace above lines with
# confirmable = find_or_initialize_with_error_by(:confirmation_token, confirmation_token)
# after enough time has passed that Devise clients do not use digested tokens
confirmable.confirm if confirmable.persisted?
confirmable
end
# 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,19 +1,18 @@
require 'devise/strategies/database_authenticatable'
require 'bcrypt'
module Devise
# Digests the password using bcrypt.
def self.bcrypt(klass, password)
::BCrypt::Password.create("#{password}#{klass.pepper}", cost: klass.stretches).to_s
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
#
# DatabaseAuthenticable adds the following options to devise_for:
# 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.
@@ -28,6 +27,8 @@ module Devise
extend ActiveSupport::Concern
included do
after_update :send_password_change_notification, if: :send_password_change_notification?
attr_reader :password, :current_password
attr_accessor :password_confirmation
end
@@ -36,18 +37,17 @@ module Devise
[: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?
end
# Verifies whether an password (ie from sign in) is the user password.
# Verifies whether a password (ie from sign in) is the user password.
def valid_password?(password)
return false if encrypted_password.blank?
bcrypt = ::BCrypt::Password.new(encrypted_password)
password = ::BCrypt::Engine.hash_secret("#{password}#{self.class.pepper}", bcrypt.salt)
Devise.secure_compare(password, encrypted_password)
Devise::Encryptor.compare(self.class, encrypted_password, password)
end
# Set password and password confirmation to nil
@@ -137,19 +137,27 @@ module Devise
encrypted_password[0,29] if encrypted_password
end
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.bcrypt(self.class, password)
Devise::Encryptor.digest(self.class, password)
end
def send_password_change_notification?
self.class.send_password_change_notification && encrypted_password_changed?
end
module ClassMethods
Devise::Models.config(self, :pepper, :stretches)
Devise::Models.config(self, :pepper, :stretches, :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

@@ -7,7 +7,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 +64,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
@@ -155,6 +155,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 +184,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

@@ -8,15 +8,13 @@ module Devise
# Recoverable adds the following options to devise_for:
#
# * +reset_password_keys+: the keys you want to use when recovering the password for an account
# * +reset_password_within+: the time period within which the password must be reset or the token expires.
# * +sign_in_after_reset_password+: whether or not to sign in the user automatically after a password reset.
#
# == Examples
#
# # resets the user password and save the record, true if valid passwords are given, otherwise false
# User.find(1).reset_password!('password123', 'password123')
#
# # only resets the user password, without saving the record
# user = User.find(1)
# user.reset_password('password123', 'password123')
# User.find(1).reset_password('password123', 'password123')
#
# # creates a new token and send it with instructions about how to reset the password
# User.find(1).send_reset_password_instructions
@@ -28,20 +26,33 @@ module Devise
[:reset_password_sent_at, :reset_password_token]
end
included do
before_update do
if (respond_to?(:email_changed?) && email_changed?) || encrypted_password_changed?
clear_reset_password_token
end
end
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)
def reset_password(new_password, new_password_confirmation)
self.password = new_password
self.password_confirmation = new_password_confirmation
if valid?
clear_reset_password_token
if respond_to?(:after_password_reset) && valid?
ActiveSupport::Deprecation.warn "after_password_reset is deprecated"
after_password_reset
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.
# Returns the token sent in the e-mail.
def send_reset_password_instructions
@@ -72,7 +83,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
@@ -83,15 +94,12 @@ module Devise
self.reset_password_sent_at = nil
end
def after_password_reset
end
def set_reset_password_token
raw, enc = Devise.token_generator.generate(self.class, :reset_password_token)
self.reset_password_token = enc
self.reset_password_sent_at = Time.now.utc
self.save(validate: false)
save(validate: false)
raw
end
@@ -130,17 +138,17 @@ module Devise
if recoverable.persisted?
if recoverable.reset_password_period_valid?
recoverable.reset_password!(attributes[:password], attributes[:password_confirmation])
recoverable.reset_password(attributes[:password], attributes[:password_confirmation])
else
recoverable.errors.add(:reset_password_token, :expired)
end
end
recoverable.reset_password_token = original_token
recoverable.reset_password_token = original_token if recoverable.reset_password_token.present?
recoverable
end
Devise::Models.config(self, :reset_password_keys, :reset_password_within)
Devise::Models.config(self, :reset_password_keys, :reset_password_within, :sign_in_after_reset_password)
end
end
end

View File

@@ -39,17 +39,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
# unless remember_across_browsers is true and the user already has a valid token.
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,25 +55,23 @@ 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
if respond_to?(:remember_token)
remember_token
elsif respond_to?(:authenticatable_salt) && (salt = authenticatable_salt)
elsif respond_to?(:authenticatable_salt) && (salt = authenticatable_salt.presence)
salt
else
raise "authenticable_salt returned nil for the #{self.class.name} model. " \
@@ -89,29 +85,60 @@ module Devise
self.class.rememberable_options
end
protected
def generate_remember_token? #:nodoc:
respond_to?(:remember_token) && remember_expired?
# A callback initiated after successfully being remembered. This can be
# used to insert your own logic that is only run after the user is
# remembered.
#
# Example:
#
# def after_remembered
# self.update_attribute(:invite_code, nil)
# end
#
def after_remembered
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_created_at.nil? || remember_expired?
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
# 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
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

@@ -26,7 +26,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 +35,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

@@ -30,8 +30,7 @@ module Devise
def update_tracked_fields!(request)
update_tracked_fields(request)
save(validate: false) or raise "Devise trackable could not save #{inspect}." \
"Please make sure a model using trackable can be saved at sign in."
save(validate: false)
end
end
end

View File

@@ -10,12 +10,12 @@ 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..128.
# * +password_length+: a range expressing password length. Defaults to 8..72.
#
module Validatable
# All validations used by this module.
VALIDATIONS = [ :validates_presence_of, :validates_uniqueness_of, :validates_format_of,
:validates_confirmation_of, :validates_length_of ].freeze
VALIDATIONS = [:validates_presence_of, :validates_uniqueness_of, :validates_format_of,
:validates_confirmation_of, :validates_length_of].freeze
def self.required_fields(klass)
[]

View File

@@ -2,16 +2,74 @@ module Devise
module OmniAuth
module UrlHelpers
def self.define_helpers(mapping)
return unless mapping.omniauthable?
mapping = mapping.name
class_eval do
define_method("#{mapping}_omniauth_authorize_path") do |provider, *args|
ActiveSupport::Deprecation.warn(<<-DEPRECATION.strip_heredoc)
[Devise] #{mapping}_omniauth_authorize_path(#{provider.inspect}) is deprecated and it will be removed from Devise 4.2.
Please use #{mapping}_#{provider}_omniauth_authorize_path instead.
DEPRECATION
send("#{mapping}_#{provider}_omniauth_authorize_path", *args)
end
define_method("#{mapping}_omniauth_authorize_url") do |provider, *args|
ActiveSupport::Deprecation.warn(<<-DEPRECATION.strip_heredoc)
[Devise] #{mapping}_omniauth_authorize_url(#{provider.inspect}) is deprecated and it will be removed from Devise 4.2.
Please use #{mapping}_#{provider}_omniauth_authorize_url instead.
DEPRECATION
send("#{mapping}_#{provider}_omniauth_authorize_url", *args)
end
define_method("#{mapping}_omniauth_callback_path") do |provider, *args|
ActiveSupport::Deprecation.warn(<<-DEPRECATION.strip_heredoc)
[Devise] #{mapping}_omniauth_callback_path(#{provider.inspect}) is deprecated and it will be removed from Devise 4.2.
Please use #{mapping}_#{provider}_omniauth_callback_path instead.
DEPRECATION
send("#{mapping}_#{provider}_omniauth_callback_path", *args)
end
define_method("#{mapping}_omniauth_callback_url") do |provider, *args|
ActiveSupport::Deprecation.warn(<<-DEPRECATION.strip_heredoc)
[Devise] #{mapping}_omniauth_callback_url(#{provider.inspect}) is deprecated and it will be removed from Devise 4.2.
Please use #{mapping}_#{provider}_omniauth_callback_url instead.
DEPRECATION
send("#{mapping}_#{provider}_omniauth_callback_url", *args)
end
end
ActiveSupport.on_load(:action_controller) do
if respond_to?(:helper_method)
helper_method "#{mapping}_omniauth_authorize_path", "#{mapping}_omniauth_authorize_url"
helper_method "#{mapping}_omniauth_callback_path", "#{mapping}_omniauth_callback_url"
end
end
end
def omniauth_authorize_path(resource_or_scope, *args)
def omniauth_authorize_path(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_path", *args)
end
def omniauth_callback_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_callback_path", *args)
_devise_route_context.send("#{scope}_#{provider}_omniauth_authorize_url", *args)
end
def omniauth_callback_path(resource_or_scope, provider, *args)
scope = Devise::Mapping.find_scope!(resource_or_scope)
_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,99 +1,214 @@
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]
# DEPRECATED: Remove this branch on Devise 4.2.
if respond_to?(action, true)
deprecate_instance_method_sanitization(action)
return cast_to_hash send(action)
end
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
# DEPRECATED: Remove this method on Devise 4.2.
def for(action, &block) # :nodoc:
if block_given?
deprecate_for_with_block(action)
permit(action, &block)
else
deprecate_for_without_block(action)
@permitted[action] or unknown_action!(action)
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) }
@params.fetch(@resource_name, {})
end
def sign_in
permit self.for(:sign_in)
def permit_keys(parameters, keys)
parameters.permit(*keys)
end
def sign_up
permit self.for(:sign_up)
def extract_auth_keys(klass)
auth_keys = klass.authentication_keys
auth_keys.respond_to?(:keys) ? auth_keys.keys : auth_keys
end
def account_update
permit self.for(:account_update)
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
private
def deprecate_for_with_block(action)
ActiveSupport::Deprecation.warn(<<-MESSAGE.strip_heredoc)
[Devise] Changing the sanitized parameters through "#{self.class.name}#for(#{action}) is deprecated and it will be removed from Devise 4.2.
Please use the `permit` method:
# 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))
devise_parameter_sanitizer.permit(:#{action}) do |user|
# Your block here.
end
MESSAGE
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}")
def deprecate_for_without_block(action)
ActiveSupport::Deprecation.warn(<<-MESSAGE.strip_heredoc)
[Devise] Changing the sanitized parameters through "#{self.class.name}#for(#{action}) is deprecated and it will be removed from Devise 4.2.
Please use the `permit` method to add or remove any key:
To add any new key, use the `keys` keyword argument:
devise_parameter_sanitizer.permit(:#{action}, keys: [:param1, :param2, :param3])
To remove any existing key, use the `except` keyword argument:
devise_parameter_sanitizer.permit(:#{action}, except: [:email])
MESSAGE
end
def default_sanitize(kind)
if respond_to?(kind, true)
send(kind)
else
raise NotImplementedError, "Devise doesn't know how to sanitize parameters for #{kind}"
end
end
def deprecate_instance_method_sanitization(action)
ActiveSupport::Deprecation.warn(<<-MESSAGE.strip_heredoc)
[Devise] Parameter sanitization through a "#{self.class.name}##{action}" method is deprecated and it will be removed from Devise 4.2.
Please use the `permit` method on your sanitizer `initialize` method.
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
end
def auth_keys
@auth_keys ||= @resource_class.authentication_keys.respond_to?(:keys) ?
@resource_class.authentication_keys.keys : @resource_class.authentication_keys
class #{self.class.name} < Devise::ParameterSanitizer
def initialize(*)
super
permit(:#{action}, keys: [:param1, :param2, :param3])
end
end
MESSAGE
end
end
end

View File

@@ -17,7 +17,7 @@ module Devise
Devise.include_helpers(Devise::Controllers)
end
initializer "devise.omniauth" do |app|
initializer "devise.omniauth", after: :load_config_initializers, before: :build_middleware_stack do |app|
Devise.omniauth_configs.each do |provider, config|
app.middleware.use config.strategy_class, *config.args do |strategy|
config.strategy = strategy
@@ -39,18 +39,9 @@ module Devise
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,10 @@
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 +18,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,20 +87,34 @@ 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 instance variable
# name in controller, as the name in routes and the scope given to warden.
# * 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.
#
# devise_for :users, singular: :user
# devise_for :admins, singular: :manager
#
# devise_scope :manager do
# ...
# end
#
# class ManagerController < ApplicationController
# before_action authenticate_manager!
#
# def show
# @manager = current_manager
# ...
# end
# end
#
# * path_names: configure different path names to overwrite defaults :sign_in, :sign_out, :sign_up,
# :password, :confirmation, :unlock.
@@ -119,7 +136,7 @@ module ActionDispatch::Routing
# * sign_out_via: the HTTP method(s) accepted for the :sign_out action (default: :get),
# 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: [:post, :delete]
#
# You need to make sure that your sign_out controls trigger a request with a matching HTTP method.
#
@@ -402,44 +419,41 @@ module ActionDispatch::Routing
def devise_omniauth_callback(mapping, controllers) #:nodoc:
if mapping.fullpath =~ /:[a-zA-Z_]/
raise <<-ERROR
Devise does not support scoping omniauth callbacks under a dynamic segment
Devise does not support scoping OmniAuth callbacks under a dynamic segment
and you have set #{mapping.fullpath.inspect}. You can work around by passing
`skip: :omniauth_callbacks` and manually defining the routes. Here is an example:
`skip: :omniauth_callbacks` to the `devise_for` call and extract omniauth
options to another `devise_for` call outside the scope. Here is an example:
match "/users/auth/:provider",
constraints: { provider: /google|facebook/ },
to: "devise/omniauth_callbacks#passthru",
as: :omniauth_authorize,
via: [:get, :post]
devise_for :users, only: :omniauth_callbacks, controllers: {omniauth_callbacks: 'users/omniauth_callbacks'}
match "/users/auth/:action/callback",
constraints: { action: /google|facebook/ },
to: "devise/omniauth_callbacks",
as: :omniauth_callback,
via: [:get, :post]
scope '/(:locale)', locale: /ru|en/ do
devise_for :users, skip: :omniauth_callbacks
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:
@@ -448,7 +462,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

@@ -3,17 +3,8 @@ module Warden::Mixins::Common
@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

@@ -27,7 +27,7 @@ module Devise
# 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
# given as parameter. Check Devise::Models::Authenticable.valid_for_authentication?
# given as parameter. Check Devise::Models::Authenticatable.valid_for_authentication?
# for more information.
#
# In case the resource can't be validated, it will fail with the given
@@ -57,7 +57,7 @@ module Devise
# Check if this is a valid strategy for http authentication by:
#
# * Validating if the model allows params authentication;
# * Validating if the model allows http authentication;
# * If any of the authorization headers were sent;
# * If all authentication keys are present;
#
@@ -108,14 +108,17 @@ module Devise
params_auth_hash.is_a?(Hash)
end
# Check if password is present.
# Note: unlike `Model.valid_password?`, this method does not actually
# ensure that the password in the params matches the password stored in
# the database. It only checks if the password is *present*. Do not rely
# on this method for validating that a given password is correct.
def valid_password?
password.present?
end
# Helper to decode credentials from HTTP.
def decode_credentials
return [] unless request.authorization && request.authorization =~ /^Basic (.*)/m
return [] unless request.authorization && request.authorization =~ /^Basic (.*)/mi
Base64.decode64($1).split(/:/, 2)
end

View File

@@ -5,16 +5,16 @@ module Devise
# Default strategy for signing in a user, based on their email and password in the database.
class DatabaseAuthenticatable < Authenticatable
def authenticate!
resource = valid_password? && mapping.to.find_for_database_authentication(authentication_hash)
encrypted = false
resource = password.present? && mapping.to.find_for_database_authentication(authentication_hash)
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
mapping.to.new.password = password if !hashed && Devise.paranoid
fail(:not_found_in_database) unless resource
end
end

View File

@@ -25,18 +25,25 @@ 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
end
# No need to clean up the CSRF when using rememberable.
# In fact, cleaning it up here would be a bug because
# rememberable is triggered on GET requests which means
# we would render a page on first access with all csrf
# tokens expired.
def clean_up_csrf?
false
end
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

@@ -16,21 +16,24 @@ module Devise
# 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
_catch_warden { super } # || @response # _catch_warden will setup the @response object
# process needs to return the ActionDispath::TestResponse object
@response
end
# We need to setup the environment variables and the response in the controller.
# 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:
@warden ||= begin
@request.env['warden'] ||= begin
manager = Warden::Manager.new(nil) do |config|
config.merge! Devise.warden_config
end
@request.env['warden'] = Warden::Proxy.new(@request.env, manager)
Warden::Proxy.new(@request.env, manager)
end
end
@@ -109,8 +112,9 @@ module Devise
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"]
r_opts = { status: status, content_type: headers["Content-Type"], location: headers["Location"] }
r_opts[Rails.version.start_with?('5') ? :body : :text] = response.body
@controller.send :render, r_opts
nil # causes process return @response
end
@@ -122,7 +126,8 @@ module Devise
# ensure the controller response is set to our response.
@controller.response ||= @response
@response.status = ret.first
@response.headers = ret.second
@response.headers.clear
ret.second.each { |k,v| @response[k] = v }
@response.body = ret.third
end

View File

@@ -1,11 +1,8 @@
# Deprecate: Copied verbatim from Rails source, remove once we move to Rails 4 only.
require 'thread_safe'
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 +27,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,3 @@
module Devise
VERSION = "3.4.0".freeze
VERSION = "4.1.0".freeze
end

View File

@@ -11,9 +11,9 @@ module ActiveRecord
def copy_devise_migration
if (behavior == :invoke && model_exists?) || (behavior == :revoke && migration_exists?(table_name))
migration_template "migration_existing.rb", "db/migrate/add_devise_to_#{table_name}.rb"
migration_template "migration_existing.rb", "db/migrate/add_devise_to_#{table_name}.rb", migration_version: migration_version
else
migration_template "migration.rb", "db/migrate/devise_create_#{table_name}.rb"
migration_template "migration.rb", "db/migrate/devise_create_#{table_name}.rb", migration_version: migration_version
end
end
@@ -75,17 +75,23 @@ RUBY
end
def inet?
rails4? && postgresql?
postgresql?
end
def rails4?
Rails.version.start_with? '4'
def rails5?
Rails.version.start_with? '5'
end
def postgresql?
config = ActiveRecord::Base.configurations[Rails.env]
config && config['adapter'] == 'postgresql'
end
def migration_version
if rails5?
"[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
end
end
end
end
end

View File

@@ -1,13 +1,13 @@
class DeviseCreate<%= table_name.camelize %> < ActiveRecord::Migration
class DeviseCreate<%= table_name.camelize %> < ActiveRecord::Migration<%= migration_version %>
def change
create_table(:<%= table_name %>) do |t|
create_table :<%= table_name %> do |t|
<%= migration_data -%>
<% attributes.each do |attribute| -%>
t.<%= attribute.type %> :<%= attribute.name %>
<% end -%>
t.timestamps
t.timestamps null: false
end
add_index :<%= table_name %>, :email, unique: true

View File

@@ -1,6 +1,6 @@
class AddDeviseTo<%= table_name.camelize %> < ActiveRecord::Migration
class AddDeviseTo<%= table_name.camelize %> < ActiveRecord::Migration<%= migration_version %>
def self.up
change_table(:<%= table_name %>) do |t|
change_table :<%= table_name %> do |t|
<%= migration_data -%>
<% attributes.each do |attribute| -%>
@@ -8,7 +8,7 @@ class AddDeviseTo<%= table_name.camelize %> < ActiveRecord::Migration
<% end -%>
# Uncomment below if timestamps were not included in your original model.
# t.timestamps
# t.timestamps null: false
end
add_index :<%= table_name %>, :email, unique: true

View File

@@ -8,7 +8,7 @@ module Devise
desc <<-DESC.strip_heredoc
Create inherited Devise controllers in your app/controllers folder.
User -c to specify which controller you want to overwrite.
Use -c to specify which controller you want to overwrite.
If you do no specify a controller, all controllers will be created.
For example:

View File

@@ -3,6 +3,8 @@ require 'securerandom'
module Devise
module Generators
MissingORMError = Class.new(Thor::Error)
class InstallGenerator < Rails::Generators::Base
source_root File.expand_path("../../templates", __FILE__)
@@ -10,6 +12,19 @@ module Devise
class_option :orm
def copy_initializer
unless options[:orm]
raise MissingORMError, <<-ERROR.strip_heredoc
An ORM must be set to install Devise in your application.
Be sure to have an ORM like Active Record or Mongoid loaded in your
app or configure your own at `config/application.rb`.
config.generators do |g|
g.orm :your_orm_gem
end
ERROR
end
template "devise.rb", "config/initializers/devise.rb"
end

View File

@@ -8,31 +8,14 @@ module Devise
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
CONTENT
buffer += <<-CONTENT if needs_attr_accessible?
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me
CONTENT
buffer
end
def needs_attr_accessible?
rails_3? && !strong_parameters_enabled?
end
def rails_3?
Rails::VERSION::MAJOR == 3
end
def strong_parameters_enabled?
defined?(ActionController::StrongParameters)
end
private
def model_exists?
File.exists?(File.join(destination_root, model_path))
File.exist?(File.join(destination_root, model_path))
end
def migration_exists?(table_name)

View File

@@ -47,7 +47,7 @@ module Devise
def view_directory(name, _target_path = nil)
directory name.to_s, _target_path || "#{target_path}/#{name}" do |content|
if scope
content.gsub "devise/shared/links", "#{scope}/shared/links"
content.gsub "devise/shared/links", "#{plural_scope}/shared/links"
else
content
end
@@ -55,7 +55,11 @@ module Devise
end
def target_path
@target_path ||= "app/views/#{scope || :devise}"
@target_path ||= "app/views/#{plural_scope || :devise}"
end
def plural_scope
@plural_scope ||= scope.presence && scope.underscore.pluralize
end
end
@@ -83,6 +87,13 @@ module Devise
source_root File.expand_path("../../templates/simple_form_for", __FILE__)
desc "Copies simple form enabled views to your application."
hide!
def copy_views
if options[:views]
options[:views].delete('mailer')
end
super
end
end
class ErbGenerator < Rails::Generators::Base #:nodoc:
@@ -111,7 +122,7 @@ module Devise
end
def target_path
"app/views/#{scope || :devise}/mailer"
"app/views/#{plural_scope || :devise}/mailer"
end
end

View File

@@ -2,12 +2,12 @@
Some setup you must do manually if you haven't yet:
Ensure you have overridden routes for generated controllers in your route.rb.
Ensure you have overridden routes for generated controllers in your routes.rb.
For example:
Rails.application.routes.draw do
devise_for :users, controllers: {
sessions: 'sessions'
sessions: 'users/sessions'
}
end

View File

@@ -21,7 +21,7 @@ class <%= @scope_prefix %>OmniauthCallbacksController < Devise::OmniauthCallback
# protected
# The path used when omniauth fails
# The path used when OmniAuth fails
# def after_omniauth_failure_path_for(scope)
# super(scope)
# end

View File

@@ -1,6 +1,6 @@
class <%= @scope_prefix %>RegistrationsController < Devise::RegistrationsController
# before_filter :configure_sign_up_params, only: [:create]
# before_filter :configure_account_update_params, only: [:update]
# before_action :configure_sign_up_params, only: [:create]
# before_action :configure_account_update_params, only: [:update]
# GET /resource/sign_up
# def new
@@ -38,14 +38,14 @@ class <%= @scope_prefix %>RegistrationsController < Devise::RegistrationsControl
# protected
# You can put the params you want to permit in the empty array.
# If you have extra params to permit, append them to the sanitizer.
# def configure_sign_up_params
# devise_parameter_sanitizer.for(:sign_up) << :attribute
# devise_parameter_sanitizer.permit(:sign_up, keys: [:attribute])
# end
# You can put the params you want to permit in the empty array.
# If you have extra params to permit, append them to the sanitizer.
# def configure_account_update_params
# devise_parameter_sanitizer.for(:account_update) << :attribute
# devise_parameter_sanitizer.permit(:account_update, keys: [:attribute])
# end
# The path used after sign up.

View File

@@ -1,5 +1,5 @@
class <%= @scope_prefix %>SessionsController < Devise::SessionsController
# before_filter :configure_sign_in_params, only: [:create]
# before_action :configure_sign_in_params, only: [:create]
# GET /resource/sign_in
# def new
@@ -18,8 +18,8 @@ class <%= @scope_prefix %>SessionsController < Devise::SessionsController
# protected
# You can put the params you want to permit in the empty array.
# If you have extra params to permit, append them to the sanitizer.
# def configure_sign_in_params
# devise_parameter_sanitizer.for(:sign_in) << :attribute
# devise_parameter_sanitizer.permit(:sign_in, keys: [:attribute])
# end
end

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

@@ -4,11 +4,9 @@ Devise.setup do |config|
# The secret key used by Devise. Devise uses this key to generate
# random tokens. Changing this key will render invalid all existing
# confirmation, reset password and unlock tokens in the database.
<% if rails_4? -%>
# Devise will use the `secret_key_base` as its `secret_key`
# by default. You can change it below and use your own secret key.
# config.secret_key = '<%= SecureRandom.hex(64) %>'
<% else -%>
config.secret_key = '<%= SecureRandom.hex(64) %>'
<% end -%>
# ==> Mailer Configuration
# Configure the e-mail address which will be shown in Devise::Mailer,
@@ -19,6 +17,9 @@ Devise.setup do |config|
# Configure the class responsible to send e-mails.
# config.mailer = 'Devise::Mailer'
# Configure the parent class responsible to send e-mails.
# config.parent_mailer = 'ActionMailer::Base'
# ==> ORM configuration
# Load and configure the ORM. Supports :active_record (default) and
# :mongoid (bson_ext recommended) by default. Other ORMs may be
@@ -33,7 +34,7 @@ Devise.setup do |config|
# session. If you need permissions, you should implement that in a before filter.
# You can also supply a hash where the value is a boolean determining whether
# or not authentication should be aborted when the value is not present.
# config.authentication_keys = [ :email ]
# config.authentication_keys = [:email]
# Configure parameters from the request object used for authentication. Each entry
# given should be a request method and it will automatically be passed to the
@@ -45,12 +46,12 @@ Devise.setup do |config|
# Configure which authentication keys should be case-insensitive.
# These keys will be downcased upon creating or modifying a user and when used
# to authenticate or find a user. Default is :email.
config.case_insensitive_keys = [ :email ]
config.case_insensitive_keys = [:email]
# Configure which authentication keys should have whitespace stripped.
# These keys will have whitespace before and after removed upon creating or
# modifying a user and when used to authenticate or find a user. Default is :email.
config.strip_whitespace_keys = [ :email ]
config.strip_whitespace_keys = [:email]
# Tell if authentication through request.params is enabled. True by default.
# It can be set to an array that will enable params authentication only for the
@@ -90,19 +91,22 @@ Devise.setup do |config|
# config.clean_up_csrf_token_on_authentication = true
# ==> Configuration for :database_authenticatable
# For bcrypt, this is the cost for hashing the password and defaults to 10. If
# using other encryptors, it sets how many times you want the password re-encrypted.
# For bcrypt, this is the cost for hashing the password and defaults to 11. If
# using other algorithms, it sets how many times you want the password to be hashed.
#
# Limiting the stretches to just one in testing will increase the performance of
# your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
# a value less than 10 in other environments. Note that, for bcrypt (the default
# encryptor), the cost increases exponentially with the number of stretches (e.g.
# algorithm), the cost increases exponentially with the number of stretches (e.g.
# a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
config.stretches = Rails.env.test? ? 1 : 10
config.stretches = Rails.env.test? ? 1 : 11
# Setup a pepper to generate the encrypted password.
# Set up a pepper to generate the hashed password.
# config.pepper = '<%= SecureRandom.hex(64) %>'
# Send a notification email when the user's password is changed
# config.send_password_change_notification = false
# ==> Configuration for :confirmable
# A period that the user is allowed to access the website even without
# confirming their account. For instance, if set to 2.days, the user will be
@@ -126,7 +130,7 @@ Devise.setup do |config|
config.reconfirmable = true
# Defines which key will be used when confirming an account
# config.confirmation_keys = [ :email ]
# config.confirmation_keys = [:email]
# ==> Configuration for :rememberable
# The time the user will be remembered without asking for credentials again.
@@ -144,21 +148,18 @@ Devise.setup do |config|
# ==> Configuration for :validatable
# Range for password length.
config.password_length = 8..128
config.password_length = 6..128
# Email regex used to validate email formats. It simply asserts that
# one (and only one) @ exists in the given string. This is mainly
# to give user feedback and not to assert the e-mail validity.
# config.email_regexp = /\A[^@]+@[^@]+\z/
config.email_regexp = /\A[^@\s]+@[^@\s]+\z/
# ==> Configuration for :timeoutable
# The time you want to timeout the user session without activity. After this
# time the user will be asked for credentials again. Default is 30 minutes.
# config.timeout_in = 30.minutes
# If true, expires auth token on session timeout.
# config.expire_auth_token_on_timeout = false
# ==> Configuration for :lockable
# Defines which strategy will be used to lock an account.
# :failed_attempts = Locks an account after a number of failed attempts to sign in.
@@ -166,7 +167,7 @@ Devise.setup do |config|
# config.lock_strategy = :failed_attempts
# Defines which key will be used when locking and unlocking an account
# config.unlock_keys = [ :email ]
# config.unlock_keys = [:email]
# Defines which strategy will be used to unlock an account.
# :email = Sends an unlock link to the user email
@@ -188,19 +189,23 @@ Devise.setup do |config|
# ==> Configuration for :recoverable
#
# Defines which key will be used when recovering the password for an account
# config.reset_password_keys = [ :email ]
# config.reset_password_keys = [:email]
# Time interval you can reset your password with a reset password key.
# Don't put a too small interval or your users won't have the time to
# change their passwords.
config.reset_password_within = 6.hours
# When set to false, does not sign a user in automatically after their password is
# reset. Defaults to true, so a user is signed in automatically after a reset.
# config.sign_in_after_reset_password = true
# ==> Configuration for :encryptable
# Allow you to use another encryption algorithm besides bcrypt (default). You can use
# :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
# :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
# and :restful_authentication_sha1 (then you should set stretches to 10, and copy
# REST_AUTH_SITE_KEY to pepper).
# Allow you to use another hashing or encryption algorithm besides bcrypt (default).
# You can use :sha1, :sha512 or algorithms from others authentication tools as
# :clearance_sha1, :authlogic_sha512 (then you should set stretches above to 20
# for default behavior) and :restful_authentication_sha1 (then you should set
# stretches to 10, and copy REST_AUTH_SITE_KEY to pepper).
#
# Require the `devise-encryptable` gem when using anything other than bcrypt
# config.encryptor = :sha512
@@ -257,7 +262,7 @@ Devise.setup do |config|
# The router that invoked `devise_for`, in the example above, would be:
# config.router_name = :my_engine
#
# When using omniauth, Devise cannot automatically set Omniauth path,
# When using OmniAuth, Devise cannot automatically set OmniAuth path,
# so you need to do it manually. For the users scope, it would be:
# config.omniauth_path_prefix = '/my_engine/users/auth'
end

View File

@@ -2,4 +2,4 @@ Welcome <%= @email %>!
You can confirm your account through the link below:
<%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %>
[Confirm my account](<%= confirmation_url(@resource, confirmation_token: @token) %>)

View File

@@ -0,0 +1,3 @@
<p>Hello <%= @resource.email %>!</p>
<p>We're contacting you to notify you that your password has been changed.</p>

View File

@@ -2,7 +2,7 @@ Hello <%= @resource.email %>!
Someone has requested a link to change your password, and you can do this through the link below.
<%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %>
[Change my password](<%= edit_password_url(@resource, reset_password_token: @token) %>)
If you didn't request this, please ignore this email.
Your password won't change until you access the link above and create a new one.

View File

@@ -4,4 +4,4 @@ Your account has been locked due to an excessive number of unsuccessful sign in
Click the link below to unlock your account:
<%= link_to 'Unlock my account', unlock_url(@resource, unlock_token: @token) %>
[Unlock my account](<%= unlock_url(@resource, unlock_token: @token) %>)

View File

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

View File

@@ -5,7 +5,7 @@
<div class="form-inputs">
<%= f.input :email, required: true, autofocus: true %>
<%= f.input :password, required: true, hint: ("#{@minimum_password_length} characters minimum" if @validatable) %>
<%= f.input :password, required: true, hint: ("#{@minimum_password_length} characters minimum" if @minimum_password_length) %>
<%= f.input :password_confirmation, required: true %>
</div>

View File

@@ -1,49 +0,0 @@
#!/usr/bin/env bash
# Usage: cached-bundle install --deployment
#
# After running `bundle`, caches the `vendor/bundle` directory to S3.
# On the next run, restores the cached directory before running `bundle`.
# When `Gemfile.lock` changes, the cache gets rebuilt.
#
# Requirements:
# - Gemfile.lock
# - TRAVIS_REPO_SLUG
# - TRAVIS_RUBY_VERSION
# - AMAZON_S3_BUCKET
# - script/s3-put
# - bundle
# - curl
#
# Author: Mislav Marohnić
set -e
compute_md5() {
local output="$(openssl md5)"
echo "${output##* }"
}
download() {
curl --tcp-nodelay -qsfL "$1" -o "$2"
}
gemfile="${BUNDLE_GEMFILE:-Gemfile}"
bundle_fullpath="$(dirname $gemfile)/vendor/bundle"
bundle_path=${bundle_fullpath#$PWD/}
gemfile_hash="$(compute_md5 <"${gemfile}.lock")"
cache_name="${TRAVIS_RUBY_VERSION}-${gemfile_hash}.tgz"
fetch_url="http://${AMAZON_S3_BUCKET}.s3.amazonaws.com/${TRAVIS_REPO_SLUG}/${cache_name}"
if download "$fetch_url" "$cache_name"; then
echo "Reusing cached bundle ${cache_name}"
tar xzf "$cache_name"
fi
bundle "$@"
if [ ! -f "$cache_name" ] && [ -n "$AMAZON_SECRET_ACCESS_KEY" ]; then
echo "Caching \`${bundle_path}' to S3"
tar czf "$cache_name" "$bundle_path"
script/s3-put "$cache_name" "${AMAZON_S3_BUCKET}:${TRAVIS_REPO_SLUG}/${cache_name}"
fi

View File

@@ -1,71 +0,0 @@
#!/usr/bin/env bash
# Usage: s3-put <FILE> <S3_BUCKET>[:<PATH>] [<CONTENT_TYPE>]
#
# Uploads a file to the Amazon S3 service.
# Outputs the URL for the newly uploaded file.
#
# Requirements:
# - AMAZON_ACCESS_KEY_ID
# - AMAZON_SECRET_ACCESS_KEY
# - openssl
# - curl
#
# Author: Mislav Marohnić
set -e
authorization() {
local signature="$(string_to_sign | hmac_sha1 | base64)"
echo "AWS ${AMAZON_ACCESS_KEY_ID?}:${signature}"
}
hmac_sha1() {
openssl dgst -binary -sha1 -hmac "${AMAZON_SECRET_ACCESS_KEY?}"
}
base64() {
openssl enc -base64
}
bin_md5() {
openssl dgst -binary -md5
}
string_to_sign() {
echo "$http_method"
echo "$content_md5"
echo "$content_type"
echo "$date"
echo "x-amz-acl:$acl"
printf "/$bucket/$remote_path"
}
date_string() {
LC_TIME=C date "+%a, %d %h %Y %T %z"
}
file="$1"
bucket="${2%%:*}"
remote_path="${2#*:}"
content_type="$3"
if [ -z "$remote_path" ] || [ "$remote_path" = "$bucket" ]; then
remote_path="${file##*/}"
fi
http_method=PUT
acl="public-read"
content_md5="$(bin_md5 < "$file" | base64)"
date="$(date_string)"
url="https://$bucket.s3.amazonaws.com/$remote_path"
curl -qsSf -T "$file" \
-H "Authorization: $(authorization)" \
-H "x-amz-acl: $acl" \
-H "Date: $date" \
-H "Content-MD5: $content_md5" \
-H "Content-Type: $content_type" \
"$url"
echo "$url"

View File

@@ -1,6 +1,6 @@
require 'test_helper'
class CustomRegistrationsControllerTest < ActionController::TestCase
class CustomRegistrationsControllerTest < Devise::ControllerTestCase
tests Custom::RegistrationsController
include Devise::TestHelpers
@@ -8,28 +8,33 @@ class CustomRegistrationsControllerTest < ActionController::TestCase
setup do
request.env["devise.mapping"] = Devise.mappings[:user]
@password = 'password'
@user = create_user(password: @password, password_confirmation: @password).tap(&:confirm!)
@user = create_user(password: @password, password_confirmation: @password).tap(&:confirm)
end
test "yield resource to block on create success" do
post :create, { user: { email: "user@example.org", password: "password", password_confirmation: "password" } }
post :create, params: { user: { email: "user@example.org", password: "password", password_confirmation: "password" } }
assert @controller.create_block_called?, "create failed to yield resource to provided block"
end
test "yield resource to block on create failure" do
post :create, { user: { } }
post :create, params: { user: { } }
assert @controller.create_block_called?, "create failed to yield resource to provided block"
end
test "yield resource to block on update success" do
sign_in @user
put :update, { user: { current_password: @password } }
put :update, params: { user: { current_password: @password } }
assert @controller.update_block_called?, "update failed to yield resource to provided block"
end
test "yield resource to block on update failure" do
sign_in @user
put :update, { user: { } }
put :update, params: { user: { } }
assert @controller.update_block_called?, "update failed to yield resource to provided block"
end
test "yield resource to block on new" do
get :new
assert @controller.new_block_called?, "new failed to yield resource to provided block"
end
end

View File

@@ -24,7 +24,7 @@ class CustomStrategy < Warden::Strategies::Base
end
end
class CustomStrategyTest < ActionController::TestCase
class CustomStrategyTest < Devise::ControllerTestCase
tests CustomStrategyController
include Devise::TestHelpers
@@ -41,8 +41,9 @@ class CustomStrategyTest < ActionController::TestCase
ret = get :new
# check the returned rack array
assert ret.is_a?(Array)
assert_equal 400, ret.first
# assert ret.is_a?(Array)
# assert_equal 400, ret.first
assert ret.is_a?(ActionDispatch::TestResponse)
# check the saved response as well. This is purely so that the response is available to the testing framework
# for verification. In production, the above array would be delivered directly to Rack.
@@ -53,8 +54,9 @@ class CustomStrategyTest < ActionController::TestCase
ret = get :new
# check the returned rack array
assert ret.is_a?(Array)
assert_equal ret.third['X-FOO'], 'BAR'
# assert ret.is_a?(Array)
# assert_equal ret.third['X-FOO'], 'BAR'
assert ret.is_a?(ActionDispatch::TestResponse)
# check the saved response headers as well.
assert_equal response.headers['X-FOO'], 'BAR'

View File

@@ -0,0 +1,22 @@
require 'test_helper'
class ApiController < ActionController::Metal
include Devise::Controllers::Helpers
end
class HelperMethodsTest < Devise::ControllerTestCase
tests ApiController
test 'includes Devise::Controllers::Helpers' do
assert_includes @controller.class.ancestors, Devise::Controllers::Helpers
end
test 'does not respond_to helper or helper_method' do
refute_respond_to @controller.class, :helper
refute_respond_to @controller.class, :helper_method
end
test 'defines methods like current_user' do
assert_respond_to @controller, :current_user
end
end

View File

@@ -1,7 +1,7 @@
require 'test_helper'
require 'ostruct'
class ControllerAuthenticatableTest < ActionController::TestCase
class ControllerAuthenticatableTest < Devise::ControllerTestCase
tests ApplicationController
def setup
@@ -245,6 +245,11 @@ class ControllerAuthenticatableTest < ActionController::TestCase
assert_equal "/foo?bar=baz", @controller.stored_location_for(:user)
end
test 'store location for stores fragments' do
@controller.store_location_for(:user, "/foo#bar")
assert_equal "/foo#bar", @controller.stored_location_for(:user)
end
test 'after sign in path defaults to root path if none by was specified for the given scope' do
assert_equal root_path, @controller.after_sign_in_path_for(:user)
end

View File

@@ -0,0 +1,51 @@
require 'test_helper'
class SessionsInheritedController < Devise::SessionsController
def test_i18n_scope
set_flash_message(:notice, :signed_in)
end
end
class AnotherInheritedController < SessionsInheritedController
protected
def translation_scope
'another'
end
end
class InheritedControllerTest < Devise::ControllerTestCase
tests SessionsInheritedController
def setup
@mock_warden = OpenStruct.new
@controller.request.env['warden'] = @mock_warden
@controller.request.env['devise.mapping'] = Devise.mappings[:user]
end
test 'I18n scope is inherited from Devise::Sessions' do
I18n.expects(:t).with do |message, options|
message == 'user.signed_in' &&
options[:scope] == 'devise.sessions'
end
@controller.test_i18n_scope
end
end
class AnotherInheritedControllerTest < Devise::ControllerTestCase
tests AnotherInheritedController
def setup
@mock_warden = OpenStruct.new
@controller.request.env['warden'] = @mock_warden
@controller.request.env['devise.mapping'] = Devise.mappings[:user]
end
test 'I18n scope is overridden' do
I18n.expects(:t).with do |message, options|
message == 'user.signed_in' &&
options[:scope] == 'another'
end
@controller.test_i18n_scope
end
end

View File

@@ -3,7 +3,7 @@ require 'test_helper'
class MyController < DeviseController
end
class HelpersTest < ActionController::TestCase
class HelpersTest < Devise::ControllerTestCase
tests MyController
def setup
@@ -13,16 +13,16 @@ class HelpersTest < ActionController::TestCase
end
test 'get resource name from env' do
assert_equal :user, @controller.resource_name
assert_equal :user, @controller.send(:resource_name)
end
test 'get resource class from env' do
assert_equal User, @controller.resource_class
assert_equal User, @controller.send(:resource_class)
end
test 'get resource instance variable from env' do
@controller.instance_variable_set(:@user, user = User.new)
assert_equal user, @controller.resource
assert_equal user, @controller.send(:resource)
end
test 'set resource instance variable from env' do
@@ -36,18 +36,16 @@ class HelpersTest < ActionController::TestCase
test 'get resource params from request params using resource name as key' do
user_params = {'email' => 'shirley@templar.com'}
params = if Devise.rails4?
# Stub controller name so strong parameters can filter properly.
# DeviseController does not allow any parameters by default.
@controller.stubs(:controller_name).returns(:sessions_controller)
# Stub controller name so strong parameters can filter properly.
# DeviseController does not allow any parameters by default.
@controller.stubs(:controller_name).returns(:sessions_controller)
params = ActionController::Parameters.new({'user' => user_params})
ActionController::Parameters.new({'user' => user_params})
else
HashWithIndifferentAccess.new({'user' => user_params})
end
@controller.stubs(:params).returns(params)
assert_equal user_params, @controller.send(:resource_params)
res_params = @controller.send(:resource_params).permit!.to_h
assert_equal user_params, res_params
end
test 'resources methods are not controller actions' do
@@ -80,7 +78,7 @@ class HelpersTest < ActionController::TestCase
test 'signed in resource returns signed in resource for current scope' do
@mock_warden.expects(:authenticate).with(scope: :user).returns(User.new)
assert_kind_of User, @controller.signed_in_resource
assert_kind_of User, @controller.send(:signed_in_resource)
end
test 'is a devise controller' do
@@ -99,6 +97,12 @@ class HelpersTest < ActionController::TestCase
assert_equal 'non-blank', flash[:notice]
end
test 'issues non-blank flash.now messages normally' do
I18n.stubs(:t).returns('non-blank')
@controller.send :set_flash_message, :notice, :send_instructions, { now: true }
assert_equal 'non-blank', flash.now[:notice]
end
test 'uses custom i18n options' do
@controller.stubs(:devise_i18n_options).returns(default: "devise custom options")
@controller.send :set_flash_message, :notice, :invalid_i18n_messagesend_instructions

View File

@@ -0,0 +1,19 @@
require 'test_helper'
class LoadHooksControllerTest < Devise::ControllerTestCase
setup do
ActiveSupport.on_load(:devise_controller) do
define_method :defined_by_load_hook do
puts 'I am defined dynamically by activesupport load hook'
end
end
end
teardown do
DeviseController.class_eval { undef :defined_by_load_hook }
end
test 'load hook called when controller is loaded' do
assert DeviseController.instance_methods.include? :defined_by_load_hook
end
end

View File

@@ -1,18 +1,19 @@
require 'test_helper'
class PasswordsControllerTest < ActionController::TestCase
class PasswordsControllerTest < Devise::ControllerTestCase
tests Devise::PasswordsController
include Devise::TestHelpers
setup do
request.env["devise.mapping"] = Devise.mappings[:user]
@user = create_user.tap(&:confirm!)
@user = create_user.tap(&:confirm)
@raw = @user.send_reset_password_instructions
end
def put_update_with_params
put :update, "user" => {
"reset_password_token" => @raw, "password" => "1234567", "password_confirmation" => "1234567"
put :update, params: { "user" => {
"reset_password_token" => @raw, "password" => "1234567", "password_confirmation" => "1234567"
}
}
end

View File

@@ -1,20 +1,21 @@
require 'test_helper'
class SessionsControllerTest < ActionController::TestCase
class SessionsControllerTest < Devise::ControllerTestCase
tests Devise::SessionsController
include Devise::TestHelpers
test "#create doesn't raise unpermitted params when sign in fails" do
begin
subscriber = ActiveSupport::Notifications.subscribe /unpermitted_parameters/ do |name, start, finish, id, payload|
subscriber = ActiveSupport::Notifications.subscribe %r{unpermitted_parameters} do |name, start, finish, id, payload|
flunk "Unpermitted params: #{payload}"
end
request.env["devise.mapping"] = Devise.mappings[:user]
request.session["user_return_to"] = 'foo.bar'
create_user
post :create, user: {
email: "wrong@email.com",
password: "wrongpassword"
post :create, params: { user: {
email: "wrong@email.com",
password: "wrongpassword"
}
}
assert_equal 200, @response.status
ensure
@@ -36,12 +37,12 @@ class SessionsControllerTest < ActionController::TestCase
request.session["user_return_to"] = 'foo.bar'
user = create_user
user.confirm!
post :create, user: {
email: user.email,
password: user.password
user.confirm
post :create, params: { user: {
email: user.email,
password: user.password
}
}
assert_nil request.session["user_return_to"]
end
@@ -50,10 +51,11 @@ class SessionsControllerTest < ActionController::TestCase
request.session["user_return_to"] = 'foo.bar'
user = create_user
user.confirm!
post :create, format: 'json', user: {
email: user.email,
password: user.password
user.confirm
post :create, params: { format: 'json', user: {
email: user.email,
password: user.password
}
}
assert_equal 'foo.bar', request.session["user_return_to"]
@@ -61,9 +63,10 @@ class SessionsControllerTest < ActionController::TestCase
test "#create doesn't raise exception after Warden authentication fails when TestHelpers included" do
request.env["devise.mapping"] = Devise.mappings[:user]
post :create, user: {
email: "nosuchuser@example.com",
password: "wevdude"
post :create, params: { user: {
email: "nosuchuser@example.com",
password: "wevdude"
}
}
assert_equal 200, @response.status
assert_template "devise/sessions/new"
@@ -72,12 +75,12 @@ class SessionsControllerTest < ActionController::TestCase
test "#destroy doesn't set the flash if the requested format is not navigational" do
request.env["devise.mapping"] = Devise.mappings[:user]
user = create_user
user.confirm!
post :create, format: 'json', user: {
email: user.email,
password: user.password
user.confirm
post :create, params: { format: 'json', user: {
email: user.email,
password: user.password
}
}
delete :destroy, format: 'json'
assert flash[:notice].blank?, "flash[:notice] should be blank, not #{flash[:notice].inspect}"
assert_equal 204, @response.status

View File

@@ -1,6 +1,6 @@
require 'test_helper'
class RoutesTest < ActionController::TestCase
class RoutesTest < Devise::ControllerTestCase
tests ApplicationController
def assert_path_and_url(name, prepend_path=nil)

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

@@ -14,11 +14,11 @@ class DeviseTest < ActiveSupport::TestCase
test 'bcrypt on the class' do
password = "super secret"
klass = Struct.new(:pepper, :stretches).new("blahblah", 2)
hash = Devise.bcrypt(klass, password)
hash = Devise::Encryptor.digest(klass, password)
assert_equal ::BCrypt::Password.create(hash), hash
klass = Struct.new(:pepper, :stretches).new("bla", 2)
hash = Devise.bcrypt(klass, password)
hash = Devise::Encryptor.digest(klass, password)
assert_not_equal ::BCrypt::Password.new(hash), hash
end
@@ -94,8 +94,8 @@ class DeviseTest < ActiveSupport::TestCase
end
test 'Devise.email_regexp should match valid email addresses' do
valid_emails = ["test@example.com", "jo@jo.co", "f4$_m@you.com", "testing.example@example.com.ua"]
non_valid_emails = ["rex", "test@go,com", "test user@example.com", "test_user@example server.com"]
valid_emails = ["test@example.com", "jo@jo.co", "f4$_m@you.com", "testing.example@example.com.ua", "test@tt", "test@valid---domain.com"]
non_valid_emails = ["rex", "test user@example.com", "test_user@example server.com"]
valid_emails.each do |email|
assert_match Devise.email_regexp, email

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