Compare commits

...

403 Commits

Author SHA1 Message Date
Ulisses Almeida
7e658a2abf Release 3.5.9 2016-05-02 23:47:19 -03:00
Justin Bull
0252f0e4a8 Extract list of both strategies into class constant 2016-05-02 23:46:18 -03:00
Justin Bull
07e907ec26 🪲 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-02 23:46:08 -03:00
Ulisses Almeida
e9ed3e2cb4 Support for older rails versions. 2016-04-25 18:44:11 -03:00
Ulisses Almeida
2fa6735462 Lock mime-types to ~> 2.99
If we update mime-types to 3 or greater, it does not
works with ruby 1.9.3.
2016-04-25 18:14:12 -03:00
Ulisses Almeida
b8cddc3cf3 Release 3.5.8 2016-04-25 16:57:28 -03:00
MatBi
1d57169c7b Send confirmation instructions when a user updates the email address from nil 2016-04-25 16:51:40 -03:00
Ulisses Almeida
812c1de8e8 Release 3.5.7 version. 2016-04-18 11:57:22 -03:00
Ulisses Almeida
a0f266c584 📝 Update CHANGELOG 2016-04-18 11:48:18 -03:00
Ulisses Almeida
ad99bfe6ef 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-18 11:47:56 -03:00
Lucas Mazza
89931ed533 Release 3.5.6. 2016-02-01 09:09:55 -02:00
Lucas Mazza
57fdae1e48 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-31 16:25:10 -02:00
Lucas Mazza
30e494580c 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:45:14 -02:00
José Valim
048d05a553 Ensure generated_at is a Time 2016-01-25 11:17:05 +01:00
José Valim
8cbdeb54a5 Release v3.5.5 2016-01-22 20:22:34 +01:00
José Valim
14affc8a55 Do not timeout if remember me is enabled 2016-01-22 16:18:57 +01:00
José Valim
eb0f0b662f Readd remember_expired? 2016-01-22 15:57:57 +01:00
José Valim
1516a0ae6d Release v3.5.4 2016-01-18 15:12:07 +01:00
José Valim
c92996646a Store creation timestamp on remember cookies
Signed-off-by: José Valim <jose.valim@plataformatec.com.br>
2016-01-18 14:47:31 +01:00
Kacper Walanus
ba5dd0a41a test for save in after_create hook breaks devise confirmation [3787] 2015-12-15 11:41:48 -02:00
Christian Macias
f63be5039a changed email_was !='' to email_was.present? 2015-12-15 11:41:33 -02:00
Christian Macias
f25562fd4b fix for #3787, save in after_create hook breaks devise confirmation 2015-12-15 11:41:33 -02:00
Siva Gollapalli
2a2fd806a8 FIX# Comparing times in UTC 2015-12-15 11:40:59 -02: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
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
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
Lucas Mazza
bdf9c25f3b Release 3.4.0 2014-10-03 14:28:15 -03:00
Lucas Mazza
9b49e89ebd Update CHANGELOG [ci skip] 2014-10-03 14:20:31 -03:00
Lucas Mazza
8e5c098e3a Merge pull request #3153 from plataformatec/lm-rails-4-2
Rails 4.2 compatibility
2014-10-03 14:07:59 -03:00
Lucas Mazza
547e18e24e Merge pull request #3239 from plataformatec/lm-last_attempt_warning
Use the `last_attempt_warning` configuration with the lockable unauthenticated_message message.
2014-10-03 14:04:56 -03:00
José Valim
5ee215bcae Merge pull request #3242 from wasabhi/master
Use spec/rails_helper.rb for rspec-rails config.
2014-10-03 18:59:27 +02:00
Abhinav
6445e07791 Use spec/rails_helper.rb for rspec-rails config. 2014-10-03 10:13:36 -06:00
Lucas Mazza
fa7714218e Update CHANGELOG 2014-10-03 09:49:48 -03:00
Lucas Mazza
6405c96213 last_attempt_warning should be true for now on. 2014-10-03 09:49:29 -03:00
Lucas Mazza
1d8890b773 Merge branch 'master' into lm-rails-4-2 2014-10-03 09:41:23 -03:00
Lucas Mazza
fd565c7efb Merge pull request #3241 from plataformatec/revert-3195-master
Revert "Removes reloading of routes when eager loading ..."
2014-10-03 09:39:09 -03:00
Lucas Mazza
c411ebcad6 Revert "Removes reloading of routes when eager loading ..." 2014-10-03 09:35:05 -03:00
Lucas Mazza
8b15184a25 Use the last_attempt_warning configuration with the lockable unauthenticated_message message.
This configuration was added in #2687 but it was never used in the real code that
defines what message should be used by the app.
2014-10-02 18:50:48 -03:00
Lucas Mazza
ed109ac3d5 Merge swap usage into a single method call. 2014-10-02 18:42:46 -03:00
Lucas Mazza
6f8a383ff6 Merge pull request #3221 from timoschilling/auth_keys_text
fix and optimice authentication_keys
2014-09-29 17:43:13 -03:00
Lucas Mazza
ee69d41fc1 Remove ActiveSupport test order deprecation warning 2014-09-29 17:42:08 -03:00
Lucas Mazza
1ed93cacd8 Update Rails dependency 2014-09-29 17:38:16 -03:00
Lucas Mazza
7eeaac9db1 Merge branch 'master' into lm-rails-4-2 2014-09-29 17:30:30 -03:00
José Valim
64b4905410 Merge pull request #3229 from yandy/patch-1
fix path bug
2014-09-29 09:30:11 +02:00
Michael Ding
002b4c6c01 fix argument bug
when `is_navigational_format?` returns false, Exception will be throw: 
ArgumentError (Nil location provided. Can't build URI.)
2014-09-29 14:36:05 +08:00
Timo Schilling
0f240ab68f code cleanup FailureApp 2014-09-24 15:51:51 +02:00
Timo Schilling
d546665102 use I18n "support.array.words_connector" as connector 2014-09-24 14:13:37 +02:00
Timo Schilling
d3c53904c7 use auth keys from scope instead of global config 2014-09-24 14:05:38 +02:00
José Valim
9f63850279 Merge pull request #3218 from timoschilling/fix_3201
use authentication_keys in flash message (fix #3201)
2014-09-24 08:15:40 +02:00
Timo Schilling
6b0d11ed7a use authentication_keys in flash message, instead of static ‘username’ (fix #3201) 2014-09-23 18:42:11 +02:00
José Valim
258a29636b Merge pull request #3216 from vasinov/master
Update README.md
2014-09-22 09:35:25 +02:00
Vasily Vasinov
c811ea2edb Update README.md
Added the security shield from Hakiri.
2014-09-21 21:41:42 -06:00
Lucas Mazza
dce67416c5 Merge pull request #3162 from plataformatec/lm-sanitizer-to-hash
Do not pass down 'ActionController::Parameters' to outside the controller
2014-09-18 18:45:05 -03:00
Lucas Mazza
c043eca2b2 Silence controller generator warning output 2014-09-18 18:24:26 -03:00
Lucas Mazza
39ed332299 Ensure that we sanitize any AC::Parameters in find_or_initialize_with_errors.
As we are already slicing the Hash, we must be sure that this method will send
 a "safe" object down to the other finder methods that will use the Hash entries
 to do the querying.
2014-09-18 18:21:05 -03:00
Lucas Mazza
8482e485d1 Merge branch 'master' into lm-rails-4-2 2014-09-18 17:46:14 -03:00
Lucas Mazza
952c162bee Update CHANGELOG 2014-09-18 17:25:13 -03:00
Lucas Mazza
131013ac56 Controller templates should have the .rb extension, not .erb. 2014-09-18 17:21:25 -03:00
Lucas Mazza
79a4b93993 Point users to the canonical Omniauth docs in our README, not the wiki. 2014-09-18 17:18:11 -03:00
Lucas Mazza
9fe1561b56 Merge pull request #3169 from Chun-Yang/master
Create controller generator for devise (rails generator devise:controllers users -c sessions)
2014-09-18 17:17:17 -03:00
José Valim
a5158939de Update CHANGELOG 2014-09-18 20:28:24 +02:00
José Valim
7029a5aaa8 Decouple validation from remember_me in authentication strategies
Closes #3118
2014-09-18 20:04:12 +02:00
José Valim
73c406b481 Fix docs for http_authenticatable_on_xhr, closes #3112 2014-09-18 19:50:58 +02:00
José Valim
432a172533 Set null: false explicitly in timestamps 2014-09-18 19:50:58 +02:00
José Valim
1581a34ee4 Merge pull request #3195 from fgro/master
Removes reloading of routes when eager loading ...
2014-09-18 19:44:45 +02:00
José Valim
32b5299547 Merge pull request #3171 from micat/find_scope-should-accept-string
Url helpers raise "undefined method `router_name' for nil:NilClass"
2014-09-18 19:41:49 +02:00
Lucas Mazza
ce6e369ba8 Remove test ordering setup
We can now run the test suite on random order.
2014-09-11 17:41:40 -03:00
Lucas Mazza
8a8e8c6519 Simplify the setup code for the Devise Helper tests so no locales or translations are leaked between tests. 2014-09-11 17:01:07 -03:00
Lucas Mazza
48f03d8cc4 Ensure that the I18n backend is always initialized when we store custom translations.
Depending on the test order, there might a moment when a test reloads the I18n
backend and another tries to store a translation, but since the backend wasn't
re-initialized the custom translations would be overriden when i18n loads the
translations from the en.yml file.
2014-09-11 15:19:41 -03:00
José Valim
13c99d8162 Merge pull request #3205 from pjungwir/consistent-failed-login-messages
All causes of failed login should have the same error message
2014-09-11 17:47:50 +02:00
Paul A. Jungwirth
6e0c287391 All causes of failed login should have the same error message 2014-09-11 08:38:14 -07:00
Chun-Yang
439112adf3 change before_action to before_filter to make it backward compatible to rails 3.2 2014-09-09 20:40:05 -05:00
Chun-Yang
17f6c76dc7 simplify sanitizer in *_params function 2014-09-09 20:35:46 -05:00
Chun-Yang
6003c69818 change indentation 2014-09-09 20:31:48 -05:00
Lucas Mazza
a6f3f8cb4a Split up mailer classes into their own files. 2014-09-08 18:01:39 -03:00
Lucas Mazza
716d128e27 Restore global allow_unconfirmed_access_for after test 2014-09-08 17:38:06 -03:00
Fred Grosskopf
db88341402 Removes reloading of routes when eager loading ...
... is enabled.

The old code may cause conflicts when developing an engine (i.e. invalid
route name) and according to @josevalim the reason for it to remain is
unknown.
2014-09-08 14:21:33 +02:00
Lucas Mazza
cc21c87bb3 Update CHANGELOG [ci skip] 2014-09-03 21:58:44 -05:00
Chun-Yang
67dc138d94 add before_action hooks for registrations and sessions controllers to enable user to add extra params 2014-09-03 00:10:32 -05:00
Chun-Yang
a9095b86d4 fix typo: 'new' action should be 'create' action 2014-09-03 00:02:07 -05:00
Chun-Yang
86ac552287 add *_path_for stubs in all controllers 2014-09-02 23:49:37 -05:00
Chun-Yang
e2e9e90d69 move controller generator info from lib/generators/templates/README to README 2014-09-02 23:25:38 -05:00
Chun-Yang
daad552e1b make scope required 2014-09-02 23:04:27 -05:00
Chun-Yang
2f81a83232 refactor code, use a constant insead of a class variable 2014-09-02 22:54:06 -05:00
Chun-Yang
6ba87ed339 comment out all stubs 2014-09-02 22:34:13 -05:00
Lucas Mazza
c25312e78e Remove ActionMailer/ActiveJob deprecation. 2014-09-02 14:54:28 -03:00
Lucas Mazza
6af18ed9e3 Change the 'postgresql?' check to not connect to the database.
Closes #3181
2014-09-02 11:24:31 -03:00
Carlos Antonio da Silva
930bed7a10 Add changelog for #3175 [ci skip] 2014-09-01 19:38:07 -03:00
Carlos Antonio da Silva
4ad2ed8f12 Merge pull request #3175 from aried3r/update_simple_form_templates
Update Simple Form templates for 3.3.0
2014-09-01 19:34:54 -03:00
Lucas Mazza
13eebb6b76 Ensure that this is only called when necessary. 2014-09-01 19:01:24 -03:00
Lucas Mazza
7dce5baf6c Devise tests are order dependent.
Until 4.2.0, any test suite based on the `TestCase` classes provided by Rails would
always run into alphabetical, but now they run in random order. For now, we ensure
that our tests always run in alphabetical order.

Related commit on rails/rails
6ffb29d24e
2014-09-01 18:47:08 -03:00
Anton Rieder
6117a3b56d Update Simple Form templates for 3.3.0 2014-09-01 21:59:03 +02:00
Chun-Yang
274daad005 fix code example shown in README user will see after running generator 2014-08-27 23:25:48 -05:00
Chun-Yang
316be42ed6 add instruction in the README file for controllers generator. This readme will be printed when user invoke devise:install 2014-08-27 23:20:26 -05:00
Chun-Yang
220c8ff089 print README instruction after running controller generator 2014-08-27 23:19:43 -05:00
Chun-Yang
af47bb5542 update description message in the controllers generator 2014-08-24 22:41:00 -05:00
Chun-Yang
992ee86b41 add test for controllers generator 2014-08-24 22:05:54 -05:00
Chun-Yang
02b1a9c4e0 enable empty scope when generating a controller 2014-08-24 21:28:06 -05:00
micat
7b5293906b Return Symbol in find_scope! if String passed 2014-08-24 21:36:11 +09:00
Chun-Yang
8de94035f0 add better help description 2014-08-24 00:06:12 -05:00
Chun-Yang
d8d9814ed4 user erb template to generate controllers, enable --controllers option to specify controllers, make 'scope' argument required 2014-08-23 23:29:45 -05:00
Chun-Yang
4f77da5b87 Step1: Create controllers templates, and create controller generator to copy ALL templates to rails app directory 2014-08-23 16:44:06 -05:00
Lucas Mazza
2f4fab00d9 Update 4.1 Gemfile 2014-08-22 13:22:00 -03:00
Lucas Mazza
2beae8e143 Update Gemfile list on Travis. 2014-08-20 18:44:50 -03:00
Lucas Mazza
70e9e92d23 Reorganize Gemfiles. 2014-08-20 18:16:51 -03:00
Lucas Mazza
a638c21e76 Add responders as a Devise dependency. 2014-08-20 18:12:57 -03:00
Lucas Mazza
9b9ee8bd2d Test against the released gem 2014-08-19 23:41:51 -03:00
Lucas Mazza
0b13f587ef Update gemfile with latest Rails changes and Responders 2. 2014-08-19 23:39:10 -03:00
Lucas Mazza
0e384f6fb6 Remove missing action warning from the omniauth callbacks route. 2014-08-19 23:38:37 -03:00
Lucas Mazza
7f3dac8652 Use []= instead of merge! to mutate the current Router scope.
This was broken in Rails 4.2.0+ because the `@scope` object is no longer a Hash
but an internal structure that supports a better override/rollback flow for cases
like this. If we would only support Rails 4.2, this method could be something
like this:

```ruby
def with_devise_exclusive_scope(new_path, new_as, options)
  overrides = { as: new_as, path: new_path, module: nil }
  overrides.merge!(options.slice(:constraints, :defaults, :options))

    @scope = @scope.new(overrides)
  yield
ensure
  @scope = @scope.parent
end
```
2014-08-19 23:38:37 -03:00
Lucas Mazza
df43642cd5 Update Gemfiles 2014-08-19 22:14:35 -03:00
Lucas Mazza
8e4a700f81 Update gemfiles 2014-08-18 10:36:57 -03:00
José Valim
871b9b06f8 Merge pull request #3152 from DamirSvrtan/master
Rename links.erb to links.html.erb
2014-08-17 18:38:15 -04:00
Damir Svrtan
df9712bbe4 Rename links.erb to links.html.erb 2014-08-18 00:15:25 +02: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
136 changed files with 2845 additions and 1183 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
- 2.1
- 2.2
gemfile:
- gemfiles/Gemfile.rails-4.2-stable
- gemfiles/Gemfile.rails-4.1-stable
- gemfiles/Gemfile.rails-4.0-stable
- gemfiles/Gemfile.rails-3.2-stable
- Gemfile
matrix:
exclude:
- rvm: 2.2
gemfile: gemfiles/Gemfile.rails-3.2-stable
services:
- mongodb
sudo: false
cache: bundler
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="
gemfile:
- gemfiles/Gemfile.rails-head
- gemfiles/Gemfile.rails-4.0-stable
- gemfiles/Gemfile.rails-3.2-stable
- Gemfile
matrix:
allow_failures:
- gemfile: gemfiles/Gemfile.rails-head
services:
- mongodb
before_install: "rm ${BUNDLE_GEMFILE}.lock"
before_script: "bundle update"
script: "bundle exec rake test"
notifications:
email: false
campfire:
slack:
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=

View File

@@ -1,9 +1,123 @@
### Unreleased
* enhancements
* bug fixes
### 3.5.9 - 2016-05-02
### 3.3.0
* bug fixes
* Fix strategy checking in `Lockable#unlock_strategy_enabled?` for `:none`
and `:undefined` strategies. (by @f3ndot)
### 3.5.8 - 2016-04-25
* bug fixes
* Fix the e-mail confirmation instructions send when a user updates the email address from nil
### 3.5.7 - 2016-04-18
* bug fixes
* Fix the `extend_remember_period` configuration. When set to `false` it does
not update the cookie expiration anymore.(by @ulissesalmeida)
### 3.5.6 - 2016-01-02
* bug fixes
* Fix type coercion of the rememberable timestamp stored on cookies.
### 3.5.5 - 2016-22-01
* bug fixes
* Bring back remember_expired? implementation
* Ensure timeouts are not triggered if remember me is being used
### 3.5.4 - 2016-18-01
* bug fixes
* Store creation timestamps on remember cookies
### 3.5.3 - 2015-12-10
* bug fixes
* Fix password reset for records where `confirmation_required?` is disabled and
`confirmation_sent_at` is nil. (by @andygeers)
* Allow resources with no `email` field to be recoverable (and do not clear the
reset password token if the model was already persisted). (by @seddy, @stanhu)
* enhancements
* Upon setting `Devise.send_password_change_notification = true` a user will receive notification when their password has been changed.
### 3.5.2 - 2015-08-10
* enhancements
* Perform case insensitive basic authorization matching
* bug fixes
* Do not use digests for password confirmation token
* Fix infinite redirect in Rails 4.2 authenticated routes
* Autoload Devise::Encryptor to avoid errors on thread-safe mode
* deprecations
* `config.expire_auth_token_on_timeout` was removed
### 3.5.1 - 2015-05-24
Note: 3.5.0 has been yanked due to a regression
* security improvements
* Clean up reset password token whenever e-mail or password changes. thanks to George Deglin & Dennis Charles Hackethal for reporting this bug
* Ensure empty `authenticable_salt` cannot be used as remember token. This bug can only affect users who manually implement their own `authenticable_salt` and allow empty values as salt
* enhancements
* The hint about minimum password length required both `@validatable` and `@minimum_password_length` variables on the views, it now uses only the latter. If you have generated the views relying on the `@validatable` variable, replace it with `@minimum_password_length`.
* Added an ActiveSupport load hook for `:devise_controller`. (by @nakhli)
* Location fragments are now preserved between requests. (by @jbourassa)
* Added an `after_remembered` callback for the Rememerable module. (by @BM5k)
* `RegistrationsController#new` and `SessionsController#new` now yields the
current resource. (by @mtarnovan, @deivid-rodriguez)
* Password length validation is now limited to 72 characters for newer apps. (by @lleger)
* Controllers inheriting from any Devise core controller will now use appropriate translations. The i18n scope can be overridden in `translation_scope`.
* Allow the user to set the length of friendly token. (by @Angelmmiguel)
* bug fixes
* Use router_name from scope if one is available to support isolated engines. (by @cipater)
* Do not clean up CSRF on rememberable.
* Only use flash if it has been configured in failure app. (by @alex88)
* deprecations
* `confirm!` has been deprecated in favor of `confirm`.
* `reset_password!` has been deprecated in favor of `reset_password`.
* `Devise.bcrypt` has been deprecated in favor of `Devise::Encryptor.digest`".
### 3.4.1 - 2014-10-29
* enhancements
* Devise default views now have a similar markup to Rails scaffold views. (by @udaysinghcode, @cllns)
* Passing `now: true` to the `set_flash_message` helper now sets the message into
the `flash.now` Hash. (by @hbriggs)
* bugfixes
* Fixed an regression with translation of flash messages for when the `authentication_keys`
config is a Hash. (by @lucasmazza)
### 3.4.0 - 2014-10-03
* enhancements
* Support added for Rails 4.2. Devise now depends on the `responders` gem due
the extraction of the `respond_with` API from Rails. (by @lucasmazza)
* The Simple Form templates follow the same change from 3.3.0 by using `Log in` and adding
a hint about the minimum password length when `validatable` is enabled. (by @aried3r)
* Controller generator added as `devise:controllers SCOPE`. You can use the `-c` flag
to pick which controllers (`unlocks`, `confirmations`, etc) you want to generate. (by @Chun-Yang)
* Removed the hardcoded references for "email" in the flash messages. If you are using
different attributes as the `authentication_keys` they will be interpolated in the
messages instead. (by @timoschilling)
* bug fix
* Fixed a regression where the devise generator would fail with a `ConnectionNotEstablished`
exception when executed inside a mountable engine. (by @lucasmazza)
* Ensure to return symbols in find_scope! fixing a previous regression from 3.3.0 (by @micat)
* Ensure all causes of failed login have the same error message (by @pjungwir)
* The `last_attempt_warning` now takes effect when generating the unauthenticated
message for your users. To keep the current behavior, this flag is now `true`
by default. (by @lucasmazza)
### 3.3.0 - 2014-08-13
* enhancements
* Support multiple warden configuration blocks on devise configuration. (by @rossta)
@@ -27,13 +141,13 @@
* Ensure registration controller block yields happen on failure in addition to success (by @dpehrson)
* Only valid paths will be stored for redirections (by @parallel588)
### 3.2.4
### 3.2.4 - 2014-03-17
* enhancements
* `bcrypt` dependency updated due https://github.com/codahale/bcrypt-ruby/pull/86.
* View generator now can generate specific views with the `-v` flag, like `rails g devise:views -v sessions` (by @kayline)
### 3.2.3
### 3.2.3 - 2014-02-20
* enhancements
* Devise will use the `secret_key_base` on Rails 4+ applications as its `secret_key`.
@@ -42,14 +156,14 @@
* bug fix
* Migrations will be properly generated when using rails 4.1.0.
### 3.2.2
### 3.2.2 - 2013-11-25
* bug fix
* Ensure timeoutable works when `sign_out_all_scopes` is false (by @louman)
* Keep the query string when storing location (by @csexton)
* Require rails generator base class in devise generators
### 3.2.1
### 3.2.1 - 2013-11-13
Security announcement: http://blog.plataformatec.com.br/2013/11/e-mail-enumeration-in-devise-in-paranoid-mode
@@ -61,7 +175,7 @@ Security announcement: http://blog.plataformatec.com.br/2013/11/e-mail-enumerati
* Bring `password_digest` back to fix compatibility with `devise-encryptable`
* Avoid e-mail enumeration on sign in when in paranoid mode
### 3.2.0
### 3.2.0 - 2013-11-06
* enhancements
* Previously deprecated token authenticatable and insecure lookups have been removed
@@ -80,13 +194,13 @@ Security announcement: http://blog.plataformatec.com.br/2013/11/e-mail-enumerati
* deprecations
* `expire_session_data_after_sign_in!` has been deprecated in favor of `expire_data_after_sign_in!`
### 3.1.1
### 3.1.1 - 2013-10-01
* bug fix
* Improve default message which asked users to sign in even when they were already signed (by @gregates)
* Improve error message for when the config.secret_key is missing
### 3.1.0
### 3.1.0 - 2013-09-05
Security announcement: http://blog.plataformatec.com.br/2013/08/devise-3-1-now-with-more-secure-defaults/
@@ -109,12 +223,12 @@ Security announcement: http://blog.plataformatec.com.br/2013/08/devise-3-1-now-w
* Do not compare directly against confirmation, unlock and reset password tokens
* Skip storage for cookies on unverified requests
### 3.0.2
### 3.0.2 - 2013-08-09
* bug fix
* Skip storage for cookies on unverified requests
### 3.0.1
### 3.0.1 - 2013-08-02
Security announcement: http://blog.plataformatec.com.br/2013/08/csrf-token-fixation-attacks-in-devise/
@@ -125,7 +239,7 @@ Security announcement: http://blog.plataformatec.com.br/2013/08/csrf-token-fixat
* When using rails 3.2, the generator adds 'attr_accessible' to the model (by @jcoyne)
* Clean up CSRF token after authentication (by @homakov). Notice this change will clean up the CSRF Token after authentication (sign in, sign up, etc). So if you are using AJAX for such features, you will need to fetch a new CSRF token from the server.
### 3.0.0
### 3.0.0 - 2013-07-14
* enhancements
* Rails 4 and Strong Parameters compatibility (by @carlosantoniodasilva, @josevalim, @latortuga, @lucasmazza, @nashby, @rafaelfranca, @spastorino)
@@ -135,7 +249,7 @@ Security announcement: http://blog.plataformatec.com.br/2013/08/csrf-token-fixat
* bug fix
* Errors on unlock are now properly reflected on the first `unlock_keys`
### 2.2.4
### 2.2.4 - 2013-05-07
* enhancements
* Add `destroy_with_password` to `DatabaseAuthenticatable`. Allows destroying a record when `:current_password` matches, similarly to how `update_with_password` works. (by @michiel3)
@@ -154,25 +268,25 @@ Security announcement: http://blog.plataformatec.com.br/2013/08/csrf-token-fixat
* backwards incompatible changes
* Changes on session storage will expire all existing sessions on upgrade. For those storing the session in the DB, they can be upgraded according to this gist: https://gist.github.com/moll/6417606
### 2.2.3
### 2.2.3 - 2013-01-26
Security announcement: http://blog.plataformatec.com.br/2013/01/security-announcement-devise-v2-2-3-v2-1-3-v2-0-5-and-v1-5-3-released/
* bug fix
* Require string conversion for all values
### 2.2.2
### 2.2.2 - 2013-01-15
* bug fix
* Fix bug when checking for reconfirmable in templates
### 2.2.1
### 2.2.1 - 2013-01-11
* bug fix
* Fix regression with case_insensitive_keys
* Fix regression when password is blank when it is invalid
### 2.2.0
### 2.2.0 - 2013-01-08
* backwards incompatible changes
* `headers_for` is deprecated, customize the mailer directly instead
@@ -203,17 +317,17 @@ Security announcement: http://blog.plataformatec.com.br/2013/01/security-announc
* `update_with_password` doesn't change encrypted password when it is invalid (by @nashby)
* Properly handle namespaced models on Active Record generator (by @nashby)
### 2.1.4
### 2.1.4 - 2013-08-18
* bugfix
* Do not confirm account after reset password
### 2.1.3
### 2.1.3 - 2013-01-26
* bugfix
* Require string conversion for all values
### 2.1.2
### 2.1.2 - 2012-06-19
* enhancements
* Handle backwards incompatibility between Rails 3.2.6 and Thor 0.15.x
@@ -221,7 +335,7 @@ Security announcement: http://blog.plataformatec.com.br/2013/01/security-announc
* bug fix
* Fix regression on strategy validation on previous release
### 2.1.1 (yanked)
### 2.1.1 - 2012-06-15 (yanked)
* enhancements
* `sign_out_all_scopes` now locks warden and does not allow new logins in the same action
@@ -238,7 +352,7 @@ Security announcement: http://blog.plataformatec.com.br/2013/01/security-announc
* deprecations
* Strategy#validate() no longer validates nil resources
### 2.1.0
### 2.1.0 - 2012-05-15
* enhancements
* Add `check_fields!(model_class)` method on Devise::Models to check if the model includes the fields that Devise uses
@@ -265,7 +379,7 @@ Security announcement: http://blog.plataformatec.com.br/2013/01/security-announc
* Return `head :no_content` in SessionsController now that most JS libraries handle it (by @julianvargasalvarez)
* Reverted moving devise/shared/_links.erb to devise/_links.erb
### 2.0.4
### 2.0.4 - 2012-02-17
Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.0
@@ -273,7 +387,7 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
* Fix when :host is used with devise_for (by @mreinsch)
* Fix a regression that caused Warden to be initialized too late
### 2.0.3 (yanked)
### 2.0.3 - 2012-06-16 (yanked)
* bug fix
* Ensure warning is not shown by mistake on apps with mounted engines
@@ -281,7 +395,7 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
* Ensure serializable_hash does not depend on accessible attributes
* Ensure that timeout callback does not run on sign out action
### 2.0.2
### 2.0.2 - 2012-02-14
* enhancements
* Add devise_i18n_options to customize I18n message
@@ -293,7 +407,7 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
* Show a warning in case someone gives a pluralized name to devise generator
* Fix test behavior for rspec subject requests (by @sj26)
### 2.0.1
### 2.0.1 - 2012-02-09
* enhancements
* Improved error messages on deprecation warnings
@@ -302,7 +416,7 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
* bug fix
* Removed tmp and log files from gem
### 2.0.0
### 2.0.0 - 2012-01-26
* enhancements
* Add support for e-mail reconfirmation on change (by @Mandaryn and @heimidal)
@@ -328,14 +442,14 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
* Deprecated support to devise.registrations.reasons and devise.registrations.inactive_signed_up in favor of devise.registrations.signed_up_but_*
* Protected method render_with_scope was removed.
### 1.5.3
### 1.5.3 - 2011-12-19
* bug fix
* Ensure delegator converts scope to symbol (by @dmitriy-kiriyenko)
* Ensure passing :format => false to devise_for is not permanent
* Ensure path checker does not check invalid routes
### 1.5.2
### 1.5.2 - 2011-11-30
* enhancements
* Add support for Rails 3.1 new mass assignment conventions (by @kirs)
@@ -344,12 +458,12 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
* bug fix
* OmniAuth error message now shows the proper option (:strategy_class instead of :klass)
### 1.5.1
### 1.5.1 - 2011-11-22
* bug fix
* Devise should not attempt to load OmniAuth strategies. Strategies should be loaded before hand by the developer or explicitly given to Devise.
### 1.5.0
### 1.5.0 - 2011-11-13
* enhancements
* Timeoutable also skips tracking if skip_trackable is given
@@ -370,12 +484,12 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
* redirect_location is deprecated, please use after_sign_in_path_for
* after_sign_in_path_for now redirects to session[scope_return_to] if any value is stored in it
### 1.4.9
### 1.4.9 - 2011-10-19
* bug fix
* url helpers were not being set under some circumstances
### 1.4.8
### 1.4.8 - 2011-10-09
* enhancements
* Add docs for assets pipeline and Heroku
@@ -383,12 +497,12 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
* bug fix
* confirmation_url was not being set under some circumstances
### 1.4.7
### 1.4.7 - 2011-09-21
* bug fix
* Fix backward incompatible change from 1.4.6 for those using custom controllers
### 1.4.6 (yanked)
### 1.4.6 - 2011-09-19 (yanked)
* enhancements
* Allow devise_for :skip => :all
@@ -396,7 +510,7 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
* Allow --skip-routes to devise generator
* Add allow_params_authentication! to make it explicit when params authentication is allowed in a controller
### 1.4.5
### 1.4.5 - 2011-09-07
* bug fix
* Failure app tries the root path if a session one does not exist
@@ -404,12 +518,12 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
* Reset password shows proper message if user is not active
* `clean_up_passwords` sets the accessors to nil to skip validations
### 1.4.4
### 1.4.4 - 2011-08-30
* bug fix
* Do not always skip helpers, instead provide :skip_helpers as option to trigger it manually
### 1.4.3
### 1.4.3 - 2011-08-29
* enhancements
* Improve Rails 3.1 compatibility
@@ -425,12 +539,12 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
* deprecations
* Loosened the used email regexp to simply assert the existent of "@". If someone relies on a more strict regexp, they may use https://github.com/SixArm/sixarm_ruby_email_address_validation
### 1.4.2
### 1.4.2 - 2011-06-30
* bug fix
* Provide a more robust behavior to serializers and add :force_except option
### 1.4.1
### 1.4.1 - 2011-06-29
* enhancements
* Add :defaults and :format support on router
@@ -441,7 +555,7 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
* Ensure to_xml is properly white listened
* Ensure handle_unverified_request clean up any cached signed-in user
### 1.4.0
### 1.4.0 - 2011-06-23
* enhancements
* Added authenticated and unauthenticated to the router to route the used based on their status (by @sj26)
@@ -459,22 +573,22 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
* Devise now honors routes constraints (by @macmartine)
* Do not return the user resource when requesting instructions (by @rodrigoflores)
### 1.3.4
### 1.3.4 - 2011-04-28
* bug fix
* Do not add formats if html or "*/*"
### 1.3.3
### 1.3.3 - 2011-04-20
* bug fix
* Explicitly mark the token as expired if so
### 1.3.2
### 1.3.2 - 2011-04-20
* bug fix
* Fix another regression related to reset_password_sent_at (by @alexdreher)
### 1.3.1
### 1.3.1 - 2011-04-18
* enhancements
* Improve failure_app responses (by @indirect)
@@ -483,7 +597,7 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
* bug fix
* Fix a regression that occurred if reset_password_sent_at is not present (by @stevehodgkiss)
### 1.3.0
### 1.3.0 - 2011-04-15
* enhancements
* All controllers can now handle different mime types than html using Responders (by @sikachu)
@@ -503,19 +617,19 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
* backward incompatible changes
* authentication_keys are no longer considered when creating the e-mail validations, the previous behavior was buggy. You must double check if you were relying on such behavior.
### 1.2.1
### 1.2.1 - 2011-03-27
* enhancements
* Improve update path messages
### 1.2.0
### 1.2.0 - 2011-03-24
* bug fix
* Properly ignore path prefix on omniauthable
* Faster uniqueness queries
* Rename active? to active_for_authentication? to avoid conflicts
### 1.2.rc2
### 1.2.rc2 - 2011-03-10
* enhancements
* Make friendly_token 20 chars long
@@ -545,7 +659,7 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
* Removed --haml and --slim view templates
* Devise::OmniAuth helpers were deprecated and removed in favor of Omniauth.config.test_mode
### 1.2.rc
### 1.2.rc - 2010-10-25
* deprecations
* cookie_domain is deprecated in favor of cookie_options
@@ -583,13 +697,13 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
* Ensure namespaces has proper scoped views
* Ensure Devise does not set empty flash messages (by @sxross)
### 1.1.6
### 1.1.6 - 2011-02-14
* Use a more secure e-mail regexp
* Implement Rails 3.0.4 handle unverified request
* Use secure_compare to compare passwords
### 1.1.5
### 1.1.5 - 2010-11-26
* bugfix
* Ensure to convert keys on indifferent hash
@@ -597,12 +711,12 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
* defaults
* Set config.http_authenticatable to false to avoid confusion
### 1.1.4
### 1.1.4 - 2010-11-25
* bugfix
* Avoid session fixation attacks
### 1.1.3
### 1.1.3 - 2010-09-23
* bugfix
* Add reply-to to e-mail headers by default
@@ -613,17 +727,17 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
* Fix for failed first-ever logins on PostgreSQL where column default is nil (by @bensie)
* :default options is now honored in migrations
### 1.1.2
### 1.1.2 - 2010-08-25
* bugfix
* Compatibility with latest Rails routes schema
### 1.1.1
### 1.1.1 - 2010-07-26
* bugfix
* Fix a small bug where generated locale file was empty on devise:install
### 1.1.0
### 1.1.0 - 2010-07-25
* enhancements
* Rememberable module allows user to be remembered across browsers and is enabled by default (by @trevorturk)
@@ -643,7 +757,7 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
* deprecations
* use_default_scope is deprecated and has no effect. Use :as or :devise_scope in the router instead
### 1.1.rc2
### 1.1.rc2 - 2010-06-22
* enhancements
* Allow to set cookie domain for the remember token. (by @mantas)
@@ -661,7 +775,7 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
* devise.mailer.user.confirmations_instructions now should be devise.mailer.confirmations_instructions.user_subject
* Generators now use Rails 3 syntax (devise:install) instead of devise_install
### 1.1.rc1
### 1.1.rc1 - 2010-04-14
* enhancements
* Rails 3 compatibility
@@ -693,7 +807,7 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
* All messages under devise.sessions, except :signed_in and :signed_out, should be moved to devise.failure
* :as and :scope in routes is deprecated. Use :path and :singular instead
### 1.0.8
### 1.0.8 - 2010-06-22
* enhancements
* Support for latest MongoMapper
@@ -702,7 +816,7 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
* bug fix
* confirmation_required? is properly honored on active? calls. (by @paulrosania)
### 1.0.7
### 1.0.7 - 2010-05-02
* bug fix
* Ensure password confirmation is always required
@@ -711,14 +825,14 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
* authenticatable was deprecated and renamed to database_authenticatable
* confirmable is not included by default on generation
### 1.0.6
### 1.0.6 - 2010-04-02
* bug fix
* Do not allow unlockable strategies based on time to access a controller.
* Do not send unlockable email several times.
* Allow controller to upstram custom! failures to Warden.
### 1.0.5
### 1.0.5 - 2010-03-25
* bug fix
* Use prepend_before_filter in require_no_authentication.
@@ -726,19 +840,19 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
* Fix a bug when giving an association proxy to devise.
* Do not use lock! on lockable since it's part of ActiveRecord API.
### 1.0.4
### 1.0.4 - 2010-03-02
* bug fix
* Fixed a bug when deleting an account with rememberable
* Fixed a bug with custom controllers
### 1.0.3
### 1.0.3 - 2010-02-22
* enhancements
* HTML e-mails now have proper formatting
* Do not remove MongoMapper options in find
### 1.0.2
### 1.0.2 - 2010-02-17
* enhancements
* Allows you set mailer content type (by @glennr)
@@ -746,7 +860,7 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
* bug fix
* Uses the same content type as request on http authenticatable 401 responses
### 1.0.1
### 1.0.1 - 2010-02-16
* enhancements
* HttpAuthenticatable is not added by default automatically.
@@ -755,7 +869,7 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
* bug fix
* Fixed encryptors autoload
### 1.0.0
### 1.0.0 - 2010-02-08
* deprecation
* :old_password in update_with_password is deprecated, use :current_password instead
@@ -766,7 +880,7 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
* Allow scoped_views to be customized per controller/mailer class
* Allow authenticatable to used in change_table statements
### 0.9.2
### 0.9.2 - 2010-02-04
* bug fix
* Ensure inactive user cannot sign in
@@ -776,13 +890,13 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
* Added gemspec to repo
* Added token authenticatable (by @grimen)
### 0.9.1
### 0.9.1 - 2010-01-24
* bug fix
* Allow bigger salt size (by @jgeiger)
* Fix relative url root
### 0.9.0
### 0.9.0 - 2010-01-20
* deprecation
* devise :all is deprecated
@@ -799,7 +913,7 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
* Accept path prefix not starting with slash
* url helpers should rely on find_scope!
### 0.8.2
### 0.8.2 - 2010-01-12
* enhancements
* Allow Devise.mailer_sender to be a proc (by @grimen)
@@ -807,7 +921,7 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
* bug fix
* Fix bug with passenger, update is required to anyone deploying on passenger (by @dvdpalm)
### 0.8.1
### 0.8.1 - 2010-01-07
* enhancements
* Move salt to encryptors
@@ -817,7 +931,7 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
* bug fix
* Bcrypt generator was not being loaded neither setting the proper salt
### 0.8.0
### 0.8.0 - 2010-01-06
* enhancements
* Warden 0.8.0 compatibility
@@ -831,19 +945,19 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
* deprecation
* Removed DeviseMailer.sender
### 0.7.5
### 0.7.5 - 2010-01-01
* enhancements
* Set a default value for mailer to avoid find_template issues
* Add models configuration to MongoMapper::EmbeddedDocument as well
### 0.7.4
### 0.7.4 - 2009-12-21
* enhancements
* Extract Activatable from Confirmable
* Decouple Serializers from Devise modules
### 0.7.3
### 0.7.3 - 2009-12-15
* bug fix
* Give scope to the proper model validation
@@ -853,7 +967,7 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
* Added update_with_password for authenticatable
* Allow render_with_scope to accept :controller option
### 0.7.2
### 0.7.2 - 2009-12-14
* deprecation
* Renamed reset_confirmation! to resend_confirmation!
@@ -863,12 +977,12 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
* Fixed render_with_scope to work with all controllers
* Allow sign in with two different users in Devise::TestHelpers
### 0.7.1
### 0.7.1 - 2009-12-09
* enhancements
* Small enhancements for other plugins compatibility (by @grimen)
### 0.7.0
### 0.7.0 - 2009-12-08
* deprecations
* :authenticatable is not included by default anymore
@@ -877,25 +991,25 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
* Improve loading process
* Extract SessionSerializer from Authenticatable
### 0.6.3
### 0.6.3 - 2009-12-02
* bug fix
* Added trackable to migrations
* Allow inflections to work
### 0.6.2
### 0.6.2 - 2009-11-25
* enhancements
* More DataMapper compatibility
* Devise::Trackable - track sign in count, timestamps and ips
### 0.6.1
### 0.6.1 - 2009-11-24
* enhancements
* Devise::Timeoutable - timeout sessions without activity
* DataMapper now accepts conditions
### 0.6.0
### 0.6.0 - 2009-11-22
* deprecations
* :authenticatable is still included by default, but yields a deprecation warning
@@ -906,19 +1020,19 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
* Allow a strategy to be placed after authenticatable
* Do not rely attribute? methods, since they are not added on Datamapper
### 0.5.6
### 0.5.6 - 2009-11-21
* enhancements
* Do not send nil to build (DataMapper compatibility)
* Allow to have scoped views
### 0.5.5
### 0.5.5 - 2009-11-20
* enhancements
* Allow overwriting find for authentication method
* Remove Ruby 1.8.7 dependency
### 0.5.4
### 0.5.4 - 2009-11-19
* deprecations
* Deprecate :singular in devise_for and use :scope instead
@@ -929,7 +1043,7 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
* Create sign_in_and_redirect and sign_out_and_redirect helpers
* Warden::Manager.default_scope is automatically configured to the first given scope
### 0.5.3
### 0.5.3 - 2009-11-18
* bug fix
* MongoMapper now converts DateTime to Time
@@ -941,20 +1055,20 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
* Added Devise.apply_schema, so you can turn it to false in Datamapper or MongoMapper
in cases you don't want it be handlded automatically
### 0.5.2
### 0.5.2 - 2009-11-17
* enhancements
* Improved sign_in and sign_out helpers to accepts resources
* Added stored_location_for as a helper
* Added test helpers
### 0.5.1
### 0.5.1 - 2009-11-15
* enhancements
* Added serializers based on Warden ones
* Allow authentication keys to be set
### 0.5.0
### 0.5.0 - 2009-11-13
* bug fix
* Fixed a bug where remember me module was not working properly
@@ -964,13 +1078,13 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
* Implemented encryptors for Clearance, Authlogic and Restful-Authentication (by @mhfs)
* Added support for MongoMapper (by @shingara)
### 0.4.3
### 0.4.3 - 2009-11-10
* bug fix
* Authentication just fails if user cannot be serialized from session, without raising errors;
* Default configuration values should not overwrite user values;
### 0.4.2
### 0.4.2 - 2009-11-06
* deprecations
* Renamed mail_sender to mailer_sender
@@ -982,12 +1096,12 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
* Allow :path_prefix to be given to devise_for
* Allow default_url_options to be configured through devise (:path_prefix => "/:locale" is now supported)
### 0.4.1
### 0.4.1 - 2009-11-04
* bug fix
* Ensure options can be set even if models were not loaded
### 0.4.0
### 0.4.0 - 2009-11-03
* deprecations
* Notifier is deprecated, use DeviseMailer instead. Remember to rename
@@ -1000,7 +1114,7 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
* Allow Warden::Manager to be configured through Devise
* Created a generator which creates an initializer
### 0.3.0
### 0.3.0 - 2009-10-30
* bug fix
* Allow yml messages to be configured by not using engine locales
@@ -1010,7 +1124,7 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
* Do not send confirmation messages when user changes their e-mail
* Renamed authenticable to authenticatable and added deprecation warnings
### 0.2.3
### 0.2.3 - 2009-10-29
* enhancements
* Ensure fail! works inside strategies
@@ -1020,12 +1134,12 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
* Do not redirect on invalid authenticate
* Allow model configuration to be set to nil
### 0.2.2
### 0.2.2 - 2009-10-28
* bug fix
* Fix a bug when using customized resources
### 0.2.1
### 0.2.1 - 2009-10-27
* refactor
* Clean devise_views generator to use devise existing views
@@ -1037,7 +1151,7 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
* bug fix
* Fix a bug with Mongrel and Ruby 1.8.6
### 0.2.0
### 0.2.0 - 2009-10-24
* enhancements
* Allow option :null => true in authenticable migration
@@ -1052,12 +1166,12 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
* bug fixes
* Fixed requiring devise strategies
### 0.1.1
### 0.1.1 - 2009-10-21
* bug fixes
* Fixed requiring devise mapping
### 0.1.0
### 0.1.0 - 2009-10-21
* Devise::Authenticable
* Devise::Confirmable

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,10 +2,11 @@ source "https://rubygems.org"
gemspec
gem "rails", "~> 4.1.0"
gem "rails", "4.2.2"
gem "omniauth", "~> 1.2.0"
gem "omniauth-oauth2", "~> 1.1.0"
gem "rdoc"
gem "mime-types", "~> 2.99"
group :test do
gem "omniauth-facebook"
@@ -25,5 +26,5 @@ platforms :ruby do
end
group :mongoid do
gem "mongoid", "~> 4.0.0"
gem "mongoid", "~> 4.0"
end

View File

@@ -1,78 +1,91 @@
PATH
remote: .
specs:
devise (3.3.0)
devise (3.5.9)
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:
actionmailer (4.1.4)
actionpack (= 4.1.4)
actionview (= 4.1.4)
mail (~> 2.5.4)
actionpack (4.1.4)
actionview (= 4.1.4)
activesupport (= 4.1.4)
rack (~> 1.5.2)
actionmailer (4.2.2)
actionpack (= 4.2.2)
actionview (= 4.2.2)
activejob (= 4.2.2)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 1.0, >= 1.0.5)
actionpack (4.2.2)
actionview (= 4.2.2)
activesupport (= 4.2.2)
rack (~> 1.6)
rack-test (~> 0.6.2)
actionview (4.1.4)
activesupport (= 4.1.4)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.1)
actionview (4.2.2)
activesupport (= 4.2.2)
builder (~> 3.1)
erubis (~> 2.7.0)
activemodel (4.1.4)
activesupport (= 4.1.4)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.1)
activejob (4.2.2)
activesupport (= 4.2.2)
globalid (>= 0.3.0)
activemodel (4.2.2)
activesupport (= 4.2.2)
builder (~> 3.1)
activerecord (4.1.4)
activemodel (= 4.1.4)
activesupport (= 4.1.4)
arel (~> 5.0.0)
activesupport (4.1.4)
i18n (~> 0.6, >= 0.6.9)
activerecord (4.2.2)
activemodel (= 4.2.2)
activesupport (= 4.2.2)
arel (~> 6.0)
activesupport (4.2.2)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
arel (5.0.1.20140414130214)
bcrypt (3.1.7)
bson (2.3.0)
arel (6.0.3)
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.5.4)
mime-types (~> 1.16)
treetop (~> 1.4.8)
globalid (0.3.6)
activesupport (>= 4.1.0)
hashie (3.4.3)
i18n (0.7.0)
json (1.8.3)
jwt (1.5.4)
loofah (2.0.3)
nokogiri (>= 1.5.9)
mail (2.6.4)
mime-types (>= 1.16, < 4)
metaclass (0.0.4)
mime-types (1.25.1)
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.3)
multi_xml (0.5.5)
multipart-post (2.0.0)
nokogiri (1.6.3.1)
mini_portile (= 0.6.0)
nokogiri (1.6.7.2)
mini_portile2 (~> 2.0.0.rc2)
oauth2 (0.9.4)
faraday (>= 0.8, < 0.10)
jwt (~> 1.0)
@@ -93,53 +106,57 @@ GEM
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)
polyglot (0.3.5)
rack (1.5.2)
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.1.4)
actionmailer (= 4.1.4)
actionpack (= 4.1.4)
actionview (= 4.1.4)
activemodel (= 4.1.4)
activerecord (= 4.1.4)
activesupport (= 4.1.4)
rails (4.2.2)
actionmailer (= 4.2.2)
actionpack (= 4.2.2)
actionview (= 4.2.2)
activejob (= 4.2.2)
activemodel (= 4.2.2)
activerecord (= 4.2.2)
activesupport (= 4.2.2)
bundler (>= 1.3.0, < 2.0)
railties (= 4.1.4)
sprockets-rails (~> 2.0)
railties (4.1.4)
actionpack (= 4.1.4)
activesupport (= 4.1.4)
railties (= 4.2.2)
sprockets-rails
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 (4.2.2)
actionpack (= 4.2.2)
activesupport (= 4.2.2)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.3.2)
rdoc (4.1.1)
rake (11.1.2)
rdoc (4.2.2)
json (~> 1.4)
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)
responders (2.2.0)
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.4)
tilt (1.4.1)
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
tzinfo (1.2.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)
@@ -154,13 +171,17 @@ DEPENDENCIES
activerecord-jdbcsqlite3-adapter
devise!
jruby-openssl
mime-types (~> 2.99)
mocha (~> 1.1)
mongoid (~> 4.0.0)
mongoid (~> 4.0)
omniauth (~> 1.2.0)
omniauth-facebook
omniauth-oauth2 (~> 1.1.0)
omniauth-openid (~> 1.0.1)
rails (~> 4.1.0)
rails (= 4.2.2)
rdoc
sqlite3
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-2015 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

132
README.md
View File

@@ -2,8 +2,9 @@
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)
[![Build Status](https://api.travis-ci.org/plataformatec/devise.svg?branch=master)](http://travis-ci.org/plataformatec/devise)
[![Code Climate](https://codeclimate.com/github/plataformatec/devise.svg)](https://codeclimate.com/github/plataformatec/devise)
[![Security](https://hakiri.io/github/plataformatec/devise/master.svg)](https://hakiri.io/github/plataformatec/devise/master)
This README is [also available in a friendly navigable format](http://devise.plataformatec.com.br/).
@@ -12,18 +13,18 @@ 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.
* [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.
@@ -43,7 +44,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
@@ -81,12 +82,13 @@ 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
@@ -104,7 +106,7 @@ 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
@@ -120,7 +122,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
@@ -150,7 +152,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"
@@ -178,19 +180,19 @@ The Devise method in your models also accepts some options to configure its modu
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
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 the permitted parameters by default are:
* `sign_in` (`Devise::SessionsController#new`) - Permits only the authentication keys (like `email`)
* `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
@@ -214,7 +216,7 @@ def configure_permitted_parameters
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
@@ -225,7 +227,7 @@ For the list of permitted scalars, and how to declare permitted keys in nested h
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
@@ -271,7 +273,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
@@ -282,29 +284,39 @@ rails generate devise:views -v registrations confirmations
If the customization at the views level is not enough, you can customize each controller by following these steps:
1. Create your custom controller, for example a `Admins::SessionsController`:
1. Create your custom controllers using the generator which requires a scope:
```ruby
class Admins::SessionsController < Devise::SessionsController
end
```console
rails generate devise:controllers [scope]
```
Note that in the above example, the controller needs to be created in the `app/controllers/admins/` directory.
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 Users::SessionsController < Devise::SessionsController
# GET /resource/sign_in
# def new
# super
# end
...
end
```
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
@@ -314,7 +326,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)
@@ -325,7 +337,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
@@ -337,7 +349,7 @@ devise_for :users, path: "auth", path_names: { sign_in: 'login', sign_out: 'logo
Be sure to check `devise_for` documentation 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
@@ -345,11 +357,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:
@@ -387,7 +399,7 @@ 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
@@ -399,7 +411,7 @@ class ActionController::TestCase
end
```
If you're using RSpec, you can put the following inside a file named `spec/support/devise.rb` or in your `spec/spec_helper.rb`:
If you're using RSpec, you can put the following inside a file named `spec/support/devise.rb` or in your `spec/spec_helper.rb` (or `spec/rails_helper.rb` if you are using rspec-rails):
```ruby
RSpec.configure do |config|
@@ -407,6 +419,8 @@ RSpec.configure do |config|
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
@@ -421,22 +435,26 @@ 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;
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
@@ -449,7 +467,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
@@ -469,17 +487,43 @@ 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 queuing back-end, you can send Devise emails through your
existing queue by overriding the `send_devise_notification` method in your model.
```ruby
def send_devise_notification(notification, *args)
devise_mailer.send(notification, self, *args).deliver_later
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
@@ -501,6 +545,6 @@ https://github.com/plataformatec/devise/graphs/contributors
## License
MIT License. Copyright 2009-2014 Plataformatec. http://plataformatec.com.br
MIT License. Copyright 2009-2015 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

@@ -33,7 +33,7 @@ class Devise::ConfirmationsController < DeviseController
# The path used after resending confirmation instructions.
def after_resending_confirmation_instructions_path_for(resource_name)
new_session_path(resource_name) if is_navigational_format?
is_navigational_format? ? new_session_path(resource_name) : '/'
end
# The path used after confirmation.
@@ -44,4 +44,8 @@ class Devise::ConfirmationsController < DeviseController
new_session_path(resource_name)
end
end
def translation_scope
'devise.confirmations'
end
end

View File

@@ -27,4 +27,8 @@ class Devise::OmniauthCallbacksController < DeviseController
def after_omniauth_failure_path_for(scope)
new_session_path(scope)
end
def translation_scope
'devise.omniauth_callbacks'
end
end

View File

@@ -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) if is_flashing_format?
sign_in(resource_name, resource)
else
set_flash_message(:notice, :updated_not_active) if is_flashing_format?
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 :require_no_authentication, only: [:new, :create, :cancel]
prepend_before_filter :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,9 +14,9 @@ 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?
sign_up(resource_name, resource)
@@ -30,10 +28,7 @@ class Devise::RegistrationsController < DeviseController
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
@@ -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,13 +1,14 @@
class Devise::SessionsController < DeviseController
prepend_before_filter :require_no_authentication, only: [ :new, :create ]
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_filter 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
@@ -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.

View File

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

@@ -6,12 +6,28 @@ class DeviseController < Devise.parent_controller.constantize
helpers = %w(resource scope_name resource_name signed_in_resource
resource_class resource_params devise_mapping)
hide_action(*helpers)
helper_method(*helpers)
prepend_before_filter :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 +54,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
@@ -129,8 +129,11 @@ MESSAGE
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 setup 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 +147,18 @@ 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 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 +167,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 +194,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" %>

View File

@@ -9,10 +9,10 @@ en:
failure:
already_authenticated: "You are already signed in."
inactive: "Your account is not activated yet."
invalid: "Invalid email or password."
invalid: "Invalid %{authentication_keys} or password."
locked: "Your account is locked."
last_attempt: "You have one more attempt before your account is locked."
not_found_in_database: "Invalid email address or password."
not_found_in_database: "Invalid %{authentication_keys} or password."
timeout: "Your session expired. Please sign in again to continue."
unauthenticated: "You need to sign in or sign up before continuing."
unconfirmed: "You have to confirm your email address before continuing."
@@ -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,15 +13,15 @@ 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 = '>= 1.9.3'
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("responders")
end

View File

@@ -1,14 +1,14 @@
GIT
remote: git://github.com/rails/rails.git
revision: 11fd052aa815ae0255ea5b2463e88138fb3fec61
revision: f85bbed4cdc1bdfd1e0dbd97bce9db81e44cbd11
branch: 3-2-stable
specs:
actionmailer (3.2.19)
actionpack (= 3.2.19)
actionmailer (3.2.22.2)
actionpack (= 3.2.22.2)
mail (~> 2.5.4)
actionpack (3.2.19)
activemodel (= 3.2.19)
activesupport (= 3.2.19)
actionpack (3.2.22.2)
activemodel (= 3.2.22.2)
activesupport (= 3.2.22.2)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.4)
@@ -16,31 +16,31 @@ GIT
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.2.1)
activemodel (3.2.19)
activesupport (= 3.2.19)
activemodel (3.2.22.2)
activesupport (= 3.2.22.2)
builder (~> 3.0.0)
activerecord (3.2.19)
activemodel (= 3.2.19)
activesupport (= 3.2.19)
activerecord (3.2.22.2)
activemodel (= 3.2.22.2)
activesupport (= 3.2.22.2)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activeresource (3.2.19)
activemodel (= 3.2.19)
activesupport (= 3.2.19)
activesupport (3.2.19)
activeresource (3.2.22.2)
activemodel (= 3.2.22.2)
activesupport (= 3.2.22.2)
activesupport (3.2.22.2)
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)
rails (3.2.22.2)
actionmailer (= 3.2.22.2)
actionpack (= 3.2.22.2)
activerecord (= 3.2.22.2)
activeresource (= 3.2.22.2)
activesupport (= 3.2.22.2)
bundler (~> 1.0)
railties (= 3.2.19)
railties (3.2.19)
actionpack (= 3.2.19)
activesupport (= 3.2.19)
railties (= 3.2.22.2)
railties (3.2.22.2)
actionpack (= 3.2.22.2)
activesupport (= 3.2.22.2)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
@@ -49,10 +49,11 @@ GIT
PATH
remote: ..
specs:
devise (3.3.0)
devise (3.5.8)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 3.2.6, < 5)
responders
thread_safe (~> 0.1)
warden (~> 1.2.3)
@@ -60,36 +61,36 @@ GEM
remote: https://rubygems.org/
specs:
arel (3.0.3)
bcrypt (3.1.7)
bcrypt (3.1.11)
builder (3.0.4)
erubis (2.7.0)
faraday (0.9.0)
faraday (0.9.2)
multipart-post (>= 1.2, < 3)
hashie (3.2.0)
hashie (3.4.3)
hike (1.2.3)
i18n (0.6.11)
i18n (0.7.0)
journey (1.0.4)
json (1.8.1)
jwt (1.0.0)
json (1.8.3)
jwt (1.5.4)
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)
mini_portile2 (2.0.0)
mocha (1.1.0)
metaclass (~> 0.0.1)
mongoid (3.1.6)
mongoid (3.1.7)
activemodel (~> 3.2)
moped (~> 1.4)
origin (~> 1.0)
tzinfo (~> 0.3.29)
moped (1.5.2)
multi_json (1.10.1)
moped (1.5.3)
multi_json (1.11.3)
multi_xml (0.5.5)
multipart-post (2.0.0)
nokogiri (1.6.3.1)
mini_portile (= 0.6.0)
nokogiri (1.6.7.2)
mini_portile2 (~> 2.0.0.rc2)
oauth2 (0.9.4)
faraday (>= 0.8, < 0.10)
jwt (~> 1.0)
@@ -112,34 +113,36 @@ GEM
origin (1.1.0)
orm_adapter (0.5.0)
polyglot (0.3.5)
rack (1.4.5)
rack-cache (1.2)
rack (1.4.7)
rack-cache (1.6.1)
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-test (0.6.3)
rack (>= 1.0)
rake (10.3.2)
rake (11.1.2)
rdoc (3.12.2)
json (~> 1.4)
ruby-openid (2.5.0)
sprockets (2.2.2)
responders (1.1.2)
railties (>= 3.2, < 4.2)
ruby-openid (2.7.0)
sprockets (2.2.3)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.9)
sqlite3 (1.3.11)
thor (0.19.1)
thread_safe (0.3.4)
thread_safe (0.3.5)
tilt (1.4.1)
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.40)
warden (1.2.3)
tzinfo (0.3.49)
warden (1.2.6)
rack (>= 1.0)
webrat (0.7.3)
nokogiri (>= 1.2.0)
@@ -164,3 +167,6 @@ DEPENDENCIES
rdoc
sqlite3
webrat (= 0.7.3)
BUNDLED WITH
1.11.2

View File

@@ -6,6 +6,7 @@ gem "rails", github: 'rails/rails', branch: '4-0-stable'
gem "omniauth", "~> 1.2.0"
gem "omniauth-oauth2", "~> 1.1.0"
gem "rdoc"
gem "mime-types", "~> 2.99"
group :test do
gem "omniauth-facebook"

View File

@@ -1,94 +1,95 @@
GIT
remote: git://github.com/rails/rails.git
revision: 6d95e04c6968fb7597ea5dbd08b31f271fb87c9c
revision: 9be9597e510d185ca7964d0a05b4ea2a7f2d50d1
branch: 4-0-stable
specs:
actionmailer (4.0.8)
actionpack (= 4.0.8)
actionmailer (4.0.13)
actionpack (= 4.0.13)
mail (~> 2.5, >= 2.5.4)
actionpack (4.0.8)
activesupport (= 4.0.8)
actionpack (4.0.13)
activesupport (= 4.0.13)
builder (~> 3.1.0)
erubis (~> 2.7.0)
rack (~> 1.5.2)
rack-test (~> 0.6.2)
activemodel (4.0.8)
activesupport (= 4.0.8)
activemodel (4.0.13)
activesupport (= 4.0.13)
builder (~> 3.1.0)
activerecord (4.0.8)
activemodel (= 4.0.8)
activerecord (4.0.13)
activemodel (= 4.0.13)
activerecord-deprecated_finders (~> 1.0.2)
activesupport (= 4.0.8)
activesupport (= 4.0.13)
arel (~> 4.0.0)
activesupport (4.0.8)
activesupport (4.0.13)
i18n (~> 0.6, >= 0.6.9)
minitest (~> 4.2)
multi_json (~> 1.3)
thread_safe (~> 0.1)
tzinfo (~> 0.3.37)
rails (4.0.8)
actionmailer (= 4.0.8)
actionpack (= 4.0.8)
activerecord (= 4.0.8)
activesupport (= 4.0.8)
rails (4.0.13)
actionmailer (= 4.0.13)
actionpack (= 4.0.13)
activerecord (= 4.0.13)
activesupport (= 4.0.13)
bundler (>= 1.3.0, < 2.0)
railties (= 4.0.8)
railties (= 4.0.13)
sprockets-rails (~> 2.0)
railties (4.0.8)
actionpack (= 4.0.8)
activesupport (= 4.0.8)
railties (4.0.13)
actionpack (= 4.0.13)
activesupport (= 4.0.13)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
PATH
remote: ..
specs:
devise (3.3.0)
devise (3.5.8)
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)
activerecord-deprecated_finders (1.0.4)
arel (4.0.2)
bcrypt (3.1.7)
bson (2.3.0)
bcrypt (3.1.11)
bson (3.2.6)
builder (3.1.4)
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)
mime-types (>= 1.16, < 3)
hashie (3.4.3)
i18n (0.7.0)
json (1.8.3)
jwt (1.5.4)
mail (2.6.4)
mime-types (>= 1.16, < 4)
metaclass (0.0.4)
mime-types (2.3)
mini_portile (0.6.0)
mime-types (2.99.1)
mini_portile2 (2.0.0)
minitest (4.7.5)
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.3)
multi_xml (0.5.5)
multipart-post (2.0.0)
nokogiri (1.6.3.1)
mini_portile (= 0.6.0)
nokogiri (1.6.7.2)
mini_portile2 (~> 2.0.0.rc2)
oauth2 (0.9.4)
faraday (>= 0.8, < 0.10)
jwt (~> 1.0)
@@ -109,33 +110,32 @@ GEM
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.1.2)
rdoc (4.2.2)
json (~> 1.4)
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)
responders (1.1.2)
railties (>= 3.2, < 4.2)
ruby-openid (2.7.0)
sprockets (3.6.0)
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)
thor (0.19.1)
thread_safe (0.3.4)
tilt (1.4.1)
tzinfo (0.3.40)
warden (1.2.3)
thread_safe (0.3.5)
tzinfo (0.3.49)
warden (1.2.6)
rack (>= 1.0)
webrat (0.7.3)
nokogiri (>= 1.2.0)
@@ -150,6 +150,7 @@ DEPENDENCIES
activerecord-jdbcsqlite3-adapter
devise!
jruby-openssl
mime-types (~> 2.99)
mocha (~> 1.1)
mongoid (~> 4.0.0)
omniauth (~> 1.2.0)
@@ -160,3 +161,6 @@ DEPENDENCIES
rdoc
sqlite3
webrat (= 0.7.3)
BUNDLED WITH
1.11.2

View File

@@ -2,13 +2,11 @@ source "https://rubygems.org"
gemspec path: '..'
gem "rails", github: "rails/rails"
gem "arel", github: "rails/arel"
gem "rack", github: "rack/rack"
gem "i18n", github: "svenfuchs/i18n"
gem "rails", github: 'rails/rails', branch: '4-1-stable'
gem "omniauth", "~> 1.2.0"
gem "omniauth-oauth2", "~> 1.1.0"
gem "rdoc"
gem "mime-types", "~> 2.99"
group :test do
gem "omniauth-facebook"
@@ -28,5 +26,5 @@ platforms :ruby do
end
group :mongoid do
gem "mongoid", github: "mongoid/mongoid", branch: "master"
gem "mongoid", "~> 4.0.0"
end

View File

@@ -0,0 +1,171 @@
GIT
remote: git://github.com/rails/rails.git
revision: 41b4d81b4fd14cbf43060c223bea0f461256d099
branch: 4-1-stable
specs:
actionmailer (4.1.15)
actionpack (= 4.1.15)
actionview (= 4.1.15)
mail (~> 2.5, >= 2.5.4)
actionpack (4.1.15)
actionview (= 4.1.15)
activesupport (= 4.1.15)
rack (~> 1.5.2)
rack-test (~> 0.6.2)
actionview (4.1.15)
activesupport (= 4.1.15)
builder (~> 3.1)
erubis (~> 2.7.0)
activemodel (4.1.15)
activesupport (= 4.1.15)
builder (~> 3.1)
activerecord (4.1.15)
activemodel (= 4.1.15)
activesupport (= 4.1.15)
arel (~> 5.0.0)
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.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.15)
sprockets-rails (~> 2.0)
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.5.8)
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 (5.0.1.20140414130214)
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)
hashie (3.4.3)
i18n (0.7.0)
json (1.8.3)
jwt (1.5.4)
mail (2.6.4)
mime-types (>= 1.16, < 4)
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.3)
multi_xml (0.5.5)
multipart-post (2.0.0)
nokogiri (1.6.7.2)
mini_portile2 (~> 2.0.0.rc2)
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.2.0)
orm_adapter (0.5.0)
rack (1.5.5)
rack-openid (1.3.1)
rack (>= 1.1.0)
ruby-openid (>= 2.1.8)
rack-test (0.6.3)
rack (>= 1.0)
rake (11.1.2)
rdoc (4.2.2)
json (~> 1.4)
responders (1.1.2)
railties (>= 3.2, < 4.2)
ruby-openid (2.7.0)
sprockets (3.6.0)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (2.3.3)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
sqlite3 (1.3.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)
PLATFORMS
ruby
DEPENDENCIES
activerecord-jdbc-adapter
activerecord-jdbcsqlite3-adapter
devise!
jruby-openssl
mime-types (~> 2.99)
mocha (~> 1.1)
mongoid (~> 4.0.0)
omniauth (~> 1.2.0)
omniauth-facebook
omniauth-oauth2 (~> 1.1.0)
omniauth-openid (~> 1.0.1)
rails!
rdoc
sqlite3
webrat (= 0.7.3)
BUNDLED WITH
1.11.2

View File

@@ -0,0 +1,30 @@
source "https://rubygems.org"
gemspec path: '..'
gem "rails", github: 'rails/rails', branch: '4-2-stable'
gem "omniauth", "~> 1.2.2"
gem "omniauth-oauth2", "~> 1.2.0"
gem "rdoc"
gem "mime-types", "~> 2.99"
group :test do
gem "omniauth-facebook"
gem "omniauth-openid", "~> 1.0.1"
gem "webrat", "0.7.3", require: false
gem "mocha", "~> 1.1", require: false
end
platforms :jruby do
gem "activerecord-jdbc-adapter"
gem "activerecord-jdbcsqlite3-adapter"
gem "jruby-openssl"
end
platforms :ruby do
gem "sqlite3"
end
group :mongoid do
gem "mongoid", "~> 4.0.0"
end

View File

@@ -0,0 +1,193 @@
GIT
remote: git://github.com/rails/rails.git
revision: 2a1b655bb7db42ed0dbadab5bb129a8515e86a40
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 (3.5.8)
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 (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.4)
mime-types (>= 1.16, < 4)
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.3)
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.2.2)
hashie (>= 1.2, < 4)
rack (~> 1.0)
omniauth-facebook (3.0.0)
omniauth-oauth2 (~> 1.2)
omniauth-oauth2 (1.2.0)
faraday (>= 0.8, < 0.10)
multi_json (~> 1.3)
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.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)
PLATFORMS
ruby
DEPENDENCIES
activerecord-jdbc-adapter
activerecord-jdbcsqlite3-adapter
devise!
jruby-openssl
mime-types (~> 2.99)
mocha (~> 1.1)
mongoid (~> 4.0.0)
omniauth (~> 1.2.2)
omniauth-facebook
omniauth-oauth2 (~> 1.2.0)
omniauth-openid (~> 1.0.1)
rails!
rdoc
sqlite3
webrat (= 0.7.3)
BUNDLED WITH
1.11.2

View File

@@ -1,190 +0,0 @@
GIT
remote: git://github.com/mongoid/mongoid.git
revision: 8cb17e9839973b76295cf87189e91a5ffcc03ab0
branch: master
specs:
mongoid (4.0.0)
activemodel (~> 4.0)
moped (~> 2.0.0)
origin (~> 2.1)
tzinfo (>= 0.3.37)
GIT
remote: git://github.com/rack/rack.git
revision: 92811eec6e86cb4dba52b3969c4dd66e639df158
specs:
rack (1.6.0.alpha)
GIT
remote: git://github.com/rails/arel.git
revision: 66cee768bc163537087037a583f60639eae49fc3
specs:
arel (6.0.0.20140505020427)
GIT
remote: git://github.com/rails/rails.git
revision: d5be08347fb7ff758572775ec93247a3ca886004
specs:
actionmailer (4.2.0.alpha)
actionpack (= 4.2.0.alpha)
actionview (= 4.2.0.alpha)
mail (~> 2.5, >= 2.5.4)
actionpack (4.2.0.alpha)
actionview (= 4.2.0.alpha)
activesupport (= 4.2.0.alpha)
rack (~> 1.6.0.alpha)
rack-test (~> 0.6.2)
actionview (4.2.0.alpha)
activesupport (= 4.2.0.alpha)
builder (~> 3.1)
erubis (~> 2.7.0)
activemodel (4.2.0.alpha)
activesupport (= 4.2.0.alpha)
builder (~> 3.1)
activerecord (4.2.0.alpha)
activemodel (= 4.2.0.alpha)
activesupport (= 4.2.0.alpha)
arel (~> 6.0.0)
activesupport (4.2.0.alpha)
i18n (>= 0.7.0.dev, < 0.8)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.1)
tzinfo (~> 1.1)
rails (4.2.0.alpha)
actionmailer (= 4.2.0.alpha)
actionpack (= 4.2.0.alpha)
actionview (= 4.2.0.alpha)
activemodel (= 4.2.0.alpha)
activerecord (= 4.2.0.alpha)
activesupport (= 4.2.0.alpha)
bundler (>= 1.3.0, < 2.0)
railties (= 4.2.0.alpha)
sprockets-rails (~> 2.1)
railties (4.2.0.alpha)
actionpack (= 4.2.0.alpha)
activesupport (= 4.2.0.alpha)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
GIT
remote: git://github.com/svenfuchs/i18n.git
revision: cb679b8cdbab675703a3f88de4d48a48f7b50e06
specs:
i18n (0.7.0.dev)
PATH
remote: ..
specs:
devise (3.3.0)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 3.2.6, < 5)
thread_safe (~> 0.1)
warden (~> 1.2.3)
GEM
remote: https://rubygems.org/
specs:
bcrypt (3.1.7)
bson (2.3.0)
builder (3.2.2)
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)
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 (5.4.0)
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)
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-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)
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 (1.2.1)
thread_safe (~> 0.1)
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
arel!
devise!
i18n!
jruby-openssl
mocha (~> 1.1)
mongoid!
omniauth (~> 1.2.0)
omniauth-facebook
omniauth-oauth2 (~> 1.1.0)
omniauth-openid (~> 1.0.1)
rack!
rails!
rdoc
sqlite3
webrat (= 0.7.3)

View File

@@ -4,9 +4,11 @@ require 'active_support/dependencies'
require 'orm_adapter'
require 'set'
require 'securerandom'
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'
@@ -56,22 +58,6 @@ 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 = {}
@@ -86,7 +72,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
@@ -94,7 +80,7 @@ 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
@@ -120,7 +106,7 @@ module Devise
# 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.
mattr_accessor :email_regexp
@@email_regexp = /\A[^@\s]+@([^@\s]+\.)+[^@\s]+\z/
@@email_regexp = /\A[^@\s]+@([^@\s]+\.)+[^@\W]+\z/
# Range validation for password length
mattr_accessor :password_length
@@ -149,7 +135,7 @@ 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.
@@ -160,14 +146,14 @@ module Devise
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.
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
@@ -180,7 +166,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
@@ -197,12 +183,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
@@ -245,7 +235,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
@@ -260,7 +250,7 @@ module Devise
mattr_reader :mappings
@@mappings = ActiveSupport::OrderedHash.new
# Omniauth configurations.
# OmniAuth configurations.
mattr_reader :omniauth_configs
@@omniauth_configs = ActiveSupport::OrderedHash.new
@@ -280,7 +270,7 @@ module Devise
# When true, warn user if they just used next-to-last attempt of authentication
mattr_accessor :last_attempt_warning
@@last_attempt_warning = false
@@last_attempt_warning = true
# Stores the token generator
mattr_accessor :token_generator
@@ -339,7 +329,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:
#
@@ -347,6 +342,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.
@@ -356,10 +352,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)
@@ -416,7 +414,7 @@ module Devise
@@warden_config_blocks << block
end
# Specify an omniauth provider.
# Specify an OmniAuth provider.
#
# config.omniauth :github, APP_ID, APP_SECRET
#
@@ -444,8 +442,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
@@ -473,8 +471,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
@@ -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
@@ -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
@@ -190,10 +196,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,

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, encrypted_password, password)
return false if encrypted_password.blank?
bcrypt = ::BCrypt::Password.new(encrypted_password)
if klass.pepper.present?
password = "#{password}#{klass.pepper}"
end
password = ::BCrypt::Engine.hash_secret(password, bcrypt.salt)
Devise.secure_compare(password, encrypted_password)
end
end
end

View File

@@ -22,9 +22,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 +51,31 @@ module Devise
end
def recall
env["PATH_INFO"] = attempted_path
flash.now[:alert] = i18n_message(:invalid)
config = Rails.application.config
if config.try(:relative_url_root)
base_path = Pathname.new(config.relative_url_root)
full_path = Pathname.new(attempted_path)
env["SCRIPT_NAME"] = config.relative_url_root
env["PATH_INFO"] = '/' + full_path.relative_path_from(base_path).to_s
else
env["PATH_INFO"] = attempted_path
end
flash.now[:alert] = i18n_message(:invalid) if is_flashing_format?
self.response = recall_app(warden_options[:recall]).call(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,6 +94,9 @@ module Devise
options[:resource_name] = scope
options[:scope] = "devise.failure"
options[:default] = [message]
auth_keys = scope_class.authentication_keys
keys = auth_keys.respond_to?(:keys) ? auth_keys.keys : auth_keys
options[:authentication_keys] = keys.join(I18n.translate(:"support.array.words_connector"))
options = i18n_options(options)
I18n.t(:"#{scope}.#{message}", options)
@@ -88,7 +107,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
@@ -102,15 +121,28 @@ 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)
# Rails 4.2 goes into an infinite loop if opts[:script_name] is unset
if (Rails::VERSION::MAJOR >= 4) && (Rails::VERSION::MINOR >= 2)
opts[:script_name] = (config.relative_url_root if config.respond_to?(:relative_url_root))
else
if config.respond_to?(:relative_url_root) && config.relative_url_root.present?
opts[:script_name] = config.relative_url_root
end
end
router_name = Devise.mappings[scope].router_name || Devise.available_router_name
context = send(router_name)
if context.respond_to?(route)
context.send(route, opts)
@@ -144,7 +176,7 @@ module Devise
# It does not make sense to send authenticate headers in ajax requests
# or if the user disabled them.
def http_auth_header?
Devise.mappings[scope].to.http_authenticatable && !request.xhr?
scope_class.http_authenticatable && !request.xhr?
end
def http_auth_body
@@ -182,6 +214,10 @@ module Devise
@scope ||= warden_options[:scope] || Devise.default_scope
end
def scope_class
@scope_class ||= Devise.mappings[scope].to
end
def attempted_path
warden_options[:attempted_path]
end
@@ -198,6 +234,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

@@ -31,9 +31,10 @@ 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
return obj.to_sym
when Class
Devise.mappings.each_value { |m| return m.name if obj <= m.to }
else

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
@@ -170,7 +164,13 @@ module Devise
# end
#
def send_devise_notification(notification, *args)
devise_mailer.send(notification, self, *args).deliver
message = devise_mailer.send(notification, self, *args)
# Remove once we move to Rails 4.2+ only.
if message.respond_to?(:deliver_now)
message.deliver_now
else
message.deliver
end
end
def downcase_keys
@@ -246,14 +246,14 @@ 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)
attributes = attributes.slice(*required_attributes).with_indifferent_access
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,15 +24,17 @@ 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 setup (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
#
@@ -56,7 +66,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,7 +74,6 @@ module Devise
return false
end
self.confirmation_token = nil
self.confirmed_at = Time.now.utc
saved = if self.class.reconfirmable && unconfirmed_email.present?
@@ -75,7 +84,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 +92,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
@@ -156,6 +170,7 @@ module Devise
# in models to map to a nice sign up e-mail.
def send_on_create_confirmation_instructions
send_confirmation_instructions
skip_reconfirmation!
end
# Callback to overwrite if confirmation is required or not.
@@ -202,7 +217,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 +231,15 @@ 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
raw, _ = Devise.token_generator.generate(self.class, :confirmation_token)
self.confirmation_token = @raw_confirmation_token = raw
self.confirmation_sent_at = Time.now.utc
end
end
def generate_confirmation_token!
@@ -232,6 +250,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 +261,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,12 +300,17 @@ 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

View File

@@ -1,10 +1,9 @@
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
@@ -13,7 +12,7 @@ module Devise
#
# == 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
@@ -42,12 +43,9 @@ module Devise
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,6 +135,10 @@ 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
@@ -145,11 +147,15 @@ module Devise
# See https://github.com/plataformatec/devise-encryptable for examples
# of other encryption 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

@@ -117,7 +117,7 @@ module Devise
super
elsif access_locked? || (lock_strategy_enabled?(:failed_attempts) && attempts_exceeded?)
:locked
elsif lock_strategy_enabled?(:failed_attempts) && last_attempt?
elsif lock_strategy_enabled?(:failed_attempts) && last_attempt? && self.class.last_attempt_warning
:last_attempt
else
super
@@ -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?
@@ -189,7 +193,7 @@ module Devise
self.lock_strategy == strategy
end
Devise::Models.config(self, :maximum_attempts, :lock_strategy, :unlock_strategy, :unlock_in, :unlock_keys)
Devise::Models.config(self, :maximum_attempts, :lock_strategy, :unlock_strategy, :unlock_in, :unlock_keys, :last_attempt_warning)
end
end
end

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,9 +94,6 @@ 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)
@@ -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,17 @@ 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)
# TODO: We were used to receive a extend period argument but we no longer do.
# Remove this for Devise 4.0.
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 +57,28 @@ 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)
remember_created_at.nil?
end
# Remember token expires at created time + remember_for configuration
def remember_expires_at
remember_created_at + self.class.remember_for
self.class.remember_for.from_now
end
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 +92,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

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

View File

@@ -94,10 +94,24 @@ module ActionDispatch::Routing
#
# 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: setup 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_filter 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 +133,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,21 +416,16 @@ 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
@@ -435,26 +444,23 @@ ERROR
match "#{path_prefix}/:action/callback",
constraints: { action: providers },
to: controllers[:omniauth_callbacks],
to: "#{controllers[:omniauth_callbacks]}#:action",
as: :omniauth_callback,
via: [:get, :post]
ensure
@scope[:path] = path
end
DEVISE_SCOPE_KEYS = [:as, :path, :module, :constraints, :defaults, :options]
def with_devise_exclusive_scope(new_path, new_as, options) #:nodoc:
old = {}
DEVISE_SCOPE_KEYS.each { |k| old[k] = @scope[k] }
current_scope = @scope.dup
new = { as: new_as, path: new_path, module: nil }
new.merge!(options.slice(:constraints, :defaults, :options))
exclusive = { as: new_as, path: new_path, module: nil }
exclusive.merge!(options.slice(:constraints, :defaults, :options))
@scope.merge!(new)
exclusive.each_pair { |key, value| @scope[key] = value }
yield
ensure
@scope.merge!(old)
@scope = current_scope
end
def constraints_for(method_to_apply, scope=nil, block=nil)

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
@@ -36,7 +36,6 @@ module Devise
result = resource && resource.valid_for_authentication?(&block)
if result
decorate(resource)
true
else
if resource
@@ -47,7 +46,7 @@ module Devise
end
# Get values from params and set in the resource.
def decorate(resource)
def remember_me(resource)
resource.remember_me = remember_me? if resource.respond_to?(:remember_me=)
end
@@ -58,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;
#
@@ -109,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,10 +5,11 @@ 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)
resource = password.present? && mapping.to.find_for_database_authentication(authentication_hash)
encrypted = false
if validate(resource){ encrypted = true; resource.valid_password?(password) }
remember_me(resource)
resource.after_database_authentication
success!(resource)
end

View File

@@ -25,15 +25,25 @@ module Devise
end
if validate(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 decorate(resource)
super
resource.extend_remember_period = mapping.to.extend_remember_period if resource.respond_to?(:extend_remember_period=)
def extend_remember_me?(resource)
resource.respond_to?(:extend_remember_period) && resource.extend_remember_period
end
def remember_me?

View File

@@ -26,11 +26,11 @@ module Devise
# 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

View File

@@ -1,3 +1,3 @@
module Devise
VERSION = "3.3.0".freeze
VERSION = "3.5.9".freeze
end

View File

@@ -83,7 +83,8 @@ RUBY
end
def postgresql?
ActiveRecord::Base.connection.adapter_name.downcase == "postgresql"
config = ActiveRecord::Base.configurations[Rails.env]
config && config['adapter'] == 'postgresql'
end
end
end

View File

@@ -7,7 +7,7 @@ class DeviseCreate<%= table_name.camelize %> < ActiveRecord::Migration
t.<%= attribute.type %> :<%= attribute.name %>
<% end -%>
t.timestamps
t.timestamps null: false
end
add_index :<%= table_name %>, :email, unique: true

View File

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

@@ -0,0 +1,44 @@
require 'rails/generators/base'
module Devise
module Generators
class ControllersGenerator < Rails::Generators::Base
CONTROLLERS = %w(confirmations passwords registrations sessions unlocks omniauth_callbacks).freeze
desc <<-DESC.strip_heredoc
Create inherited Devise controllers in your app/controllers folder.
Use -c to specify which controller you want to overwrite.
If you do no specify a controller, all controllers will be created.
For example:
rails generate devise:controllers users -c=sessions
This will create a controller class at app/controllers/users/sessions_controller.rb like this:
class Users::ConfirmationsController < Devise::ConfirmationsController
content...
end
DESC
source_root File.expand_path("../../templates/controllers", __FILE__)
argument :scope, required: true,
desc: "The scope to create controllers in, e.g. users, admins"
class_option :controllers, aliases: "-c", type: :array,
desc: "Select specific controllers to generate (#{CONTROLLERS.join(', ')})"
def create_controllers
@scope_prefix = scope.blank? ? '' : (scope.camelize + '::')
controllers = options[:controllers] || CONTROLLERS
controllers.each do |name|
template "#{name}_controller.rb",
"app/controllers/#{scope}/#{name}_controller.rb"
end
end
def show_readme
readme "README" if behavior == :invoke
end
end
end
end

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

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

View File

@@ -0,0 +1,28 @@
class <%= @scope_prefix %>ConfirmationsController < Devise::ConfirmationsController
# GET /resource/confirmation/new
# def new
# super
# end
# POST /resource/confirmation
# def create
# super
# end
# GET /resource/confirmation?confirmation_token=abcdef
# def show
# super
# end
# protected
# The path used after resending confirmation instructions.
# def after_resending_confirmation_instructions_path_for(resource_name)
# super(resource_name)
# end
# The path used after confirmation.
# def after_confirmation_path_for(resource_name, resource)
# super(resource_name, resource)
# end
end

View File

@@ -0,0 +1,28 @@
class <%= @scope_prefix %>OmniauthCallbacksController < Devise::OmniauthCallbacksController
# You should configure your model like this:
# devise :omniauthable, omniauth_providers: [:twitter]
# You should also create an action method in this controller like this:
# def twitter
# end
# More info at:
# https://github.com/plataformatec/devise#omniauth
# GET|POST /resource/auth/twitter
# def passthru
# super
# end
# GET|POST /users/auth/twitter/callback
# def failure
# super
# end
# protected
# The path used when OmniAuth fails
# def after_omniauth_failure_path_for(scope)
# super(scope)
# end
end

View File

@@ -0,0 +1,32 @@
class <%= @scope_prefix %>PasswordsController < Devise::PasswordsController
# GET /resource/password/new
# def new
# super
# end
# POST /resource/password
# def create
# super
# end
# GET /resource/password/edit?reset_password_token=abcdef
# def edit
# super
# end
# PUT /resource/password
# def update
# super
# end
# protected
# def after_resetting_password_path_for(resource)
# super(resource)
# end
# The path used after sending reset password instructions
# def after_sending_reset_password_instructions_path_for(resource_name)
# super(resource_name)
# end
end

View File

@@ -0,0 +1,60 @@
class <%= @scope_prefix %>RegistrationsController < Devise::RegistrationsController
# before_filter :configure_sign_up_params, only: [:create]
# before_filter :configure_account_update_params, only: [:update]
# GET /resource/sign_up
# def new
# super
# end
# POST /resource
# def create
# super
# end
# GET /resource/edit
# def edit
# super
# end
# PUT /resource
# def update
# super
# end
# DELETE /resource
# def destroy
# super
# end
# GET /resource/cancel
# Forces the session data which is usually expired after sign
# in to be expired now. This is useful if the user wants to
# cancel oauth signing in/up in the middle of the process,
# removing all OAuth session data.
# def cancel
# super
# end
# protected
# If you have extra params to permit, append them to the sanitizer.
# def configure_sign_up_params
# devise_parameter_sanitizer.for(:sign_up) << :attribute
# end
# If you have extra params to permit, append them to the sanitizer.
# def configure_account_update_params
# devise_parameter_sanitizer.for(:account_update) << :attribute
# end
# The path used after sign up.
# def after_sign_up_path_for(resource)
# super(resource)
# end
# The path used after sign up for inactive accounts.
# def after_inactive_sign_up_path_for(resource)
# super(resource)
# end
end

View File

@@ -0,0 +1,25 @@
class <%= @scope_prefix %>SessionsController < Devise::SessionsController
# before_filter :configure_sign_in_params, only: [:create]
# GET /resource/sign_in
# def new
# super
# end
# POST /resource/sign_in
# def create
# super
# end
# DELETE /resource/sign_out
# def destroy
# super
# end
# protected
# If you have extra params to permit, append them to the sanitizer.
# def configure_sign_in_params
# devise_parameter_sanitizer.for(:sign_in) << :attribute
# end
end

View File

@@ -0,0 +1,28 @@
class <%= @scope_prefix %>UnlocksController < Devise::UnlocksController
# GET /resource/unlock/new
# def new
# super
# end
# POST /resource/unlock
# def create
# super
# end
# GET /resource/unlock?unlock_token=abcdef
# def show
# super
# end
# protected
# The path used after sending unlock password instructions
# def after_sending_unlock_instructions_path_for(resource)
# super(resource)
# end
# The path used after unlocking the resource
# def after_unlock_path_for(resource)
# super(resource)
# end
end

View File

@@ -4,6 +4,8 @@ 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.
# Devise will use the `secret_key_base` on Rails 4+ applications as its `secret_key`
# by default. You can change it below and use your own secret key.
<% if rails_4? -%>
# config.secret_key = '<%= SecureRandom.hex(64) %>'
<% else -%>
@@ -33,7 +35,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 +47,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
@@ -65,7 +67,7 @@ Devise.setup do |config|
# :database = Support basic authentication with authentication key + password
# config.http_authenticatable = false
# If http headers should be returned for AJAX requests. True by default.
# If 401 status code should be returned for AJAX requests. True by default.
# config.http_authenticatable_on_xhr = true
# The realm used in Http Basic Authentication. 'Application' by default.
@@ -103,6 +105,9 @@ Devise.setup do |config|
# Setup a pepper to generate the encrypted 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 +131,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,7 +149,7 @@ Devise.setup do |config|
# ==> Configuration for :validatable
# Range for password length.
config.password_length = 8..128
config.password_length = 8..72
# Email regex used to validate email formats. It simply asserts that
# one (and only one) @ exists in the given string. This is mainly
@@ -156,9 +161,6 @@ Devise.setup do |config|
# 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 +168,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
@@ -183,18 +185,22 @@ Devise.setup do |config|
# config.unlock_in = 1.hour
# Warn on the last attempt before the account is locked.
# config.last_attempt_warning = false
# config.last_attempt_warning = true
# ==> 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,
@@ -257,7 +263,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 %>
<%= 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,4 +1,4 @@
<h2>Sign in</h2>
<h2>Log in</h2>
<%= simple_form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
<div class="form-inputs">
@@ -8,7 +8,7 @@
</div>
<div class="form-actions">
<%= f.button :submit, "Sign in" %>
<%= f.button :submit, "Log in" %>
</div>
<% end %>

View File

@@ -8,7 +8,7 @@ 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
@@ -32,4 +32,9 @@ class CustomRegistrationsControllerTest < ActionController::TestCase
put :update, { 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

@@ -0,0 +1,21 @@
require 'test_helper'
class ApiController < ActionController::Metal
include Devise::Controllers::Helpers
end
class HelperMethodsTest < ActionController::TestCase
tests ApiController
test 'includes Devise::Controllers::Helpers' do
assert_includes @controller.class.ancestors, Devise::Controllers::Helpers
end
test 'does not respond_to helper_method' do
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

@@ -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 < ActionController::TestCase
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 < ActionController::TestCase
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

@@ -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
@@ -80,7 +80,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 +99,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 < ActionController::TestCase
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

@@ -6,7 +6,7 @@ class PasswordsControllerTest < ActionController::TestCase
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

View File

@@ -36,7 +36,7 @@ class SessionsControllerTest < ActionController::TestCase
request.session["user_return_to"] = 'foo.bar'
user = create_user
user.confirm!
user.confirm
post :create, user: {
email: user.email,
password: user.password
@@ -50,7 +50,7 @@ class SessionsControllerTest < ActionController::TestCase
request.session["user_return_to"] = 'foo.bar'
user = create_user
user.confirm!
user.confirm
post :create, format: 'json', user: {
email: user.email,
password: user.password
@@ -72,7 +72,7 @@ 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!
user.confirm
post :create, format: 'json', user: {
email: user.email,
password: user.password

View File

@@ -13,6 +13,12 @@ class RoutesTest < ActionController::TestCase
assert_equal @controller.send(:"#{prepend_path}#{name}_url", :user),
send(:"#{prepend_path}user_#{name}_url")
# With string
assert_equal @controller.send(:"#{prepend_path}#{name}_path", "user"),
send(:"#{prepend_path}user_#{name}_path")
assert_equal @controller.send(:"#{prepend_path}#{name}_url", "user"),
send(:"#{prepend_path}user_#{name}_url")
# Default url params
assert_equal @controller.send(:"#{prepend_path}#{name}_path", :user, param: 123),
send(:"#{prepend_path}user_#{name}_path", param: 123)

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
@@ -95,7 +95,7 @@ class DeviseTest < ActiveSupport::TestCase
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"]
non_valid_emails = ["rex", "test@go,com", "test user@example.com", "test_user@example server.com", "test_user@example.com."]
valid_emails.each do |email|
assert_match Devise.email_regexp, email

View File

@@ -26,6 +26,22 @@ class FailureTest < ActiveSupport::TestCase
end
end
class FakeEngineApp < Devise::FailureApp
class FakeEngine
def new_user_on_engine_session_url _
'/user_on_engines/sign_in'
end
end
def main_app
raise 'main_app router called instead of fake_engine'
end
def fake_engine
@fake_engine ||= FakeEngine.new
end
end
def self.context(name, &block)
instance_eval(&block)
end
@@ -85,6 +101,13 @@ class FailureTest < ActiveSupport::TestCase
end
end
test 'returns to the default redirect location considering the router for supplied scope' do
call_failure app: FakeEngineApp, 'warden.options' => { scope: :user_on_engine }
assert_equal 302, @response.first
assert_equal 'You need to sign in or sign up before continuing.', @request.flash[:alert]
assert_equal 'http://test.host/user_on_engines/sign_in', @response.second['Location']
end
if Rails.application.config.respond_to?(:relative_url_root)
test 'returns to the default redirect location considering the relative url root' do
swap Rails.application.config, relative_url_root: "/sample" do
@@ -109,6 +132,13 @@ class FailureTest < ActiveSupport::TestCase
assert_equal 'http://test.host/users/sign_in', @response.second["Location"]
end
test 'supports authentication_keys as a Hash for the flash message' do
swap Devise, authentication_keys: { email: true, login: true } do
call_failure('warden' => OpenStruct.new(message: :invalid))
assert_equal 'Invalid email, login or password.', @request.flash[:alert]
end
end
test 'uses custom i18n options' do
call_failure('warden' => OpenStruct.new(message: :does_not_exist), app: FailureWithI18nOptions)
assert_equal 'User Steve does not exist', @request.flash[:alert]
@@ -264,5 +294,22 @@ class FailureTest < ActiveSupport::TestCase
assert @response.third.body.include?('<h2>Log in</h2>')
assert @response.third.body.include?('Your account is not activated yet.')
end
if Rails.application.config.respond_to?(:relative_url_root)
test 'calls the original controller with the proper environment considering the relative url root' do
swap Rails.application.config, relative_url_root: "/sample" do
env = {
"warden.options" => { recall: "devise/sessions#new", attempted_path: "/sample/users/sign_in"},
"devise.mapping" => Devise.mappings[:user],
"warden" => stub_everything
}
call_failure(env)
assert @response.third.body.include?('<h2>Log in</h2>')
assert @response.third.body.include?('Invalid email or password.')
assert_equal @request.env["SCRIPT_NAME"], '/sample'
assert_equal @request.env["PATH_INFO"], '/users/sign_in'
end
end
end
end
end

View File

@@ -0,0 +1,48 @@
require "test_helper"
class ControllersGeneratorTest < Rails::Generators::TestCase
tests Devise::Generators::ControllersGenerator
destination File.expand_path("../../tmp", __FILE__)
setup :prepare_destination
test "Assert no controllers are created with no params" do
capture(:stderr) { run_generator }
assert_no_file "app/controllers/sessions_controller.rb"
assert_no_file "app/controllers/registrations_controller.rb"
assert_no_file "app/controllers/confirmations_controller.rb"
assert_no_file "app/controllers/passwords_controller.rb"
assert_no_file "app/controllers/unlocks_controller.rb"
assert_no_file "app/controllers/omniauth_callbacks_controller.rb"
end
test "Assert all controllers are properly created with scope param" do
run_generator %w(users)
assert_class_names 'users'
run_generator %w(admins)
assert_class_names 'admins'
end
test "Assert specified controllers with scope" do
run_generator %w(users -c sessions)
assert_file "app/controllers/users/sessions_controller.rb"
assert_no_file "app/controllers/users/registrations_controller.rb"
assert_no_file "app/controllers/users/confirmations_controller.rb"
assert_no_file "app/controllers/users/passwords_controller.rb"
assert_no_file "app/controllers/users/unlocks_controller.rb"
assert_no_file "app/controllers/users/omniauth_callbacks_controller.rb"
end
private
def assert_class_names(scope, options = {})
base_dir = "app/controllers#{scope.blank? ? '' : ('/' + scope)}"
scope_prefix = scope.blank? ? '' : (scope.camelize + '::')
controllers = options[:controllers] ||
%w(confirmations passwords registrations sessions unlocks omniauth_callbacks)
controllers.each do |c|
assert_file "#{base_dir}/#{c}_controller.rb", /#{scope_prefix + c.camelize}/
end
end
end

View File

@@ -46,6 +46,13 @@ class ViewsGeneratorTest < Rails::Generators::TestCase
assert_no_file "app/views/devise/mailer/confirmation_instructions.html.erb"
end
test "Assert mailer specific directory with simple form" do
run_generator %w(-v mailer -b simple_form_for)
assert_file "app/views/devise/mailer/confirmation_instructions.html.erb"
assert_file "app/views/devise/mailer/reset_password_instructions.html.erb"
assert_file "app/views/devise/mailer/unlock_instructions.html.erb"
end
test "Assert specified directories with scope" do
run_generator %w(users -v sessions)
assert_file "app/views/users/sessions/new.html.erb"
@@ -78,7 +85,7 @@ class ViewsGeneratorTest < Rails::Generators::TestCase
assert_file "app/views/#{scope}/registrations/new.html.erb"
assert_file "app/views/#{scope}/registrations/edit.html.erb"
assert_file "app/views/#{scope}/sessions/new.html.erb"
assert_file "app/views/#{scope}/shared/_links.erb"
assert_file "app/views/#{scope}/shared/_links.html.erb"
assert_file "app/views/#{scope}/unlocks/new.html.erb"
end

View File

@@ -2,25 +2,22 @@ require 'test_helper'
class DeviseHelperTest < ActionDispatch::IntegrationTest
setup do
model_labels = { models: { user: "utilisateur" } }
# TODO: Remove this hack that fixes the I18n performance safeguards that
# breaks the custom locale.
I18n.available_locales += [:fr]
I18n.backend.store_translations :fr,
{
model_labels = { models: { user: "the user" } }
translations = {
errors: { messages: { not_saved: {
one: "Erreur lors de l'enregistrement de '%{resource}': 1 erreur.",
other: "Erreur lors de l'enregistrement de '%{resource}': %{count} erreurs."
one: "Can't save %{resource} because of 1 error",
other: "Can't save %{resource} because of %{count} errors",
} } },
activerecord: model_labels,
mongoid: model_labels
}
I18n.locale = 'fr'
I18n.available_locales
I18n.backend.store_translations(:en, translations)
end
teardown do
I18n.locale = 'en'
I18n.reload!
end
test 'test errors.messages.not_saved with single error from i18n' do
@@ -31,7 +28,7 @@ class DeviseHelperTest < ActionDispatch::IntegrationTest
click_button 'Sign up'
assert_have_selector '#error_explanation'
assert_contain "Erreur lors de l'enregistrement de 'utilisateur': 1 erreur"
assert_contain "Can't save the user because of 1 error"
end
test 'test errors.messages.not_saved with multiple errors from i18n' do
@@ -47,6 +44,6 @@ class DeviseHelperTest < ActionDispatch::IntegrationTest
click_button 'Sign up'
assert_have_selector '#error_explanation'
assert_contain "Erreur lors de l'enregistrement de 'utilisateur': 2 erreurs"
assert_contain "Can't save the user because of 2 errors"
end
end

View File

@@ -580,7 +580,7 @@ class AuthenticationKeysTest < ActionDispatch::IntegrationTest
test 'missing authentication keys cause authentication to abort' do
swap Devise, authentication_keys: [:subdomain] do
sign_in_as_user
assert_contain "Invalid email or password."
assert_contain "Invalid subdomain or password."
assert_not warden.authenticated?(:user)
end
end

View File

@@ -81,4 +81,15 @@ class DatabaseAuthenticationTest < ActionDispatch::IntegrationTest
assert_contain 'Invalid credentials'
end
end
test 'valid sign in calls after_database_authentication callback' do
user = create_user(email: ' foo@bar.com ')
User.expects(:find_for_database_authentication).returns user
user.expects :after_database_authentication
sign_in_as_user do
fill_in 'email', with: 'foo@bar.com'
end
end
end

View File

@@ -42,7 +42,7 @@ class HttpAuthenticationTest < ActionDispatch::IntegrationTest
sign_in_as_new_user_with_http("unknown")
assert_equal 401, status
assert_equal "application/xml; charset=utf-8", headers["Content-Type"]
assert_match "<error>Invalid email address or password.</error>", response.body
assert_match "<error>Invalid email or password.</error>", response.body
end
test 'returns a custom response with www-authenticate and chosen realm' do

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