Compare commits

...

715 Commits
v1.5 ... v2.2.8

Author SHA1 Message Date
José Valim
beeb48c404 Release v2.2.8 2013-11-13 14:11:45 +01:00
José Valim
cd982123a8 Release 2.2.7 2013-08-18 10:29:38 +02:00
José Valim
02a2976f5e Release v2.2.6 2013-08-09 10:31:54 +02:00
José Valim
a44002c68b Fix the build 2013-08-09 10:21:22 +02:00
José Valim
60f3c678e6 Skip storage for cookies on unverified requests 2013-08-09 09:33:19 +02:00
José Valim
81141bb9c8 Update Gemfile.lock 2013-08-02 23:45:31 +02:00
José Valim
373fd03ebc Release 2.2.5 2013-08-02 23:24:17 +02:00
José Valim
b3eace20c7 Update CHANGELOG 2013-08-02 23:22:39 +02:00
José Valim
415fa2ad21 Protect against CSRF token fixation attacks 2013-08-02 23:16:32 +02:00
Carlos Antonio da Silva
f5e33089a0 Release 2.2.4 2013-05-07 12:51:46 -03:00
José Valim
e499fadf52 Use persisted? in order to check if the record was destoryed or not 2013-05-07 08:55:30 -06:00
Carlos Antonio da Silva
70199ed039 Bump webrat to 0.7.3 on 3.1 as well 2013-05-07 11:48:03 -03:00
Carlos Antonio da Silva
fb07558082 Update changelog with latest fixes [ci skip] 2013-05-07 11:48:03 -03:00
José Valim
5ad122b928 Fix build for mongoid 2013-05-07 08:47:18 -06:00
José Valim
c78b4b40c1 Remove warning since webrat is emitting tons of them 2013-05-07 08:22:06 -06:00
José Valim
ef2a2280a3 Update examples to be compatible with Rails 4 2013-05-07 08:18:12 -06:00
Carlos Antonio da Silva
42fca4dbe5 Update 3.1 lock file 2013-05-07 11:12:58 -03:00
José Valim
03f2a6a5e4 Merge pull request #2392 from michiel3/master
Add destroy_with_password method
2013-05-07 07:11:47 -07:00
José Valim
cc2fea8276 Merge pull request #2402 from xtream/master
Avoid duplication on param filter
2013-05-07 07:09:47 -07:00
José Valim
bb4cc2428f Merge pull request #2407 from sebastianwr/master
No redirect when accessing devise API via JSON
2013-05-07 07:08:53 -07:00
Sebastian Wramba
43f7cf0f12 No redirect when Devise API is accessed via JSON 2013-05-07 10:18:23 +02:00
Carlos Antonio da Silva
bb5d65209a Change rubygems source to use https [ci skip] 2013-05-06 23:04:49 -03:00
Victor Cruz Dueñas
75fdd2944d Avoid hash mutation 2013-05-05 10:12:57 +02:00
Victor Cruz Dueñas
ae48fc8419 Refactor to avoid duplication on param filter 2013-05-05 01:19:37 +02:00
Victor Cruz Dueñas
d6d61fc5be Adding tests for case_insensitive_keys and strip_whitespace_keys to param filter 2013-05-05 01:02:48 +02:00
Victor Cruz Dueñas
19c8f0c0ad Merge remote-tracking branch 'upstream/master'
Conflicts:
	app/controllers/devise/registrations_controller.rb
	test/integration/registerable_test.rb
2013-05-05 00:20:34 +02:00
Rafael Mendonça França
63627d1439 Refactoring the code a little bit
* Rename #get_constraints_given_method to #constraints_for to make the
  method clear.

* The method name now is required.

* Use symbols instead of strings.

* Make #constraints_for a protected method.
2013-05-04 14:33:55 -03:00
José Valim
662f0e76d8 Merge pull request #2401 from jd-erreape/master
Refactor to avoid repeated code
2013-05-04 09:06:16 -07:00
DI2uNk
eadce2fef6 Refactored rails/routes.rb to avoid repeated code 2013-05-04 11:56:56 +02:00
Carlos Antonio da Silva
a0058d5fbf Add some spaces, remove comment 2013-05-03 21:52:00 -03:00
Carlos Antonio da Silva
d9d5ae3d58 Correct OrderedHash initialization to ensure keys order in 1.8.7
This should hopefully fix the build with 1.8.7 🙏
2013-05-01 21:35:03 -03:00
Rafael Mendonça França
b51c7fe59b Merge pull request #2396 from nickborromeo/show_license_in_gemspec
Fix gemspec so that MIT license will be visible when running the -d flag

Closes #2390
2013-04-30 10:34:54 -07:00
Nick Borromeo
a6b754b697 Fix gemspec so that MIT license will be visible when running the -d flag 2013-04-30 10:23:50 -07:00
Michiel Prins
92218e9ecc Remove unnecessary code 2013-04-29 15:21:31 +02:00
Michiel Prins
60e933df73 Add destroy_with_password method 2013-04-29 15:06:13 +02:00
José Valim
b451fc0aad Merge pull request #2391 from stereoscott/patch-1
Fix spelling error in doc block
2013-04-28 22:20:59 -07:00
Scott M
2f28e48f54 Fix spelling error in doc block 2013-04-29 01:52:37 -03:00
Carlos Antonio da Silva
76e4967ca1 Update travis-ci link in README [ci skip] 2013-04-28 13:06:08 -03:00
Vasiliy Ermolovich
dceb788c6b fix OrderedHash initialization 2013-04-23 10:37:10 +03:00
Vasiliy Ermolovich
fae8e977e8 use ordered hash to fix tests on ruby 1.8 2013-04-22 22:42:49 +03:00
Vasiliy Ermolovich
0a588fab3a update CHANGELOG [ci skip] 2013-04-22 17:51:54 +03:00
Vasiliy Ermolovich
bbf57214ac Merge pull request #2384 from worker8/after_reset_password_redirect_path
Add ability to override the redirect path after user has reset their password
2013-04-22 07:36:41 -07:00
Tan Jun Rong
804fbdf6d5 Fix spelling error, 'reseting' to 'resetting' 2013-04-22 22:25:40 +08:00
Tan Jun Rong
e4987e8bb7 Fix resource_name to resource 2013-04-22 21:40:52 +08:00
Tan Jun Rong
9d5a9c8a61 Add ability to override the redirect path after user has reset their password 2013-04-22 20:22:53 +08:00
Carlos Antonio da Silva
c8aa5f3e62 Bump webrat to 0.7.3 2013-04-19 20:38:39 -03:00
Carlos Antonio da Silva
df4b282566 Set variable to false instead of nil 2013-04-19 19:59:08 -03:00
Carlos Antonio da Silva
b8c5d76c5a Merge pull request #2380 from vipulnsward/fix_warnings
fix some warnings
2013-04-19 15:53:43 -07:00
Vipul A M
b871bd5036 fix some warning 2013-04-19 19:08:20 +05:30
José Valim
c439b80524 Merge pull request #2381 from vipulnsward/enable_warinings
enable warnings by default
2013-04-18 13:40:01 -07:00
Rafael Mendonça França
704221d48f Merge pull request #2379 from vipulnsward/remove_unused_vars
Remove unused variables and fix typos
2013-04-18 06:38:32 -07:00
Vipul A M
da70348662 enable warnings by default 2013-04-18 11:07:36 +05:30
Vipul A M
2e6457006e Remove unused variables and fix typos 2013-04-18 10:24:38 +05:30
Carlos Antonio da Silva
1f68309c47 ✂️ changelog [ci skip] 2013-04-15 15:50:06 -03:00
Lucas Mazza
93013c2e89 Merge pull request #2366 from hauleth/extract-lookup-for-i18n
Extract get_message
2013-04-14 08:21:19 -07:00
José Valim
b3edfeab73 Update README.md 2013-04-13 23:35:58 -07:00
José Valim
2dfa7e1761 Update CHANGELOG 2013-04-13 22:10:48 -07:00
José Valim
5bf4f57fcf Tidy up devise configuration 2013-04-13 22:07:54 -07:00
José Valim
1b8fd7c2ff Merge pull request #2271 from robhurring/master
Allowing http token auth to set the token_authentication_key if missing from params
2013-04-13 21:39:36 -07:00
Carlos Antonio da Silva
fa5ae57ce4 Use instance_eval instead of Proc#bind
Keep the implementation more similar to how it works in Action Mailer,
and avoid deprecation warnings with Proc#bind being raised in rails4
branch.
2013-04-13 11:35:51 -03:00
Carlos Antonio da Silva
d89dad5728 Bundle update for both Rails 3.1 and 3.2, update mocha, fix failing tests 2013-04-13 11:08:27 -03:00
Carlos Antonio da Silva
32a141d2a9 Fix typo in test descriptions 2013-04-13 10:54:52 -03:00
Carlos Antonio da Silva
36557ef641 ✂️ [ci skip] 2013-04-13 10:53:49 -03:00
José Valim
aa24335656 Merge pull request #2371 from tomasv/custom-devise-mailer-default-proc-fix
Fix devise sender bug with custom devise mailers.
2013-04-12 08:37:31 -07:00
Tomas Varneckas
1acd3d1790 Fix devise sender bug with custom devise mailers.
The devise sender detection must take into account that the default
sender set in the custom devise mailer can be a proc.
2013-04-12 16:48:48 +03:00
Łukasz Niemier
95f56258d7 Rename get_message to find_message and fix set_flash_message 2013-04-07 08:52:11 +02:00
Łukasz Niemier
8e9ad4626e Extract get_message 2013-04-06 18:46:21 +02:00
José Valim
2de7cbae25 Merge pull request #2363 from eloyesp/documenting_protected_methods
Generate documentation for protected methods.
2013-04-04 06:52:08 -07:00
Eloy Espinaco
37473cdaf7 Add config to customize documentation. 2013-04-04 09:48:33 -03:00
Lucas Mazza
bf30d79aca Update rubygems url inside Gemfile.lock 2013-04-03 10:22:46 -03:00
José Valim
148fa99dce Merge pull request #2330 from pungoyal/master
Language copy changes
2013-04-01 12:20:02 -07:00
Vasiliy Ermolovich
72cbafa322 Merge pull request #2340 from scottjacobsen/master
s/reseting/resetting

[ci skip]
2013-03-22 00:17:20 -07:00
Scott Jacobsen
4549d8c65f Update recoverable.rb
Fix type-o.
2013-03-21 18:49:19 -06:00
Vasiliy Ermolovich
6c566c1ca4 Merge pull request #2331 from yxhuvud/master
License information to gemspec.
[ci skip]
2013-03-16 09:06:04 -07:00
linus
41aed807fc Add license to gemspec. 2013-03-16 09:29:46 +01:00
Puneet Goyal
ddea9359a6 Removing an extra full stop 2013-03-15 15:19:52 +05:30
Puneet Goyal
5d87e150f7 removing an extra full stop 2013-03-15 15:18:45 +05:30
José Valim
d90e365636 Merge pull request #2315 from neo/http_auth_key
Allow explicit configuration of http auth key
2013-03-07 09:43:08 -08:00
Lucas Mazza
22442907af Fix send_devise_notification arity in the documentation.
[ci skip]
2013-03-05 15:55:19 -03:00
robhurring
10f58b636f update devise config template with new allow_token_authenticatable_via_headers options 2013-03-04 17:38:36 -05:00
robhurring
2d14bd2826 removing params hash merging of token and mimicking http basic auth flow 2013-03-04 17:33:27 -05:00
Matt Jones + Tony Schneider
f4ceecece4 Allow explicit configuration of http auth key
- Fix basic auth case in which authorized_keys is configured as hash
- Duplicate existing functionality when http_auth_key is not explicitly
  set
2013-03-04 12:23:05 -05:00
José Valim
359fdd840c Merge pull request #2311 from pixeltrix/improve-delayed-email-documentation
Improve documentation on sending delayed emails
2013-03-01 06:49:39 -08:00
Andrew White
c6578250d2 Improve documentation on sending delayed emails
There are a couple of gotchas in the existing documentation
about the `send_devise_notification` hook.

1.  The `after_commit` callback can be called multiple times
    so you should clear the array otherwise any additional
    invocations will trigger extra copies of the email.

2.  The `after_commit` callback is only called when a record
    is created or updated so you need to check for `new_record?`
    or `changed?` before adding it to `pending_notifications`
    otherwise it's okay to send it immediately.

The `new_record? || changed?` condition is necessary because
the latter isn't always true for new records, e.g:

    >> User.new.changed?
    => false

[ci skip]
2013-03-01 14:32:15 +00:00
José Valim
dc14c76ff6 Merge pull request #2308 from vfrride/patch-1
updates source url to use https
2013-02-27 18:59:31 -08:00
vfrride
5e74fd406b updates source url to use https 2013-02-27 21:39:45 -05:00
José Valim
ebeee33429 Run image optimizer on the logo (i'm done) 2013-02-26 11:36:25 -07:00
José Valim
e449c3b6d2 Update badges 2013-02-26 11:27:58 -07:00
José Valim
58871172ab Crop the logo a bit more 💣 2013-02-26 11:25:26 -07:00
José Valim
41a2d65ade Reduce logo dimentions 2013-02-26 11:23:11 -07:00
José Valim
e6dc425abb Add Devise logo 2013-02-26 11:19:48 -07:00
Lucas Mazza
198bfff2de Merge pull request #2300 from fphilipe/scoped-serialization
Make use of warden's scoped serialization
2013-02-25 15:32:43 -08:00
Lucas Mazza
d3f0665105 Merge pull request #2305 from gregates/feature/skip_confirmation_notice!
Changelog for #2296
2013-02-25 15:31:56 -08:00
Greg Gates
77b960f14a Changelog for #2296 2013-02-25 18:23:43 -05:00
José Valim
b388aae473 Merge pull request #2302 from islandr/master
Mention devise-encryptable requirement in initializer template
2013-02-25 14:05:15 -08:00
José Valim
81c6d70b7c Merge pull request #2296 from gregates/feature/skip_confirmation_notice!
Add #skip_confirmation_notification! to Confirmable
2013-02-25 14:01:54 -08:00
Ryan Mohr
f3928d8462 Mention devise-encryptable requirement for anything but bcrypt. 2013-02-25 10:42:06 -10:00
Philipe Fatio
c22d755cf4 Make use of warden's scoped serialization 2013-02-25 07:38:42 +01:00
Greg Gates
72cfaad618 Add #skip_confirmation_notification to Confirmable 2013-02-22 12:43:01 -05:00
José Valim
22897150d8 Merge pull request #2278 from plataformatec/issue-2275
allow_unconfirmed_access_for set to nil means unconfirmed access for unlimited time
2013-02-14 11:30:51 -08:00
Vasiliy Ermolovich
395a69b4ef allow_unconfirmed_access_for set to nil means unconfirmed access for unlimited time
closes #2275
2013-02-13 21:17:38 +03:00
Rob
547439d94c renaming devise option "allow_authorization_to_set_auth_token" to "allow_token_authenticatable_via_headers" 2013-02-10 12:50:52 -05:00
Rob
84f743c4ef adding http token auth options to env[devise.token_options] 2013-02-10 12:48:02 -05:00
Rob
22a8cfe6d3 fix hanging line on method call 2013-02-09 15:19:42 -05:00
Rob
3025b7e2f7 Allow http token authorization to set token_authentication_key in place of passing it in via params
It will not override existing token_authentication_key params if they are present.
2013-02-09 15:12:36 -05:00
Vasiliy Ermolovich
1b2460171e Merge pull request #2261 from plataformatec/issue-2253
use scoped path to shared views if scope is present
2013-02-08 15:43:39 -08:00
Vasiliy Ermolovich
f822f92321 use scoped path to shared views if scope is present
closes #2253
2013-02-09 02:35:06 +03:00
Lucas Mazza
042ba76480 Merge pull request #2263 from sboesen/patch-1
Typo - Update lib/generators/templates/devise.rb
2013-02-06 17:08:36 -08:00
Stefan Boesen
3458e12274 Update lib/generators/templates/devise.rb
Typo in template comment.
2013-02-06 16:30:00 -08:00
José Valim
d9364f7a4a Update CHANGELOG.rdoc
Close #2254
2013-02-01 09:30:43 -07:00
José Valim
fd0db0b188 Merge pull request #2251 from latortuga/2190-test-case
Add test for Issue #2190
2013-02-01 07:58:00 -08:00
Drew Ulmer
c9c1e13743 Add test for Issue #2190
Seems to be passing for me.
2013-01-31 10:05:53 -06:00
José Valim
25296d8c6f Add tests for sign out with redirect, related to #2249 2013-01-30 08:28:51 -07:00
José Valim
34c7981f69 Merge pull request #2248 from bvsatyaram/patch-1
Update README.md
2013-01-30 07:11:43 -08:00
B V Satyaram
f7a658e13d Update README.md
Devise is composed of 11 modules instead of 12.
2013-01-30 15:17:36 +05:30
José Valim
1d639bd0c5 Merge pull request #2247 from waldyr/patch-1
correcting tiny typo
2013-01-29 17:01:04 -08:00
Waldyr Guimarães Araújo de Souza
5ee07390b7 correcting tiny typo 2013-01-29 22:45:23 -02:00
Carlos Antonio da Silva
83ad67bd51 Fix inheriting mailer templates from Devise::Mailer
Previously inheriting from Devise::Mailer would not render default views
from devise when the inheriting mailer didn't have the view. Now it'll
correctly pick the default one from Devise::Mailer.
2013-01-29 00:08:26 -02:00
Carlos Antonio da Silva
72be1f1289 Match against string value, no need to create regexps 2013-01-28 23:59:15 -02:00
Carlos Antonio da Silva
0285565322 Actually fix this test by forcing to_s on the id 2013-01-28 21:40:11 -02:00
Carlos Antonio da Silva
acc3adb2c1 Use #next instead of calculating id + 1
The id attribute is not Integer in Mongo, so it fails with something like:

    NoMethodError: undefined method `+' for "5106fc06ee6da1ee44000002":Moped::BSON::ObjectId'`

With #next, it will work with both Integer and String ids, for both AR
and Mongo, returning a different id to test for filtered conditions.
2013-01-28 20:46:21 -02:00
Carlos Antonio da Silva
af37800c1d Change match routes to get / post
match without a verb is deprecated in Rails master.
2013-01-28 20:23:13 -02:00
Carlos Antonio da Silva
86eecc6606 Change "ActionController::IntegrationTest" to "ActionDispatch::IntegrationTest" 2013-01-28 19:58:21 -02:00
Rafael Mendonça França
349aab72f0 No need to test against ree since we are testing with 1.8.7 2013-01-28 13:50:08 -02:00
Rafael Mendonça França
bfa65dde70 Use the Ruby 1.8 hash syntax.
Yes we still support Ruby 1.8 😢
2013-01-28 13:21:44 -02:00
José Valim
d099d8f0ac Release v2.2.3 2013-01-26 11:43:17 -07:00
José Valim
5190f52857 Require string conversion for all values 2013-01-26 11:42:42 -07:00
José Valim
5790107f49 Merge pull request #2235 from camelmasa/sorted_locale_file
sorted locale file
2013-01-22 19:11:38 -08:00
camelmasa
6fd21ae37e sorted locale file 2013-01-23 10:39:58 +09:00
Vasiliy Ermolovich
b95c321660 update Gemfile.lock 2013-01-21 20:14:59 +03:00
Carlos Antonio da Silva
0061f113db Fix indent [ci skip] 2013-01-20 21:49:45 -02:00
José Valim
1fb3fbbd88 Merge pull request #2230 from nashby/issue-2218
add key option to rememberable_options
2013-01-20 12:23:21 -08:00
Vasiliy Ermolovich
d3f8bd6cae add key option to rememberable_options
closes #2218
2013-01-20 23:16:25 +03:00
José Valim
0642e2fc9b Merge pull request #2223 from jayshepherd/master
Allow parent_mailer to be customizable via Devise.parent_mailer ... (#2219)
2013-01-18 05:35:55 -08:00
Jay Shepherd
cc017b1f0d Allow parent_mailer to be customizable via Devise.parent_mailer, useful for engines 2013-01-18 02:26:41 -06:00
José Valim
6c2f51e35e Release 2.2.2 2013-01-15 21:03:15 +01:00
Lucas Mazza
47db984f52 Apply the changes on 0c4615e33 to the simple_form template too. 2013-01-14 18:53:34 -02:00
José Valim
0c4615e337 Properly check if reconfirmable is available 2013-01-13 09:53:26 +01:00
Carlos Antonio da Silva
85e46f0163 Merge pull request #2211 from nashby/fix-build
uUe click_button for canceling account in integration specs
2013-01-12 03:16:12 -08:00
Vasiliy Ermolovich
9913fde749 use click_button for canceling account in integration specs 2013-01-12 14:12:05 +03:00
José Valim
1f940f61c6 Merge pull request #2210 from steverob/master
Changed link_to to button_to for cancel registration link in edit registration view
2013-01-11 14:25:55 -08:00
Steve Robinson
70e38fe66d Changed link_to to button_to for delete user
It is advisable to use link_to for mostly GET operations. Actions like DESTROY when presented as a link can cause severe vulnerabilities.
Hence using a button is advisable.
2013-01-12 01:53:09 +05:30
José Valim
872ef2b97f Release 2.2.1 with fixes for 2.2.0 regressions 2013-01-11 19:15:54 +01:00
José Valim
33fb89340a Revert "update_with_password doesn't change encrypted password when it is invalid"
This reverts commit 10235f9d72.
2013-01-11 19:12:53 +01:00
José Valim
bd9bf326c0 Merge pull request #2206 from tigris/mailer_subject_rename
Rename Devise::Mailer.translate() to something more inline with what it does
2013-01-10 04:19:57 -08:00
Danial Pearce
d48414b0a5 Rename Devise::Mailer.translate() to something more inline with what it does. 2013-01-10 15:26:06 +11:00
José Valim
b6a7d11e5a Merge pull request #2205 from latortuga/2204-regression-with-db-authenticatable
2204 regression with db authenticatable
2013-01-09 09:52:14 -08:00
Drew Ulmer
75ce916be9 Call respond_to?(attr) before applying strip or downcase
This avoids calling strip and downcase on globally configured keys that may
not exist on all devise models. Fixes #2204, a regression introduced by
PR #2135. Also included a note about the intentional use of respond_to.
2013-01-09 11:42:54 -06:00
Drew Ulmer
c768366240 Add failing tests for Issue #2204
For a point release upgrade, Devise should not throw an exception when trying
to downcase or strip globally configured keys. This would be a breaking
change in functionality and this test demonstrates the issue.
2013-01-09 11:41:20 -06:00
Lucas Mazza
ca7d479e90 Install mongoid only on 1.9 2013-01-09 11:51:15 -02:00
Rafael Mendonça França
5bfbc264b7 Invalid YAML 💣 2013-01-09 10:14:01 -02:00
Rafael Mendonça França
9f8d3db2b4 Notify on campfire 2013-01-09 10:11:24 -02:00
Lucas Mazza
4b0d161f95 Update Gemfile.locks to latest patch releases of Rails and fix mocha to 0.10.0.t 2013-01-09 10:01:25 -02:00
José Valim
b2b8b5bf9a Release v2.2.0 2013-01-08 21:30:43 +01:00
Carlos Antonio da Silva
beda0fe9bd Update copyright [ci skip]
Or as @rafaelfranca says: Happy New Year 🎆
2013-01-08 09:22:26 -02:00
José Valim
8fa3951bea Update app/controllers/devise/sessions_controller.rb 2013-01-06 11:07:51 +01:00
José Valim
9724e386c3 Merge pull request #2201 from al/bugfix-non_navigational_session_destroy
Fix bug with non-navigational requests being treated as navigational ones in XHR to SessionsController#destroy.
2013-01-06 02:07:16 -08:00
Alan Larkin
f2de7bf84c Fixed bug in SessionsController#destroy which caused all XHR requests, regardless of `Accept' header, to be treated as 'text/html'. 2013-01-06 03:50:26 +00:00
Alan Larkin
84b8188db9 Added failing integration test for XHR invocation of SessionsController#destroy with */*' in the Accept' header. 2013-01-06 03:49:59 +00:00
José Valim
19b5bcbe0f Accept mail options in Devise::Mailer and deprecate headers_for 2013-01-04 18:52:49 +01:00
José Valim
7c8f636b98 Merge pull request #2178 from gwagener/master
Improved grammar of reset password e-mail
2012-12-13 22:49:30 -08:00
Graham Wagener
5745d97232 Improved grammar of reset password e-mail. 2012-12-14 15:08:55 +13:00
José Valim
86f0bff332 Apparently Rails 3.1 does not like @headers as ivar 2012-12-13 09:59:36 +01:00
José Valim
30ab6f923d Release 2.2.0.rc 2012-12-13 09:20:46 +01:00
José Valim
839e8fc8ac Show if there is an e-mail waiting for confirmation, closes #2060 2012-12-13 09:13:33 +01:00
José Valim
4c83743263 unconfirmed_email now uses the proper e-mail on salutation, related to #2060 2012-12-13 09:02:59 +01:00
José Valim
e1fde192f2 Update CHANGELOG 2012-12-13 08:43:43 +01:00
José Valim
73389ea491 Merge pull request #2174 from rykov/master
Adding the Gem Version badge to README
2012-12-11 10:44:32 -08:00
Michael Rykov
eeb6a30752 Add 'Gem Version' badge to README.md 2012-12-11 10:39:47 -08:00
Lucas Mazza
01669c7374 Display the build status just for the master branch [ci skip]. 2012-12-10 10:59:50 -02:00
Carlos Antonio da Silva
ac3a25bf2e Remove nothing raised assertion
Let the test raise if that is the case, no need for assert that nothing
was raised.

Hopefully fix the build 
2012-12-04 17:49:26 -02:00
Carlos Antonio da Silva
0652117c79 Bundle update 2012-12-04 17:37:32 -02:00
Carlos Antonio da Silva
2261005ed5 Refactor a bit to avoid two model attributes lookup
Tidy up tests a bit.
2012-12-04 17:37:12 -02:00
José Valim
e80e0c9a89 Merge pull request #2135 from latortuga/2129-make-validatable-affect-virtual-attributes
Make validatable callbacks affect virtual attributes
2012-12-02 01:43:48 -08:00
Drew Ulmer
79e9d6e564 Allow validation callbacks to apply to virtual attributes 2012-12-01 21:06:33 -06:00
Drew Ulmer
0c6f2adf14 Add failing test for #2129 2012-12-01 21:06:11 -06:00
Drew Ulmer
77ec1b08cd Move test models into their own file so they can be used elsewhere 2012-12-01 21:06:03 -06:00
Carlos Antonio da Silva
2be9fb292e Merge pull request #2165 from asanghi/master
Reverting part of #2164 which was a mistake [ci skip]
2012-12-01 10:58:39 -08:00
Aditya Sanghi
88dba417ef reverting part of #2164 which was a mistake 2012-12-02 00:24:09 +05:30
José Valim
b98f021d0f Merge pull request #2164 from asanghi/master
Minor grammar updates
2012-11-30 03:25:51 -08:00
Aditya Sanghi
c026b5a3f6 minor documentation grammar update 2012-11-30 16:42:18 +05:30
José Valim
3696cbf33e Merge pull request #2148 from kukula/master
Fix default email_regexp config to not allow spaces
2012-11-21 02:58:30 -08:00
José Valim
cbfdcbeaed Merge pull request #2147 from gabetax/signin_nonexistent_error
Support alternate sign in error message when email record does not exist
2012-11-19 15:56:18 -08:00
Gabe Martin-Dempesy
130d684198 Change failure key for missing database resource to :invalid_email 2012-11-19 15:49:21 -08:00
Anatoliy Kukul
f0f3e15c08 add test for Devise.email_regexp 2012-11-19 17:38:22 +02:00
José Valim
19a1ea5211 Update README.md 2012-11-19 14:02:43 +01:00
José Valim
6c2c808478 Merge pull request #2143 from luisico/display-invalid-confirmation-token-error
Invalid confirmation token message not shown with simple_form
2012-11-19 05:02:06 -08:00
Anatoliy Kukul
adc9a45f05 Used other regxp 2012-11-19 13:58:19 +02:00
Anatoliy Kukul
50186474d4 Fix default email_regexp config to not allow spaces
Default email_regexp config accepted emails with spaces. e.g.: "test user@test server.com" http://rubular.com/r/jXGS8pmumd
Changed regexp to not allow spaces in email. e.g.:  http://rubular.com/r/tTD9PytGEp
2012-11-19 13:40:54 +02:00
Gabe Martin-Dempesy
ffab77c35e Fix typo on nonexistent error 2012-11-18 15:19:15 -08:00
Gabe Martin-Dempesy
cde2229e59 Support alternate sign in error message when email record does not exist
By default, the nonexistent error is still identical to the :invalid
message, and must be customized by the developer to implement.
2012-11-18 15:08:57 -08:00
José Valim
397fce1f9d Merge pull request #2144 from jm81/master
Use correct current_password in RegistrationTest of invalid confirmation
2012-11-15 10:56:49 -08:00
Jared Morgan
f044916f94 Use correct current_password in RegistrationTest of invalid confirmation
In DatabaseAuthenticatable#update_with_password, password is now deleted if
the current_password is invalid. dm-validations will not check the
confirmation in that case, so this test was failing in dm-devise.
2012-11-15 12:21:11 -06:00
Luis Gracia
0415564a7d Show invalid unlock token message
Attribute unlock token is not present in the simple_form template,
therefore not being displayed by #error_notification.
This fix explicitily call #full_error on :unlock_token.
2012-11-13 15:01:32 -05:00
Luis Gracia
ed6f2abc23 Show invalid confirmation token message
fixes #2143

Attribute confirmation token is not present in the simple_form template,
therefore not being displayed by #error_notification.
This fix explicitily call #full_error on :confirmation_token.
2012-11-12 20:05:42 -05:00
Lucas Mazza
96a0477555 Remove 1.9.2 + Mongoid from the build matrix.
http://mongoid.org/en/mongoid/docs/tips.html#ruby
2012-11-12 15:07:29 -02:00
Lucas Mazza
da5464acf6 Update Travis CI configuration:
* `DEVISE_ORM=mongoid` is part of the build matrix, except
  for 1.8.7 and REE rubies;
* `language` key added (Thanks to travis-lint).
2012-11-12 09:12:17 -02:00
Lucas Mazza
1c8fc18fad Update Gemfile.rails-3.1.x. 2012-11-12 09:11:55 -02:00
José Valim
fbf667e009 Update CHANGELOG 2012-11-10 21:07:34 +01:00
José Valim
071ba358a9 Update README.md 2012-11-10 20:51:20 +01:00
José Valim
ef4db2e93d Merge pull request #2138 from nashby/patch-1
update README
2012-11-10 11:49:15 -08:00
José Valim
6a2ef52aa0 Merge pull request #2139 from durran/mongoid-3-test-fixes
Fix spec failures for Mongoid 3.
2012-11-10 11:49:05 -08:00
Durran Jordan
d821275588 Fix spec failures for Mongoid 3.
This has no actual changes to Devise itself, just fixes the failing
tests when running against Mongoid 3 instead of Mongoid 2.

Mocha has been locked at 0.10.0 since 0.12.0 raises an error when trying
to set an expectation on a frozen object.

Tests were updated to work with both AR and Mongoid, some cases the XML
serialization was slightly different but both were outputting correct
and valid XML, and the id/_id field mismatch is now handled.

An active field was missing from the test models for Mongoid, and the
invalid :null => true options in field were removed.
2012-11-10 20:02:58 +01:00
Vasiliy Ermolovich
59966e817c update README
closes #2128
2012-11-10 20:35:43 +03:00
José Valim
b1df686a2e Merge pull request #2137 from nashby/indifferent
remove useless test
2012-11-08 11:25:08 -08:00
Vasiliy Ermolovich
ae426dcc1c remove useless test 2012-11-08 22:22:03 +03:00
José Valim
1646684af9 Merge pull request #2134 from marcinb/master
unlock user after password re-set
2012-11-07 14:15:00 -08:00
Marcin Balinski
ac58c28617 Unlock user when re-setting password and unlock strategy is :email or :both 2012-11-07 10:45:46 +01:00
José Valim
7d72121bd7 Merge pull request #2132 from nashby/issue-2130
update_with_password doesn't change encrypted password when it is invalid
2012-11-06 13:13:50 -08:00
Vasiliy Ermolovich
10235f9d72 update_with_password doesn't change encrypted password when it is invalid
closes #2130
2012-11-06 21:05:17 +03:00
José Valim
5d311e7557 Merge pull request #2126 from nashby/issue-2122
don't delete the return to url from session if the requested format is not navigational
2012-11-04 23:49:42 -08:00
Vasiliy Ermolovich
5d86327e4d move is_navigational_format? and request_format methods to helpers 2012-11-05 09:54:22 +03:00
Vasiliy Ermolovich
61903b534a don't delete the return to url from session if the requested format is not navigational
closes #2122
2012-11-04 23:42:38 +03:00
José Valim
ee61d86546 Update CONTRIBUTING.md 2012-10-30 20:09:10 +01:00
José Valim
06a2cff140 Merge pull request #2117 from nashby/fix-issue-2043
handle namespaced models in AR generator
2012-10-27 15:25:32 -07:00
Vasiliy Ermolovich
2f36d0dd32 handle namespaced models in AR generator
closes #2043
2012-10-28 00:59:33 +03:00
José Valim
d5a2a9b2da Update CHANGELOG 2012-10-26 11:24:56 +02:00
José Valim
8ee1591868 Merge pull request #2115 from latortuga/1994-paranoid-locking
Add failing test for Issue #1994
2012-10-26 02:22:49 -07:00
José Valim
18c377e0d7 Merge pull request #2112 from latortuga/patch-1
Make #set_flash_message respect i18n-set resource_name
2012-10-26 02:05:42 -07:00
Drew Ulmer
00a01c2bc4 Fix #1994 Lockable no longer leaks account existence 2012-10-25 16:51:56 -05:00
Drew Ulmer
00e8841e93 Unit test for Lockable#unauthenticated_message not leaking account existence
This is another failing test for #1994, a unit test for Lockable. Lockable's
#uanauthenticated_message should not return :locked if paranoid mode is on
and instead should return the generic :invalid response.
2012-10-25 16:51:02 -05:00
Drew Ulmer
f79bb31ee6 Add failing test for Issue #1994
Lockable should not leak information about account existence if paranoid
mode is on.
2012-10-25 16:20:21 -05:00
Drew Ulmer
d6449d014e Add test for #devise_i18n_options allowing resource_name override 2012-10-24 12:13:07 -05:00
Drew Ulmer
b853871667 Make #set_flash_message respect i18n-set resource_name
Using #devise_i18n_options allows overriding any i18n keys but the
resulting call to I18n.t does not respect an override of resource_name.
2012-10-24 11:50:26 -05:00
José Valim
f796439cf2 Merge pull request #2111 from rubynortheast/signup_hook
Separates sign_up and sign_in on Registration
2012-10-23 12:53:52 -07:00
Philip Poots
692175b897 Moves sign_up from helpers to controller 2012-10-23 20:29:41 +01:00
Philip Poots
68dc20cba2 Separates sign_up and sign_in on Registration
See #2104

Completed with the help of @rubynortheast
2012-10-23 20:05:45 +01:00
José Valim
90dbae4c7a Merge pull request #2096 from adammcnamara/bugfix/assign-self-dot-resource
Assigns object to self.resource, changing variable scope.
2012-10-10 07:10:22 -07:00
Adam McNamara
564e588f5e Assigns object to self.resource, changing variable scope. 2012-10-10 10:01:35 -04:00
José Valim
8f4b06542e Merge pull request #2088 from dyba/contributing-fix
Missing https:// in Google Group link
2012-10-04 08:44:20 -07:00
Daniel Dyba
7513512000 Missing https:// in Google Group link 2012-10-04 08:38:16 -07:00
José Valim
7b04ecdddb Update CONTRIBUTING.md 2012-10-04 08:20:50 -07:00
José Valim
50338b34f9 Merge pull request #2074 from diminish7/failure_app_test_helper
Test helper was incorrectly returning failure body
2012-09-28 07:45:49 -07:00
José Valim
75268bed5c Merge pull request #2077 from floehopper/use-number-of-for-countable-noun
Use "number of" instead of "amount of" for countable nouns.
2012-09-28 07:45:03 -07:00
James Mead
e873e2aeed Use "number of" instead of "amount of" for countable nouns. 2012-09-28 10:52:37 +01:00
Jason Rush
b27491061e Test helper was incorrectly returning failure body
The _process_unauthenticated method in test_helper was returning
the response as the body. When setting rendering the text, it was
calling to_s on the response which would render something like
this: #<ActionDispatch::Response:0x007fb9e1efea00>. This change
renders the body of the response instead of the response itself
2012-09-27 18:44:31 -06:00
José Valim
9e096a4113 Update README.md 2012-09-18 14:30:04 +03:00
José Valim
8c7bf7dd15 Merge pull request #2042 from igor04/master
Deleted unnecessary validation in generator mongoid model
2012-09-13 05:10:18 -07:00
José Valim
f7dd59839c Update lib/generators/templates/README 2012-09-06 17:26:20 +03:00
José Valim
84c4759f58 Merge pull request #2045 from mtoledo/patch-1
Minor typo fix
2012-08-28 04:17:53 -07:00
Marcos Toledo
e345d3940c Minor typo fix 2012-08-27 23:41:47 -03:00
igor04
d59301ed2a Deleted unnecessary validation in generator mongoid model 2012-08-26 14:54:08 +03:00
José Valim
48751783a7 Merge pull request #2040 from RudyOnRails/master
Corrected routes.rb comment for destroy_user_session HTTP method. From GET to DELETE.
2012-08-23 09:24:39 -07:00
Kevin Musiorski
691172d01f Changed HTTP method for route destroy_user_session from GET to DELETE. Cleaned up indentations to keep tidy. 2012-08-23 10:26:45 -05:00
José Valim
eb51d0365f Merge pull request #2037 from Radagaisus/master
HTML5 Autofocus, to make things nicer
2012-08-22 05:38:38 -07:00
Radagaisus
422bf89182 autofocus for simple_form_for 2012-08-22 15:28:25 +03:00
Radagaisus
4962fbcb51 no need for {} they said 2012-08-22 02:15:48 +03:00
Radagaisus
be2b481385 fixed for 1.8.7 syntax 2012-08-22 02:13:38 +03:00
Radagaisus
d169ef3641 extra whitespace 2012-08-22 02:01:01 +03:00
Radagaisus
2a64972321 html5 autofocus for a better ux from the get go 2012-08-22 01:58:26 +03:00
Rafael Mendonça França
33fac7f765 Merge pull request #2027 from nashby/patch-1
Update lib/devise/rails/routes.rb comments
2012-08-17 07:09:49 -07:00
Vasiliy Ermolovich
5c2e3e1a12 Update lib/devise/rails/routes.rb 2012-08-17 17:05:47 +03:00
José Valim
4a24667e80 Revert "Rails 3.2.7 deprecates update_attribute in favor of update_column"
Rails 3.2.8 is rolling back the deprecations.

This reverts commit 7d41072c0e.
2012-08-05 09:24:10 -03:00
José Valim
c3d9dc3007 Merge pull request #2007 from willrax/patch-1
fixed typo in readme.md
2012-08-05 04:48:35 -07:00
willrax
df0a9401b1 fixed typo in readme.md 2012-08-05 19:27:11 +10:00
Carlos Antonio da Silva
f7f086faae Fix README [ci skip] 2012-07-31 23:32:10 -03:00
Rafael Mendonça França
6ae64b1723 Merge pull request #1998 from fabiokr/update_attribute
Replaces update_attribute with update_column
2012-07-27 13:31:20 -07:00
Fabio Kreusch
7d41072c0e Rails 3.2.7 deprecates update_attribute in favor of update_column. Updated projects using Devise output lots of warnings because Devise uses the deprecated version in some places. This commit replaces update_attribute with update_column to fix that. 2012-07-27 17:25:21 -03:00
José Valim
2f75b12add Merge pull request #1993 from ahmeij/master
Add message about :timedout flash to the Readme (resolved #1777)
2012-07-25 07:25:37 -07:00
Andre Meij
352dd1f2fc Update README.md include :timedout notice
Resolves #1777
2012-07-25 16:47:40 +03:00
José Valim
bdf0bc7b1e Revert "Revert "New password default minimum length is now 8""
This reverts commit b1f490a2f8.
Actually, the implementation was good!
2012-07-24 23:41:17 +02:00
José Valim
b1f490a2f8 Revert "New password default minimum length is now 8"
This reverts commit 2950434ed3.
It is backwards incompatible, we need a better migration plan.
2012-07-24 22:41:13 +02:00
Víctor Manuel Cruz Dueñas
73f617db7b Checking if unconfirmed_email has changed before to set update_needs_confirmation flash message.
Conflicts:

	test/integration/registerable_test.rb

Signed-off-by: José Valim <jose.valim@plataformatec.com.br>
2012-07-23 16:20:51 +02:00
José Valim
1da8490dbc Add a note about APIs in token authenticatable, closes #1959 2012-07-23 16:12:38 +02:00
José Valim
6e79c5c242 Ensure a new token is generated if the previous one expired 2012-07-23 16:05:51 +02:00
José Valim
f4db03d31c Do not add ActionView::Helpers::DateHelper to all models 2012-07-23 15:59:17 +02:00
Rodrigo Flores
8bc1096099 Minor correction on changelog 2012-07-23 10:39:39 -03:00
Rodrigo Flores
a23247d431 Changelog 2012-07-22 17:17:50 -03:00
Rodrigo Flores
6a37945025 Merge pull request #1975 from promisedlandt/email-token-expiration
Email token expiration
2012-07-22 13:10:27 -07:00
Nils Landt
dcada8fe75 Refactor according to line notes from josevalim
- rename reset_password_within to confirm_within
- confirmation_period_valid? is back and memoized
- fix hash syntax to hashrocket
2012-07-22 14:02:27 +02:00
Nils Landt
f80cecc864 Remove unnecessary include 2012-07-16 11:50:46 +02:00
Nils Landt
1d6ee13aae Refactor according to rodrigoflores
- Favor using update_attribute instead of constructor parameters in user
  factory for tests
- Test for accurate error message when confirmation token is expired
- Don't check twice whether the confirmation period is expired
2012-07-16 11:20:01 +02:00
José Valim
01d3ed7172 Merge pull request #1976 from benknowles/master
Patch for Trackable IP
2012-07-12 12:15:36 -07:00
Ben Knowles
a1411c885f Trackable should use the remote IP address, not the gateway's 2012-07-12 13:34:31 -05:00
Nils Landt
6e48fcee76 Fix tests for email token expiration
The tests work now, but are a bit wonky because User.create does things
I don't understand.
2012-07-11 18:30:36 +02:00
Nils Landt
42a0c30139 Refactored according to line notes by rodrigoflores 2012-07-11 15:49:41 +02:00
Nils Landt
87f2fa9767 Add options to expire confirmation tokens
With this patch, functionality is added to expire the confirmation
tokens that are being sent by email.
For example, if a token is valid for 3 days only, it cannot be used for
confirmation on the 4th day.
2012-07-09 14:43:12 +02:00
José Valim
8463c6dce4 Merge pull request #1963 from shime/master
update CONTRIBUTING.md
2012-07-07 11:38:41 -07:00
Hrvoje Šimić
9b77ac0cab update CONTRIBUTING.md 2012-07-07 19:57:59 +02:00
Rodrigo Flores
0afae74386 Update CONTRIBUTING.md 2012-07-06 16:52:53 -03:00
José Valim
56c1ab0824 Update CONTRIBUTING.md 2012-07-06 20:39:39 +02:00
José Valim
1ec23994f2 Try CONTRIBUTING.md 2012-07-06 20:23:58 +02:00
Rodrigo Flores
2950434ed3 New password default minimum length is now 8 2012-07-06 13:41:28 -03:00
Rodrigo Flores
1aca139c65 Changelog update 2012-07-06 12:03:25 -03:00
Rodrigo Flores
fa451306fc Merge pull request #1961 from carlosgaldino/change-min-password-length
Change the minimum password length to 8
2012-07-06 08:01:41 -07:00
Carlos Galdino
c179cef365 Change the minimum password length to 8 2012-07-06 11:46:46 -03:00
Víctor Manuel Cruz Dueñas
3511f8ac00 Checking if unconfirmed_email has changed before to set update_needs_confirmation flash message. 2012-07-05 19:10:34 +02:00
José Valim
1579ec9a87 Update CHANGELOG 2012-06-28 12:13:42 +02:00
José Valim
cbc6926e3d Fix issue #1928, thanks to @ejfinneran for a test case 2012-06-28 12:05:20 +02:00
José Valim
9678b422ff Merge pull request #1954 from mrchrisadams/d1bf31729d10fbb65f1b7ce158f3926aa946b3ad
Allow setting of default reply_to fields on mailer mails - #1936
2012-06-27 03:19:52 -07:00
Chris Adams
d1bf31729d Address issue #1936
Update mailer to accept reply_to as a default param as well, as discussed in 

https://github.com/plataformatec/devise/issues/1936#issuecomment-6583637
2012-06-26 23:11:35 +01:00
José Valim
a89a2052b8 Depend on latest warden 2012-06-26 21:16:00 +03:00
José Valim
6c80839e7b Merge pull request #1953 from ka8725/master
Use request_format method instead of direct code
2012-06-26 11:12:18 -07:00
Andrey Koleshko
972ac3b5f0 refactor is_navigational_format? method 2012-06-26 17:58:50 +03:00
Rodrigo Flores
caa8961938 Merge pull request #1949 from dblock/reconfirmation_token_reset
Test that confirms that #1948 is not an issue.
2012-06-25 15:37:05 -07:00
dblock
619826fbc8 Test that confirms that #1948 is not an issue. 2012-06-25 18:33:48 -04:00
José Valim
fe62d1bf6a Merge pull request #1943 from mathieul/patch-1
Allow to destroy a session using JSON format
2012-06-24 07:25:25 -07:00
mathieul
95f20587ef test that destroying a session doesn't set the flash if the requested format is not navigational 2012-06-23 14:43:35 -07:00
Mathieu Lajugie
8171ad39e0 Allow to destroy a session using JSON format (or any non navigational format) when Rails flash feature is not enabled (i.e.: when using rails-api). 2012-06-23 10:49:33 -07:00
Carlos Antonio da Silva
0c9b79947d Fix locked_at column in lockable required fields logic
See a7658f9d75 (commitcomment-1493199)

Thanks @nickhoffman
2012-06-22 22:31:57 -03:00
Carlos Antonio da Silva
4c9680787d Merge pull request #1941 from saizai/patch-1
Camelize correctly - e.g. omniauth-paypal sets this via OmniAuth.config.add_camelization
2012-06-22 18:21:14 -07:00
Sai
6eeb9e4b7d Update patch-1 2012-06-22 14:03:56 -03:00
Sai
80b2240ef0 Camelize correctly - e.g. omniauth-paypal sets this via OmniAuth.config.add_camelization 2012-06-22 10:55:23 -03:00
José Valim
2f142724c5 Update master 2012-06-19 19:33:30 +03:00
José Valim
174c2903d7 Release 2.1.2 2012-06-19 11:27:30 +02:00
José Valim
1f4c8e39f8 Revert "Thor fixes were sent upstream"
Actually, we need to wait for a new rails release, le sigh.

This reverts commit 3caab6d2ea.
2012-06-18 15:18:33 +02:00
José Valim
3caab6d2ea Thor fixes were sent upstream 2012-06-18 15:06:06 +02:00
José Valim
4e5a9bd600 Workaround thor bug /cc @wycats 2012-06-18 13:44:43 +02:00
José Valim
fef34d360b Merge pull request #1924 from calmyournerves/patch-1
fixed typo "Depreation" -> "Deprecation"
2012-06-16 11:00:38 -07:00
calmyournerves
05ddd9c204 fixed typo "Depreation" -> "Deprecation" 2012-06-16 20:51:56 +03:00
José Valim
ba2e44c6a4 Release 2.1.1 2012-06-16 15:57:17 +02:00
José Valim
4f07ed42e3 Lock warden on sign out 2012-06-16 15:21:48 +02:00
José Valim
66716023e4 Disable storage on CSRF 2012-06-16 14:51:37 +02:00
José Valim
4bc2ff997a Timeout does not explode when reset_authentication_token! is accidentally defined by Active Model 2012-06-16 14:04:34 +02:00
José Valim
b1633f2454 Delegate omniauth_authorize_path to the router, closes #1843 2012-06-16 13:43:11 +02:00
José Valim
41a91188f5 Do not trigger timeout on sign in related actions 2012-06-16 13:24:07 +02:00
José Valim
4def600076 Mark some methods as private 2012-06-16 13:06:52 +02:00
José Valim
18a18e4c72 Provide a send_devise_notification hook 2012-06-16 13:00:51 +02:00
José Valim
85c90671bc Update CHANGELOG 2012-06-16 12:38:02 +02:00
José Valim
16b688eced Merge pull request #1922 from excid3/master
Flexible routing scopes
2012-06-15 11:21:21 -07:00
Chris Oliver
37c55eb192 Added tests for flexible routing constraints 2012-06-15 13:06:29 -05:00
Chris Oliver
2d7dc3e82d Merge branch 'master' of git://github.com/plataformatec/devise 2012-06-15 11:05:58 -05:00
Chris Oliver
e7a8a7247c Switch and, or to &&, || 2012-06-15 08:45:44 -05:00
José Valim
c4818a9fb2 Reorganize tests slightly 2012-06-15 11:15:03 +02:00
Chris Oliver
8c2a7146df Add scope into warden user access 2012-06-15 02:10:42 -05:00
Chris Oliver
311e3206c9 Added block to authenticate route as well 2012-06-15 00:12:09 -05:00
Chris Oliver
6ad6b3d2a6 Allow passing a block to the authenticated route 2012-06-14 23:54:12 -05:00
Carlos Galdino
471a05fd59 Merge pull request #1921 from nashby/data-confirm
use data-confirm option as :confirm was deprecated in rails 3.2.6
2012-06-14 12:50:02 -07:00
Vasiliy Ermolovich
7a12655111 use data-confirm option as :confirm was deprecated in rails 3.2.6
SimpleForm templates
2012-06-14 22:48:37 +03:00
Rafael Mendonça França
1b26869b74 Merge pull request #1920 from nashby/data-confirm
use data-confirm option as :confirm was deprecated in rails 3.2.6
2012-06-14 12:35:30 -07:00
Vasiliy Ermolovich
13f35d80a9 use data-confirm option as :confirm was deprecated in rails 3.2.6 2012-06-14 22:27:40 +03:00
José Valim
1c4faa7d8a Depend on latest orm adapter 2012-06-13 15:07:24 +02:00
José Valim
c26ed53927 Merge pull request #1908 from mhfs/lockable_async_fix
Persist unlock token before triggering mailer
2012-06-11 14:09:24 -07:00
Marcelo Silveira
fe0f6e96b3 Persist unlock token before triggering mailer 2012-06-11 17:52:10 -03:00
José Valim
6dd7ccee68 Add more docs, remove 3.0 related code, update CHANGELOG 2012-06-08 19:22:14 +02:00
José Valim
9327cf8af5 Merge pull request #1903 from zamith/master
Routes for engines
2012-06-08 10:05:56 -07:00
Zamith
512b52e23a Adding option to change omniauth path prefix 2012-06-08 17:50:33 +01:00
José Valim
5df7105301 Merge pull request #1902 from gbataille/master
Redirect to sign_in page when trying to access password#edit without a reset password token
2012-06-08 01:19:05 -07:00
Gregory Bataille
a84fdb771f Merge branches 'master' and 'no_token' 2012-06-08 10:08:50 +02:00
Gregory Bataille
ff75341c75 Redirect to sign in page when trying to access password#edit without a
reset_password_token (i.e. not coming from a reset password email)
2012-06-08 10:08:35 +02:00
Carlos Antonio da Silva
f0d48a96ca Fix rdoc rake task [ci skip] 2012-06-07 22:48:15 -03:00
José Valim
215fdf119e Better error message when mapping can't be found 2012-06-07 14:34:13 +03:00
José Valim
985b646ee1 Update README.md, closes #1895 2012-06-07 14:31:43 +03:00
José Valim
622e480c4b Merge pull request #1892 from clody69/master
Fixed User model generation for Mongoid
2012-06-07 01:09:54 -07:00
José Valim
2e78a46c52 Merge pull request #1896 from Antiarchitect/patch-1
In addition to #1722. expire_auth_token_on_timeout added to Timeoutable configuration block.
2012-06-07 01:09:05 -07:00
Andrey Voronkov
b1b6e53d6f In addition to #1722. expire_auth_token_on_timeout added to Timeoutable configuration block. 2012-06-07 09:32:44 +04:00
José Valim
65325f7f81 Merge pull request #1894 from wtn/master
#update_with_password should use mass assignment options when password is not valid
2012-06-05 01:15:51 -07:00
William T Nelson
9bd82e5a24 use mass assignment options when password is not valid 2012-06-04 22:52:09 -05:00
Claudio Riva
0689b4558e Update master 2012-06-03 22:24:31 +03:00
Rafael Mendonça França
dbea934701 Update README.md [ci skip] 2012-05-29 17:28:57 -03:00
Rafael Mendonça França
8e4d5fb38f Merge pull request #1882 from GeekOnCoffee/patch-1
URLs that aren't links aren't nice
2012-05-29 13:26:56 -07:00
Andrew Hooker
e324ee9823 URLs that aren't links aren't nice 2012-05-29 15:24:34 -05:00
José Valim
54e9cabf5d Update README.md 2012-05-29 16:46:58 +03:00
José Valim
7a3f6fb53d Merge pull request #1880 from brynary/codeclimate-badge
Add Code Climate badge to README
2012-05-29 05:54:49 -07:00
Bryan Helmkamp
59a9576498 Add Code Climate badge to README 2012-05-29 08:46:48 -04:00
José Valim
57eb3886ba Refactor router.rb a bit based on Code Climate feedback: https://codeclimate.com/github/plataformatec/devise/Devise 2012-05-29 11:29:09 +02:00
Rafael Mendonça França
fe9e6db0e2 Merge pull request #1876 from shaliko/master
Remove not used variables
2012-05-26 09:36:30 -07:00
Shaliko Usubov
db8eeb6c6e Remove not used variables 2012-05-26 20:31:42 +04:00
José Valim
2b7328535d Check for the request before checking for the mapping, closes #1859 2012-05-25 09:39:50 +02:00
José Valim
d4e5424360 Simplify validation logic inside strategies 2012-05-22 14:10:06 +02:00
José Valim
d67d992749 Merge pull request #1865 from nirvdrum/patch-1
Simple compose VS comprise grammar fix.
2012-05-21 03:33:57 -07:00
Kevin Menard
b6c7aafe55 Simple compose VS comprise grammar fix. 2012-05-20 23:04:53 -03:00
José Valim
9829384829 Merge pull request #1864 from nashby/update-views
use implicit partials rendering and update simple_form templates
2012-05-20 12:17:19 -07:00
Vasiliy Ermolovich
1d79c1982a use implicit partials rendering
make simple_form templates consistent with templates
that generates by simple_form itself

612c0067cf
2012-05-20 22:01:11 +03:00
José Valim
f6259531c3 Update CHANGELOG.rdoc 2012-05-17 13:25:07 +03:00
José Valim
ed03039d19 Merge pull request #1857 from pomnikita/master
Remove devise/schema from autoloads
2012-05-17 02:27:30 -07:00
Nikita Pomyashchiy
b6abc4623b Remove autoload of deprecated devise/schema 2012-05-17 13:13:19 +04:00
Carlos Antonio da Silva
d1949b7b42 Fix indent, remove not used variable 2012-05-15 17:22:52 -03:00
Carlos Antonio da Silva
b6e30427a3 Pass the block argument straight to the assertion methods in test helpers 2012-05-15 17:19:21 -03:00
Carlos Antonio da Silva
96e0dcf5d5 Remove not used variable, fix indent 2012-05-15 17:14:05 -03:00
Carlos Antonio da Silva
ab48435211 Remove warning with shadowing variable 2012-05-15 15:27:46 -03:00
Carlos Antonio da Silva
8bcb05d6c0 Cache constant on check fields 2012-05-15 15:20:01 -03:00
Carlos Antonio da Silva
6b363d6af9 Build only one model instance for checking fields 2012-05-15 15:12:18 -03:00
Carlos Antonio da Silva
2fd2a8662d Define the accessor right away instead of open + send 2012-05-15 15:05:21 -03:00
Rodrigo Flores
f1db0809b1 Bumping to 2.1.0 2012-05-15 14:14:41 -03:00
Rodrigo Flores
30ca072f50 Fixing README to reflect 2.1.0 release 2012-05-15 14:14:40 -03:00
José Valim
85ea53198a Merge pull request #1853 from adzap/master
Add resource_params controller method as helper to allow overriding params used to build resource
2012-05-15 01:21:18 -07:00
Adam Meehan
7ec4c1424d Add resource_params internal helper to param filtering
In light of recent discussions around mass assignment security and
the alternate solution of using the controller to filter params, not the model,
a hook/helper is needed to be able to override how the params are filtered
before they are used to build the resource.
2012-05-15 18:07:02 +10:00
Rodrigo Flores
f95513e86b Merge branch 'asanghi-fixes' 2012-05-14 17:53:52 -03:00
Rodrigo Flores
8baacecdcf Fixing tests 2012-05-14 17:53:34 -03:00
Aditya Sanghi
ff6e30cec4 Minor updates suggested to default language in locales. Be consistent with "email" and "e-mail"; email address exists "in" our database not "on" our database. 2012-05-14 17:44:51 -03:00
Rodrigo Flores
308275c8a8 Fixing a phrase on README 2012-05-14 10:37:30 -03:00
Rodrigo Flores
5ed6534aa3 Adding a line break on resource generator after attr_accessible
Fixes issue #1851
2012-05-14 10:26:30 -03:00
Rodrigo Flores
120ca0e3a5 Merge branch 'fork-readme-rdoc-links' 2012-05-10 10:40:38 -03:00
Hosam Aly
d193802613 Added links to module RDocs, except for Encryptable which I couldn't find. 2012-05-10 10:40:27 -03:00
Rodrigo Flores
50b4d2eb6b Removing mentioning encryptable on README 2012-05-10 10:29:34 -03:00
Rodrigo Flores
36db032ca0 Updated Gemfile.lock 2012-05-09 19:54:09 -03:00
Rodrigo Flores
afbcc31c6a Bumping version to 2.1.0.rc2 2012-05-09 19:53:38 -03:00
Rodrigo Flores
52c35b18da Updating README 2012-05-09 19:52:56 -03:00
José Valim
454a5ad1ec Try to fix the build for rails 3.1 2012-05-09 23:41:05 +02:00
Rodrigo Flores
1698f0f57c Merge branch 'removing_encryptable' 2012-05-09 18:05:14 -03:00
Rodrigo Flores
bb6d7334d0 Fixing gem name 2012-05-09 18:04:40 -03:00
Rodrigo Flores
659ec4d6ea Using bundler's awesome way to release the gem! 2012-05-09 14:59:42 -03:00
Rodrigo Flores
2e50204700 Changelog 2012-05-09 14:52:47 -03:00
Rodrigo Flores
39dc9a7ba6 Removed encryptable references on rails_app 2012-05-09 14:49:55 -03:00
José Valim
65ef2592f6 Add a test case to previous commit 2012-05-09 18:27:44 +02:00
José Valim
ad0aed3ba5 Alternative solution to failure app's script name handling (tests upcoming) 2012-05-09 18:03:23 +02:00
Rodrigo Flores
0d868b9ec1 Removed ENCRYPTORS_LENGTH 2012-05-09 08:42:37 -03:00
Rodrigo Flores
5f440dfe13 Removing encryptors and its autoloads 2012-05-07 16:50:35 -03:00
Rodrigo Flores
768f8832b9 Removing encryptable module 2012-05-07 16:37:16 -03:00
José Valim
32f20dddd6 Get rid of deprecated code 2012-05-06 13:13:53 +02:00
José Valim
7aa93a3ecb Update CHANGELOG 2012-05-06 12:53:27 +02:00
José Valim
b07dd76453 Remove faux bcrypt encryptor from Devise (it was never released and it wont be until we solve the encryptable issue 2012-05-06 12:49:53 +02:00
José Valim
4600b4ab22 Speed up bcrypt handling 2012-05-06 12:29:03 +02:00
José Valim
a8d2dce563 Merge branch 'test_helpers' 2012-05-06 12:19:36 +02:00
José Valim
5e845ee265 Do not reproduce warden behavior, simply rely on the controller calling it 2012-05-06 12:09:53 +02:00
Matt Connolly
a9b7a4a1de Reinstating tests for the controller test's response object. This does need to be set so the strategy's custom response can be tested. 2012-05-06 19:24:57 +10:00
Matt Connolly
32d2f78239 Updating process unauthenticated to set the response so it can be tested. 2012-05-06 18:41:43 +10:00
Matt Connolly
2a3a8b8008 Changing test to not bother with saved response, since it wasn't set by the test. 2012-05-06 17:08:00 +10:00
Matt Connolly
90a63d4d89 Completing test and functionality for TestHelper to correctly return a custom response from a warden strategy. 2012-05-06 16:48:39 +10:00
Matt Connolly
66f74ed579 Adding a test for a warden strategy retuning a custom response. 2012-05-06 13:35:24 +10:00
José Valim
d376d11d42 Merge pull request #1825 from julianvargasalvarez/master
Use 'head :no_content' in sessions_controller#destroy
2012-05-03 00:27:21 -07:00
Julian Vargas
6664acd27f Use 'head :no_content' in sessions_controller#destroy
Code cleanup for returning headers instead of an empty string
when destroying sessions.

Lines 464 and 471 on test/integration/autenticatable_test.rb
were adjusted to assert on :no_content
2012-05-02 22:40:53 -05:00
Rodrigo Flores
525bcd4e2d Refactoring simulation inside engine to decide based on the api 2012-05-02 14:53:14 -03:00
Rodrigo Flores
34a64070ca Cached the class_path and changed a variable name (kudos to @britto!) 2012-05-02 14:52:55 -03:00
José Valim
67f2074c81 Merge pull request #1805 from rosenfeld/deserialization-handling
Better handling of previously enabled Devise model deserialization
2012-05-02 10:34:28 -07:00
José Valim
e6717e3d68 Merge pull request #1823 from plataformatec/bugfix-engine-generator
Fixes generator on engine
2012-05-02 10:33:54 -07:00
Rodrigo Flores
271eac7381 Testes passing on 3.1 \o/ 2012-05-02 14:15:42 -03:00
Rodrigo Flores
4bf4036bf7 Upgrading Rails 3.1 to 3.1.4 2012-05-02 14:15:42 -03:00
Rodrigo Flores
22c210c8b9 Changelog 2012-05-02 14:15:42 -03:00
Rodrigo Flores
afc3888391 Generators on engine fix 2012-05-02 14:15:42 -03:00
Rodrigo Rosenfeld Rosas
411b565cca Better handling of previously enabled Devise model deserialization 2012-05-02 13:03:34 -03:00
Carlos Antonio da Silva
f6c06ac786 Use sqlite3 gem for 3.1 Gemfile 2012-04-27 18:42:03 -03:00
Rodrigo Flores
852a6ff175 Merge pull request #1813 from Agis-/patch-1
Break the line so it doesn't exceed 80-chars limit
2012-04-27 07:55:58 -07:00
Agis Anastasopoulos
d6f4d936ee Apply the 80 chars per-line rule 2012-04-27 17:51:07 +03:00
Carlos Antonio da Silva
cba1820168 Change Copyright also in license file [ci skip]
See d435118 for the readme change.
2012-04-24 08:54:01 -03:00
Carlos Antonio da Silva
0cfc88d2ee Merge pull request #1804 from rosenfeld/sqlite
sqlite3-ruby was renamed to sqlite3
2012-04-22 06:12:35 -07:00
Carlos Antonio da Silva
ec3eed5d2a Change method name 2012-04-22 10:07:44 -03:00
Carlos Antonio da Silva
49873f4fea Merge pull request #1796 from mkremer/feature/devise_redirects
Added after_sending_reset_unlock_instructions_path_for
2012-04-22 05:44:50 -07:00
Rodrigo Rosenfeld Rosas
ee29bf8d42 sqlite3-ruby was renamed to sqlite3 2012-04-18 15:31:25 -03:00
Mark Kremer
0e0bfe6686 Added after_unlock_path_for to allow override of redirect after account
unlock
2012-04-17 13:38:50 +02:00
Mark Kremer
fafea15fa8 Added after_sending_reset_unlock_instructions_path_for which can be overridden in extensions to modify the redirect path 2012-04-17 10:04:06 +02:00
José Valim
3752981cfa Merge pull request #1794 from aderyabin/master
Clean up global namespaces
2012-04-16 09:14:36 -07:00
Andrey Deryabin
9ec1003f1e removed global namespaces 2012-04-16 21:27:16 +07:00
Rodrigo Flores
64c99bcfd4 Updated changelog to include the removal of render_with_scope
Closes #1737
2012-04-09 16:42:30 -03:00
George Guimarães
d4351183d9 Changes link in copyright notice to Plataformatec's site 2012-04-09 09:37:35 -03:00
José Valim
cef5c93bca Merge pull request #1780 from cmeiklejohn/master
Verify AR constant is defined in test suite.
2012-04-08 08:59:39 -07:00
Christopher Meiklejohn
eb4e23274d Ensure ActiveRecord is defined, which is not true when running Mongoid tests. 2012-04-07 15:54:00 -03:00
José Valim
dacdc72581 Do not accidently mark _prefixes as private. 2012-04-05 09:18:59 -03:00
José Valim
6846014def Do not make _prefixes private. 2012-04-05 09:15:48 -03:00
Rodrigo Flores
07ef99a8f0 Changelog and a minor change on the test title 2012-04-04 17:27:41 -03:00
Rodrigo Flores
857af600f7 Merge pull request #1722 from Antiarchitect/master
Token regeneration on session timeout.
2012-04-04 13:23:27 -07:00
Carlos Antonio da Silva
3cbced4e4e Merge pull request #1776 from bloudermilk/patch-1
Fixes syntax highlighting in the "Getting started" section of the README
2012-04-04 11:09:03 -07:00
Brendan Loudermilk
85e4a0e6ec Fixes syntax highlighting in the "Getting started" section of the README 2012-04-04 11:03:24 -07:00
Rodrigo Flores
45aca40f6c Updating the README since we won't have more private messages on Github 2012-04-04 08:12:12 -03:00
Andrey Voronkov
7ecbba089f Authentication token expiration on session timeout 2012-04-02 20:48:23 +04:00
José Valim
205ddfb7c9 Merge pull request #1761 from rosenfeld/patch-7
Fix require for rememberable strategy
2012-03-31 04:21:19 -07:00
Rodrigo Rosenfeld Rosas
8a50b207eb Fix require for rememberable strategy 2012-03-31 08:17:16 -03:00
José Valim
9f99ccdca3 Merge pull request #1759 from rosenfeld/patch-6
Fix typo
2012-03-30 12:38:58 -07:00
Rodrigo Rosenfeld Rosas
f49b605514 Fix typo 2012-03-30 16:37:23 -03:00
José Valim
52b4bab461 Fix failing test. 2012-03-30 09:13:28 +02:00
José Valim
f1ccaf86a4 Remember token is not required. 2012-03-30 09:08:00 +02:00
José Valim
b59ce51760 Wording. 2012-03-30 09:05:52 +02:00
José Valim
60d2c6fddb Update docs to make find_for_authentication purpose more clear. 2012-03-30 09:00:03 +02:00
José Valim
25a563119b Revert "Merge pull request #1754 from pivotalhalogen/master"
find_for_authentication should be called during only during
an authentication process.

This reverts commit a4c9d5826d, reversing
changes made to f94b71038e.
2012-03-30 08:53:35 +02:00
Rodrigo Flores
a4c9d5826d Merge pull request #1754 from pivotalhalogen/master
Shiny new pull request for #1752
2012-03-29 19:34:55 -07:00
Josh Knox & Ken Mayer
1d3b89458e Fix Authenticatable, call find_for_authentication 2012-03-29 16:27:41 -07:00
José Valim
f94b71038e Merge pull request #1749 from rosenfeld/patch-5
config.use_salt_as_remember_token is no longer supported
2012-03-28 23:47:42 -07:00
Rodrigo Rosenfeld Rosas
076f4b4db1 config.use_salt_as_remember_token is no longer supported 2012-03-28 19:29:41 -03:00
José Valim
18829a56e4 Merge pull request #1745 from rosenfeld/patch-3
Fix minor typo on settings template
2012-03-28 13:05:03 -07:00
Rodrigo Rosenfeld Rosas
ac7b1b3c1f Fix minor typo on settings template 2012-03-28 16:58:21 -03:00
José Valim
b74f71fbed Fix build so it works with Rails 3.1. 2012-03-26 18:50:39 +03:00
José Valim
c3c0f4bd89 Update CHANGELOG.rdoc 2012-03-26 18:01:21 +03:00
José Valim
e860ade718 Merge pull request #1730 from Paymium/issue-1729
Fix for #1729
2012-03-26 07:59:17 -07:00
José Valim
e9a8c6cb62 Merge pull request #1738 from parndt/patch-1
Bumped orm_adapter requirement up to ~> 0.0.7 per ianwhite/orm_adapter#10
2012-03-25 04:41:22 -07:00
Philip Arndt
473a68dbf9 Bumped orm_adapter requirement up to ~> 0.0.7 per ianwhite/orm_adapter#10 2012-03-26 00:16:01 +13:00
David FRANCOIS
885d8836d1 Ability to use attr_protected attributes as sign-in keys without triggering ActiveModel::MassAssignmentSecurity::Error when ActiveRecord::Base.mass_assignment_sanitizer is set to :strict. Fixes #1729. 2012-03-21 11:48:00 +01:00
José Valim
e92ae37dc3 Merge pull request #1726 from plataformatec/failed_attempts
Setting failed_attempts to 0 after sign in
2012-03-19 14:09:23 -07:00
Rodrigo Flores
e6af9763fd Hook should be on lockable not recoverable and removed an useless comment 2012-03-19 18:06:20 -03:00
Rodrigo Flores
ca73dae1f0 Changelog 2012-03-19 17:15:32 -03:00
Rodrigo Flores
3623215b8c failed_attempts is set to 0 on sign in 2012-03-19 17:09:22 -03:00
Rodrigo Flores
a1376ac8ea Indentation + Typo 2012-03-16 22:06:43 -03:00
Rodrigo Flores
9d724cb72a OMG Forgot to update the Changelog 2012-03-15 11:23:01 -03:00
Rodrigo Flores
91ba14e77e Bumping to 2.1.0.rc 2012-03-15 11:16:11 -03:00
José Valim
2cab75d72b Merge pull request #1719 from hakanensari/mounted-app-redirect
Fix redirect when authenticating mounted apps
2012-03-15 00:15:02 -07:00
Hakan Ensari
b37a74533d Fix redirect when authenticating mounted apps 2012-03-15 02:41:29 +00:00
Rodrigo Flores
939d0f25c5 Merge pull request #1716 from plataformatec/validate_symbol
Validate is now a boolean function and unautheticated_symbol returns the symbol
2012-03-13 12:07:13 -07:00
Rodrigo Flores
61929d2e2f Fixing lockable to use the correct method 2012-03-13 15:53:57 -03:00
Rodrigo Flores
a7658f9d75 Checking required fields on lockable 2012-03-13 15:50:13 -03:00
Rodrigo Flores
033e91b7b9 Adding symbols only on validate 2012-03-13 14:24:21 -03:00
José Valim
68de34c03e Move valid_password? up to database authenticatable. 2012-03-10 11:10:57 +01:00
José Valim
94c05e346d Merge pull request #1709 from plataformatec/extracting_bcrypt
Moved BCrypt logic to a Encryptor
2012-03-09 14:26:20 -08:00
Rodrigo Flores
45298c0a37 Fixing some arguments order 2012-03-09 19:19:20 -03:00
Rodrigo Flores
c12fc1afea The signature must be the same 2012-03-09 18:37:37 -03:00
Rodrigo Flores
136b5b0be9 Added compare to encryptors 2012-03-09 17:19:36 -03:00
Rodrigo Flores
9203651110 Moved BCrypt logic to a encryptor 2012-03-09 16:38:06 -03:00
José Valim
a394ceaef1 Update CHANGELOG. 2012-03-09 18:12:43 +01:00
José Valim
0ab28ef8ee Add skip_reconfirmation! , closes #1708 2012-03-09 18:12:30 +01:00
Rodrigo Flores
b928b8b3a2 Merge pull request #1700 from strzalek/patch-1
Fix formatting in README
2012-03-05 08:19:02 -08:00
Łukasz Strzałkowski
075fc96f10 Fix formatting in README 2012-03-05 17:01:46 +01:00
Rodrigo Flores
15f6255c7c Update CHANGELOG.rdoc 2012-03-03 16:41:24 -03:00
Rodrigo Flores
2b79519ad1 Changelog 2012-03-03 15:25:07 -03:00
Rodrigo Flores
617a8876a6 Merge branch 'deprecating-ausence-of-required-fields' 2012-03-03 15:16:07 -03:00
Rodrigo Flores
7b7af57813 Minor fixes on models_test 2012-03-03 15:10:17 -03:00
Rodrigo Flores
a12f6ec70c Failure is better than exceptions 2012-03-03 14:49:59 -03:00
Rodrigo Flores
fffc3b1e0e Moved a method to support 2012-03-03 14:41:22 -03:00
Rodrigo Flores
af12ec2b01 Fixing a deprecation warning 2012-03-03 14:32:53 -03:00
Rodrigo Flores
ecfc7d752a Deprecation warning on module doesn't have a required_fields method 2012-03-03 14:30:59 -03:00
Rodrigo Flores
bc096994b0 Merge pull request #1696 from plataformatec/reverting
Adding back links partial to shared
2012-03-03 07:05:04 -08:00
Rodrigo Flores
ba80074b7b Added a missing hide! 2012-03-03 11:32:58 -03:00
Rodrigo Flores
f04d883ac1 Deprecation warning 2012-03-03 11:12:30 -03:00
Rodrigo Flores
9bf718dd82 Revert "Move devise/shared/_links.erb to devise/_links.erb"
This reverts commit aa2d15aa33.

Conflicts:

	CHANGELOG.rdoc
2012-03-03 10:40:59 -03:00
Rodrigo Flores
643d5600b2 Changelog adjustments 2012-03-03 08:41:23 -03:00
Rodrigo Flores
1edae9c6c1 Changelog update 2012-03-03 08:39:24 -03:00
José Valim
b41e5f5bf6 Update CHANGELOG 2012-03-03 12:11:40 +01:00
José Valim
2f6ecc1328 Do not call after sign in hook without resource, closes #1666. 2012-03-03 12:09:26 +01:00
José Valim
b93288875f Update lib/devise/rails/routes.rb 2012-03-03 11:16:21 +01:00
Rodrigo Flores
bb4f699d03 Fixing two tests 2012-03-03 01:25:17 -03:00
Rodrigo Flores
f1d991fa8b Merge pull request #1681 from abevoelker/change-omniauth-flash-wording
Change OmniAuth flash wording (authorize->authenticate)
2012-03-02 20:16:54 -08:00
Rodrigo Flores
4ce7854f44 Changelog 2012-02-25 10:38:40 -02:00
Rodrigo Flores
5ef35ee1bd Adding required_fields to all modules 2012-02-24 20:57:58 -02:00
Rodrigo Flores
6d5bccc050 Added required fields to validatable 2012-02-24 20:57:58 -02:00
Abe Voelker
3ac2c1dd18 Change OmniAuth flash wording (authorize->authenticate) 2012-02-24 14:35:43 -06:00
Carlos Antonio da Silva
07a41ecf6f Merge pull request #1679 from codeodor/patch-1
Include note about restarting the rails app if it's already running
2012-02-23 15:57:44 -08:00
Sammy Larbi
61e85a578e Include note about restarting the rails app if it's already running, because the last 2 apps I used Devise with, I could not figure out why I was getting very strange errors, and finally today I figured out it was due to the fact that it needed to reload. 2012-02-23 17:37:13 -06:00
José Valim
88d68587e1 Update lib/devise/controllers/helpers.rb 2012-02-23 21:06:39 +01:00
Rodrigo Flores
23ae04e6cb Merge pull request #1675 from plataformatec/fix_assertion
Fix the assert_same_content assertion helper
2012-02-22 10:51:05 -08:00
Lucas Mazza
64c05f2ce9 Fix the assert_same_content assertion helper
and a broken confirmable test.
2012-02-22 16:49:09 -02:00
José Valim
c5cb60a752 Merge pull request #1673 from plataformatec/check_attributes_rebased
Check attributes on models
2012-02-22 08:07:16 -08:00
Rodrigo Flores
803e4f5524 Changed message and refactored exception to use a initializer 2012-02-22 13:55:06 -02:00
Rodrigo Flores
a909bfaf85 Added required_fields when reconfirmable 2012-02-22 13:55:06 -02:00
Rodrigo Flores
bc11e9f300 One exception to rule them all 2012-02-22 13:55:05 -02:00
Rodrigo Flores
e3412d4207 No need to sort anymore 2012-02-22 13:55:05 -02:00
Rodrigo Flores
faf8b01ecc Fixing some tests and adding an assert message 2012-02-22 13:55:05 -02:00
Rodrigo Flores
d7337c5b26 Added a missing test and asserting same content for 1.8 compatibility 2012-02-22 13:55:05 -02:00
Rodrigo Flores
2ab1086b80 Test, you shall pass! 2012-02-22 13:55:05 -02:00
Rodrigo Flores
85f2f88c59 Added required fields to lockable 2012-02-22 13:55:05 -02:00
Rodrigo Flores
ce3422e75a Added required_fields to recoverable 2012-02-22 13:55:04 -02:00
Rodrigo Flores
bee87843b4 Added required_fields to rememberable 2012-02-22 13:55:04 -02:00
Rodrigo Flores
18aef6ac33 Some refactor 2012-02-22 13:55:03 -02:00
Rodrigo Flores
890f6031c3 Required fields on trackable 2012-02-22 13:55:03 -02:00
Rodrigo Flores
f3bace570d Required fields on token_authenticatable 2012-02-22 13:55:02 -02:00
Rodrigo Flores
533511f8c3 Required fields on encryptable 2012-02-22 13:55:02 -02:00
Rodrigo Flores
6489354b0e Required fields on confirmable 2012-02-22 13:55:02 -02:00
Rodrigo Flores
1bbae013cc ✂️ whitespaces 2012-02-22 13:55:02 -02:00
Rodrigo Flores
8ac8129fe7 Added required_fields to database_authenticatable 2012-02-22 13:55:01 -02:00
Rodrigo Flores
9667a38bc9 Added check_model! method 2012-02-22 13:55:01 -02:00
José Valim
e3df7f033e Update .travis.yml 2012-02-21 08:47:28 +01:00
José Valim
989fd92b84 Merge pull request #1672 from RogerE/rememberable_options-in-initializer
Use rememberable_options instead of deprecated cookie_options in initializer
2012-02-20 23:10:57 -08:00
RogerE
de24170a79 Use rememberable_options instead of deprecated cookie_options in initializer 2012-02-21 08:01:17 +01:00
José Valim
5a0548621f Remove deprecated examples from README, closes #1669. 2012-02-20 18:53:45 +01:00
Rafael Mendonça França
0f8e472dab Update CHANGELOG.rdoc 2012-02-18 14:24:49 -02:00
George Guimarães
b190fa38c7 typo 2012-02-17 19:15:46 -02:00
José Valim
b0b01dae81 Update CHANGELOG. 2012-02-17 12:51:00 +01:00
José Valim
f2b4ba6110 Release 2.0.4 2012-02-17 12:46:31 +01:00
José Valim
d15d0ba6a5 Update CHANGELOG. 2012-02-17 12:46:31 +01:00
José Valim
fc3af50b55 Fix regression where warden was being configured too early. 2012-02-17 12:46:31 +01:00
José Valim
a0a141b457 Merge pull request #1661 from mreinsch/fix_subdomain_routing
fix for when using :host in routes
2012-02-17 02:31:14 -08:00
Michael Reinsch
0315ca2701 fix for :host getting overwritten in scope[:options] and thus not generating URLs with correct hostnames 2012-02-17 19:14:42 +09:00
Rodrigo Flores
9f4f973277 Bumping new version 2012-02-16 16:07:10 -02:00
Rodrigo Flores
b825e16e36 Merge branch 'issue-solving' 2012-02-16 16:01:59 -02:00
Rodrigo Flores
24b4db4352 Added Gemfile.rails-3.1.x.lock 2012-02-16 15:53:22 -02:00
Rodrigo Flores
06941ac7a2 Updating gemfile to use the new warden version 2012-02-16 15:49:16 -02:00
Rodrigo Flores
91d0360a11 Changelog 2012-02-16 15:34:41 -02:00
Rodrigo Flores
17bae5bba2 Executing all sign_out function regardless of logged in users presence 2012-02-16 15:30:12 -02:00
Rodrigo Flores
1a41fff009 Bye PathChecker 2012-02-16 15:25:06 -02:00
Rodrigo Flores
7739c495e7 Any? instead of !empty? 2012-02-16 15:22:10 -02:00
Rodrigo Flores
5607f7a2c8 Updating Rails 3.1 gemfile 2012-02-16 15:08:47 -02:00
Rodrigo Flores
2a74416d68 Documentation update 2012-02-16 14:53:11 -02:00
Rodrigo Flores
65f08ea175 Removing signed_out path workaround 2012-02-16 14:53:11 -02:00
Rodrigo Flores
70b9bdcc9a Adding temporary dependency to warden master 2012-02-16 14:53:11 -02:00
Rodrigo Flores
584d5d1a81 Adding the api changes on sign_out_all_scopes 2012-02-16 14:53:10 -02:00
Rodrigo Flores
9e7ab38bce sign_out helper uses the new warden api 2012-02-16 14:53:10 -02:00
José Valim
71f5a01b83 Update CHANGELOG. 2012-02-16 12:31:04 +01:00
José Valim
df8ac1cfe6 Clean up remember token related config. 2012-02-16 12:30:04 +01:00
José Valim
72b6a0a0c9 Another attempt to avoid false positives in this warning. 2012-02-16 08:01:03 +01:00
José Valim
93cf836564 Avoid false positives for warning message. 2012-02-15 23:39:36 +01:00
José Valim
d2223ee5e3 Improve coverage, cache array in a constant. 2012-02-15 20:18:52 +01:00
José Valim
b6ab8d6776 Update lib/devise/models/authenticatable.rb 2012-02-15 20:05:18 +01:00
José Valim
456989ca8d Simply blacklist Devise attributes instead of trying to be smart. 2012-02-15 19:52:10 +01:00
José Valim
2e27d1f763 Update CHANGELOG, release 2.0.2 2012-02-15 17:26:23 +01:00
José Valim
27a83f3dd3 Ensure Devise.available_router_name is never nil, closes #1648 2012-02-15 17:13:57 +01:00
José Valim
79aadb4bc9 Set autocomplete to off by default on password field. 2012-02-15 17:07:58 +01:00
José Valim
43d0715238 Better error message in case a trackable module can't be saved. 2012-02-15 17:07:46 +01:00
José Valim
fb8e093389 Accept devise_i18n_options to handle custom i18n values, closes #1633 2012-02-15 16:58:23 +01:00
José Valim
4b47c3ab73 Clean up devise_controller? related code. 2012-02-15 16:58:23 +01:00
José Valim
a0eff85d73 Use ResourceHelpers so we get a warning in case someone passes a plural name, closes #1651. 2012-02-15 16:58:23 +01:00
Rodrigo Flores
aa36719bd9 Merge branch 'ysiadf-integrating' 2012-02-13 18:24:38 -02:00
Ysiad Ferreiras
33aa71c38f Update lib/generators/templates/README 2012-02-13 18:24:11 -02:00
Ysiad Ferreiras
1f20d7da25 Update lib/generators/templates/README 2012-02-13 18:23:45 -02:00
Ysiad Ferreiras
dfcf825721 Update README.doc to specify adding devise to the Gemfile. 2012-02-13 18:23:07 -02:00
José Valim
eaae041b4c Merge pull request #1635 from sj26/test-helpers-process-should-return-response
Fix test behaviour for rspec subject requests
2012-02-11 22:32:35 -08:00
Samuel Cochran
dbd79746b1 Fix test behaviour for rspec subject requests 2012-02-10 21:42:20 +08:00
José Valim
f1a27b8f33 Release 2.0.1. 2012-02-09 11:11:12 +01:00
José Valim
86c8e5455a Fix gemspec to not include tmp or log files, closes #1632. 2012-02-09 11:07:03 +01:00
José Valim
dc37b82298 Show a warning message in case routes are not mounted in the main app. 2012-02-07 10:56:30 +01:00
José Valim
7d09b84ded Split send_on_create_confirmation_instructions, closes #1621 2012-02-03 17:35:55 +01:00
José Valim
53894e1e2b Better exception message. 2012-02-03 17:29:22 +01:00
José Valim
7e3ccbe835 Better implementation for hide! 2012-02-03 09:12:15 +01:00
José Valim
8b8b6a866d Hide internal generators, closes #1586 2012-02-03 09:04:05 +01:00
Rodrigo Flores
222e606f89 Added a documentup link on README 2012-02-03 00:39:28 -02:00
José Valim
83c47552e8 Extract auth_options into its own method. 2012-02-01 09:37:33 +01:00
José Valim
03851cab90 Update lib/devise/rails/routes.rb 2012-02-01 07:26:39 +01:00
Carlos Antonio da Silva
bb6d89bbc3 Change README do markdown 2012-01-30 18:58:04 -02:00
José Valim
b061f985cf Update README to remove reference to old migration helpers. 2012-01-27 19:43:47 +01:00
José Valim
ecd7c17ffd Improve the message for case_insensitive_keys. 2012-01-27 17:53:44 +01:00
José Valim
a71a352822 Release 2.0.0 2012-01-26 19:40:04 +01:00
José Valim
c08c921b3f Update README.rdoc 2012-01-26 18:19:02 +01:00
Carlos Antonio da Silva
95399f1286 2012 [ci skip]
Hope we can do the same bump next year :)
2012-01-24 19:35:14 -02:00
José Valim
b5fd15c2e1 Let's show the default values for convenience. 2012-01-24 17:34:18 +01:00
José Valim
85e9dab370 Release 2.0.0.rc2. 2012-01-24 14:29:26 +01:00
José Valim
8c9cf7d671 Add deprecations, update changelog. 2012-01-24 14:23:34 +01:00
José Valim
82da877863 Merge pull request #1565 from joliss/unconfirmed-message
More helpful sign-up message for Confirmable
2012-01-24 05:06:51 -08:00
José Valim
275c480f89 Redirect to the previous URL on timeout, closes #1596 2012-01-24 14:00:36 +01:00
José Valim
477d9fbcba Do not fallback to string on failure app, easier for debugging, closes #1587 2012-01-24 13:46:25 +01:00
José Valim
b88524027c Get rid of deprecation warning. 2012-01-24 13:41:19 +01:00
José Valim
55be93d5c4 Deprecated support for nested devise_for blocks 2012-01-24 13:40:04 +01:00
Jo Liss
c78c196423 More helpful sign-up message for Confirmable
This is also better for translations, because we can translate paragraph-wise.

signed_up_but_inactive and signed_up_but_locked are likely not needed,
but I wasn't sure how to best remove them.
2012-01-23 13:52:32 +01:00
José Valim
d8656427fd Merge pull request #1591 from kaleemullah/master
fix unlock message
2012-01-23 03:29:29 -08:00
Kaleem Ullah
41b1e87105 fix unlock message 2012-01-23 15:20:05 +04:00
José Valim
37678ac5ec Merge pull request #1588 from nashby/fix-travis-build
fix travis build
2012-01-23 02:46:24 -08:00
Vasiliy Ermolovich
7832d90077 fix travis build 2012-01-22 22:12:28 +03:00
José Valim
3bd78cabd8 Update to 3.2.0 2012-01-20 19:03:22 +01:00
José Valim
fff75b1904 Merge pull request #1579 from masterkain/patch-1
Fix typos in devise.rb
2012-01-17 14:18:10 -08:00
Claudio Poli
97c0339f66 Fix typos in devise.rb 2012-01-17 23:14:26 +01:00
Rafael Mendonça França
5b3f14df3b Fix README 2012-01-17 15:59:50 -02:00
José Valim
07cdba349d Merge pull request #1563 from asynchrony/handle_regexp_param_filtering
Allow regex to avoid string conversion for parameter filtering
2012-01-16 03:20:17 -08:00
José Valim
197e837e5b Merge pull request #1564 from pcantrell/patch-1
Grammar fix.
2012-01-11 23:09:17 -08:00
pcantrell
13bd4ce46a Grammar fix. 2012-01-11 23:18:04 -06:00
José Valim
a43d1af23e Merge pull request #1557 from plataformatec/rails-3-2-fixes
Rails 3.2 fixes
2012-01-10 12:26:58 -08:00
Rafael Mendonça França
cbf483143f Remove rubinius from travis-ci matrix 2012-01-10 11:59:59 -03:00
Rafael Mendonça França
cf5fbb9d65 Fix order specific test 2012-01-10 11:59:20 -03:00
Rafael Mendonça França
d699b80254 Do not use a local network ip as HTTP_X_FORWARDED_FOR header
If HTTP_X_FORWARDED_FOR is a local network IP the HTTP_CLIENT_IP
need to be set
2012-01-10 11:43:15 -03:00
Rafael Mendonça França
ead414d0a7 Use global Gemfile in travis-ci 2012-01-10 10:52:14 -03:00
Rafael Mendonça França
cfdabf874a Change gemspec to avoid subshells and remove unneeded files
More informations at http://tenderlovemaking.com/2011/12/05/profiling-rails-startup-with-dtrace/
2012-01-09 23:47:35 -03:00
Rafael Mendonça França
e954254abb Fix gemfiles 2012-01-09 23:18:03 -03:00
Rafael Mendonça França
93d4bb8361 Add travis-ci specific gemfiles 2012-01-09 22:59:13 -03:00
Rafael Mendonça França
edb0aac091 Whitespaces ✂️ 2012-01-09 18:11:10 -03:00
Rafael Mendonça França
9549a32500 Do not use deprecated ActiveSupport::Base64. Closes #1554 2012-01-09 18:10:49 -03:00
José Valim
a949f9eca2 FailureApp shuold always consider Devise.router_name, closes #1544 2012-01-03 20:32:51 +01:00
Carlos Antonio da Silva
f4bbad6323 Merge pull request #1543 from joliss/doc
Improve routing API docs
2012-01-03 06:39:41 -08:00
Jo Liss
8a4d4864ea Improve routing API docs 2012-01-03 15:33:19 +01:00
José Valim
a8de38d0b0 Fix http://@ from CHANGELOG 2012-01-02 23:18:57 +01:00
José Valim
18dc82c6b6 add a test that :module => :devise overrides previous configs. 2012-01-02 22:47:28 +01:00
José Valim
897c1c684e Allow router_name to be customizable via Devise.router_name, useful for engines 2012-01-02 22:43:07 +01:00
José Valim
1ebcb09fc1 Do not rely on root_path. Redirect to / if not available. 2012-01-02 22:43:07 +01:00
José Valim
0f11226ced Merge pull request #1540 from michaelklishin/master
Bring .travis.yml up to date
2012-01-02 13:21:51 -08:00
José Valim
dada404a6b Support 3.2 as well. 2012-01-02 22:19:05 +01:00
Michael Klishin
e4a37d6a5e Bring .travis.yml up to date
* rbx and rbx-2.0 are now both aliases for rbx-18mode (master in 1.8 mode)
 * 1.9.3 final is available
2012-01-03 01:14:59 +04:00
José Valim
66b93e8fd2 Clean up as we don't need to call render_with_scope anymore. 2012-01-02 22:12:09 +01:00
José Valim
d9df632671 Get rid of InternalHelpers, refactor scoped views for more performant behavior. 2012-01-02 22:01:28 +01:00
José Valim
aa2d15aa33 Move devise/shared/_links.erb to devise/_links.erb 2012-01-02 21:26:26 +01:00
José Valim
0b55ebb150 Remove 3.0 related code. 2012-01-02 21:04:54 +01:00
José Valim
7c11564613 Remove Rails 3.0 only code. 2012-01-02 20:43:39 +01:00
José Valim
c3f864f2b6 Allow parent controller to be customizable. 2012-01-02 20:39:22 +01:00
José Valim
a29a30effc Move InternalHelpers to parent controller. 2012-01-02 20:30:56 +01:00
José Valim
0af2722926 Let's depend on 3.1 forward. 2012-01-02 20:24:42 +01:00
José Valim
78efec09d5 Move notes to the top. 2012-01-02 20:24:42 +01:00
José Valim
1fdeadd113 Merge pull request #1188 from sj26/controller-inheritence
Make all controllers inherit from a single DeviseController
2012-01-02 11:24:33 -08:00
José Valim
a1464dbad7 Replace github.com/ by @ 2012-01-02 20:16:40 +01:00
José Valim
dd2a66d00c Update CHANGELOG. 2012-01-02 20:16:11 +01:00
José Valim
1152fda687 Only proxy to application controller if it exists. 2012-01-02 20:00:38 +01:00
José Valim
fd0e929087 Generate session routes for token authentication, but mark it as no_input. 2012-01-02 19:38:02 +01:00
José Valim
8b3e0e52f1 Generate routes again for token, closes #1526. 2012-01-02 19:27:05 +01:00
José Valim
8ff080fb99 Improve docs for params/http authenticatable. 2012-01-02 19:24:48 +01:00
José Valim
6bca228888 Merge pull request #1527 from joliss/generator
Use consistent number of hash signs
2012-01-02 10:21:41 -08:00
José Valim
fd1e588645 Merge pull request #1534 from jigyasa/master
Fix for a bug: Incorrect message for locked account
2012-01-02 10:04:17 -08:00
José Valim
024d9e6df7 Merge pull request #1537 from nashby/fix-issue-1530
regenerate confirmation token on reconfirmation
2011-12-31 04:03:14 -08:00
Vasiliy Ermolovich
aca8d3f34c regenerate confirmation token on reconfirmation, closes #1530 2011-12-31 14:22:58 +03:00
Jigyasa Makkar
e2030a740d Fixed a bug in lockable wherein when a user tries to login with correct password after being locked,
failed attempts count gets reset. When the user tries to login with an incorrect password next,
the message shown is for invalid password instead of locked account since this check
depended mainly on failed attempts count.
2011-12-29 23:57:39 +05:30
Jo Liss
27b745d04f Use consistent number of hash signs 2011-12-28 17:26:57 +01:00
José Valim
f712d07b23 Merge pull request #1516 from jm81/master
Move "include Devise::Models::Authenticatable" inside devise_modules_hook! call
2011-12-20 14:00:36 -08:00
Jared Morgan
f8ea5e0942 move include Devise::Models::Authenticatable inside devise_modules_hook! call
This allows alternate ORMs to run compatibility setup code before
Authenticatable is included.

The particular issue for dm-devise is that DataMapper does not have a
before_validation method, which is called when Authenticatable is included
(as of plataformatec/devise@bd27bf76). dm-devise adds before_validation in
it's devise_modules_hook!
2011-12-20 15:52:26 -06:00
José Valim
89db0dd44d Do not run validatins unless on reconfirmable branch, closes #1515. 2011-12-20 20:54:49 +01:00
José Valim
94e5a589b6 Update README.rdoc 2011-12-19 13:35:54 +01:00
José Valim
2dbb23f973 Update README.rdoc 2011-12-19 13:34:31 +01:00
José Valim
b71028dc73 Add a note to the README. 2011-12-19 13:33:33 +01:00
José Valim
f5aab14766 Release Devise 2.0.0.rc. 2011-12-19 13:31:24 +01:00
José Valim
273c5e99c1 Add space between messages. 2011-12-19 13:30:33 +01:00
José Valim
7ba37b5dc0 Improve messages. 2011-12-19 13:21:17 +01:00
José Valim
059d3856cf Update CHANGELOG. 2011-12-19 12:58:34 +01:00
José Valim
9dbd265fdd Update messages. 2011-12-19 12:55:41 +01:00
José Valim
09ae63f822 Update CHANGELOG.rdoc 2011-12-19 12:32:32 +01:00
T1D
c9becd3ea1 Allow regular expressions to avoid string conversion for parameter
filtering.
2011-12-14 10:41:24 -06:00
José Valim
5a245b3d55 Merge pull request #1508 from spagalloco/patch-1
Fixed gemnasium link in README to link to the web page and not the image
2011-12-12 13:57:06 -08:00
Steve Agalloco
7d3b16fe73 Fixed gemnasium link in README to link to the web page and not the image 2011-12-12 15:08:13 -05:00
José Valim
fd85b25d29 PathChecker should not attempt to validate invalid routes, closes #1505 2011-12-12 11:35:41 +01:00
José Valim
5eebf74f69 Fix a bug where passing :format => false to devise_for was permanent, closes #1504 2011-12-12 09:25:19 +01:00
José Valim
5a11c6597c Usage of Devise.stateless_token= is deprecated in favor of appending :token_auth to Devise.skip_session_storage 2011-12-11 20:39:41 +01:00
José Valim
930b324c15 Usage of confirm_within was deprecated in favor allow_unconfirmed_access_for 2011-12-11 20:18:02 +01:00
José Valim
d952dea32b Remove the code that was dynamically adding columns to active record 2011-12-11 20:07:50 +01:00
José Valim
9a6ac7ab69 Add confirmable to admin. 2011-12-11 20:07:50 +01:00
José Valim
df43ee640d Add Gemfile back to repository. 2011-12-11 20:07:50 +01:00
José Valim
309b57f4ea Merge pull request #1496 from laserlemon/patch-1
Add dependency status to README
2011-12-10 14:29:36 -08:00
José Valim
cc839caba5 Update CHANGELOG, rename method. 2011-12-10 23:28:23 +01:00
Steve Richert
d734648b15 Add dependency status to README 2011-12-09 15:46:52 -05:00
José Valim
006400905b Merge pull request #1493 from nashby/fix-issue-1486
redirect users to sign in page after unlock, closes #1486
2011-12-08 11:13:24 -08:00
Vasiliy Ermolovich
1e1e964d25 redirect users to sign in page after unlock, closes #1486 2011-12-08 22:06:09 +03:00
José Valim
263e0b7692 Fix failing test. 2011-12-07 13:23:55 +01:00
José Valim
01d4d0131b Merge pull request #1489 from dmitriy-kiriyenko/fix_delegator
Fix taking associated failure app from the scope in the given env.
2011-12-07 04:12:26 -08:00
Dmitriy Kiriyenko
f41e4befde Fix taking associated failure app from the scope in the given env.
There is a delegator to get failure app, introduced in 4629bee and tuned
in 24b26026. The latter commit introduced a bit of logic, however, no
tests are included into commit. Needless to say this resulted in a
broken code.

The point is that `env["warden.options"][:scope]` returns a string.
However, `Devise.mappings` is a hash with symbol keys.

Adding tests and converting scope to symbol here.
2011-12-07 14:09:00 +02:00
Rodrigo Flores
94fca31be8 Improving the unconfirmed message 2011-12-06 09:24:06 -02:00
Rodrigo Flores
19db459fca typo 2011-12-06 08:35:02 -02:00
José Valim
7693173ecd Final tidy up on removing schema helpers. 2011-12-05 12:17:02 +01:00
José Valim
a0294cbae8 Improve fields. 2011-12-05 12:02:25 +01:00
José Valim
1cf008cbe3 Remove apply schema from mongoid as well. 2011-12-05 11:48:27 +01:00
José Valim
87b84ffded Remove schema fields from Devise. 2011-12-05 11:28:04 +01:00
José Valim
035e56215d Enable reconfirmable by default and disable apply_schema. 2011-12-05 00:03:53 +01:00
José Valim
fa4d420fdb Update CHANGELOG. 2011-12-05 00:01:25 +01:00
José Valim
bd27bf7677 Deprecate and disable old behavior accumulated with time. 2011-12-04 23:58:19 +01:00
José Valim
03d9ebb56e Merge branch 'reconfirm' 2011-12-04 22:19:07 +01:00
José Valim
113b48a2ad Update CHANGELOG. 2011-12-04 22:18:58 +01:00
José Valim
6aed8f1c87 Clean up reconfirmable behavior. 2011-12-04 22:14:44 +01:00
José Valim
6d681c5b8a Merge remote-tracking branch 'heimidal/updates' into reconfirm
Conflicts:
	lib/devise/models/confirmable.rb
	test/support/helpers.rb
2011-12-04 20:58:41 +01:00
José Valim
b3034292f2 Ensure admin is running with manual lock strategy. 2011-12-01 13:19:05 +01:00
Brian Rose
7f754caba3 Merge branch 'master' into updates 2011-10-12 10:56:08 -06:00
Brian Rose
8c0f74f036 Add better message when user updates while reconfirmable is enabled. 2011-08-30 22:19:18 -06:00
Brian Rose
5a820262f9 Fix double-submit reconfirmation bug
Previously, if a user submitted their new email twice, they would bypass
the reconfirmation requirement and wind up auto-confirmed.
2011-08-30 22:19:18 -06:00
Brian Rose
3906456993 Clean up copy and use the Devise API a bit better. 2011-08-30 22:19:18 -06:00
Brian Rose
a1407565c8 Selectively add reconfirmable field in tests when necessary. 2011-08-30 22:19:18 -06:00
Brian Rose
a7c5a2e65d Fix up implementation of reconfirmable. 2011-08-30 22:19:17 -06:00
mandaryn
10ac4dbc35 reconfirmable uniqueness validations 2011-08-30 22:19:17 -06:00
mandaryn
6469cbc62a renamed confirmation_on_email_change property to reconfirmable and added reconfirmable explanations 2011-08-30 22:19:17 -06:00
mandaryn
1961de6b5d Add email confirmation when it is changed by a user 2011-08-30 22:19:17 -06:00
Samuel Cochran
2b64c6d951 Make all controllers inherit from a single DeviseController 2011-06-25 03:34:13 +08:00
172 changed files with 4719 additions and 2751 deletions

6
.gitignore vendored
View File

@@ -1,5 +1,5 @@
**/*/log/*
**/*/tmp/*
test/rails_app/log/*
test/rails_app/tmp/*
*~
coverage/*
*.sqlite3
@@ -8,5 +8,3 @@ rdoc/*
pkg
log
test/tmp/*
Gemfile.lock

View File

@@ -1,13 +1,35 @@
language: ruby
script: "bundle exec rake test"
rvm:
- 1.8.7
- 1.9.2
- ree
- rbx
- rbx-2.0
- 1.9.3
env:
- DEVISE_ORM=mongoid
- DEVISE_ORM=active_record
matrix:
exclude:
- rvm: 1.8.7
env: DEVISE_ORM=mongoid
gemfile: Gemfile
- rvm: 1.8.7
env: DEVISE_ORM=mongoid
gemfile: gemfiles/Gemfile.rails-3.1.x
- rvm: 1.9.2
env: DEVISE_ORM=mongoid
gemfile: Gemfile
- rvm: 1.9.2
env: DEVISE_ORM=mongoid
gemfile: gemfiles/Gemfile.rails-3.1.x
gemfile:
- gemfiles/Gemfile.rails-3.1.x
- Gemfile
services:
- mongodb
notifications:
recipients:
- jose.valim@plataformatec.com.br
- carlos@plataformatec.com.br
- rodrigo.flores@plataformatec.com.br
- rafael.franca@plataformatec.com.br
email: false
campfire:
on_success: change
on_failure: always
rooms:
- secure: "TRiqvuM4i/QmRDWjUSNitE5/P91BOzDkNl53+bZjjtxcISCswZtmECWBR7n9\n3xwqCOU1o2lfohxZ32OHOj/Nj7o+90zWJfWxcv+if0hIXRiil62M5pg0lZUd\nyJ4M5VQ0lSWo5he1OUrXhSabPJeaK3B8yT/tdh+qO5yzR+vb/jc="

9
.yardopts Normal file
View File

@@ -0,0 +1,9 @@
--protected
--no-private
--embed-mixin ClassMethods
-
README.md
CHANGELOG.rdoc
CONTRIBUTING.md
MIT-LICENSE

View File

@@ -1,8 +1,216 @@
== 2.2.8
Security announcement: http://blog.plataformatec.com.br/2013/11/e-mail-enumeration-in-devise-in-paranoid-mode
* bug fix
* Avoid e-mail enumeration on sign in when in paranoid mode
== 2.2.7
* bug fix
* Do not confirm account after reset password
== 2.2.6
* bug fix
* Skip storage for cookies on unverified requests
== 2.2.5
* bug fix
* 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.
== 2.2.4
* enhancements
* Add `destroy_with_password` to `DatabaseAuthenticatable`. Allows destroying a record when `:current_password` matches, similarly to how `update_with_password` works. (by @michiel3)
* Allow to override path after password resetting (by @worker8)
* Add `#skip_confirmation_notification!` method to `Confirmable`. Allows skipping confirmation email without auto-confirming. (by @gregates)
* allow_unconfirmed_access_for config from `:confirmable` module can be set to `nil` that means unconfirmed access for unlimited time. (by @nashby)
* Support Rails' token strategy on authentication (by @robhurring)
* Support explicitly setting the http authentication key via `config.http_authentication_key` (by @neo)
* bug fix
* Do not redirect when accessing devise API via JSON. (by @sebastianwr)
* Generating scoped devise views now uses the correct scoped shared links partial instead of the default devise one (by @nashby)
* Fix inheriting mailer templates from `Devise::Mailer`
* Fix a bug when procs are used as default mailer in Devise (by @tomasv)
== 2.2.3
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
* bug fix
* Fix bug when checking for reconfirmable in templates
== 2.2.1
* bug fix
* Fix regression with case_insensitive_keys
* Fix regression when password is blank when it is invalid
== 2.2.0
* backwards incompatible changes
* `headers_for` is deprecated, customize the mailer directly instead
* All mailer methods now expect a second argument with delivery options
* Default minimum password length is now 8 (by @carlosgaldino)
* Support alternate sign in error message when email record does not exist (this adds a new I18n key to the locale file) (by @gabetax)
* DeviseController responds only to HTML requests by default (call `DeviseController.respond_to` or `ApplicationController.respond_to` to add new formats)
* Support Mongoid 3 onwards (by @durran)
* enhancements
* Fix unlockable which could leak account existence on paranoid mode (by @latortuga)
* Confirmable now has a confirm_within option to set a period while the confirmation token is still valid (by @promisedlandt)
* Flash messages in controller now respects `resource_name` (by @latortuga)
* Separate `sign_in` and `sign_up` on RegistrationsController (by @rubynortheast)
* Add autofocus to default views (by @Radagaisus)
* Unlock user on password reset (by @marcinb)
* Allow validation callbacks to apply to virtual attributes (by @latortuga)
* bug fix
* unconfirmed_email now uses the proper e-mail on salutation
* Fix default email_regexp config to not allow spaces (by @kukula)
* Fix a regression introduced on warden 1.2.1 (by @ejfinneran)
* Properly camelize omniauth strategies (by @saizai)
* Do not set flash messages for non navigational requests on session sign out (by @mathieul)
* Set the proper fields as required on the lockable module (by @nickhoffman)
* Respects Devise mailer default's reply_to (by @mrchrisadams)
* Properly assign resource on `sign_in` related action (by @adammcnamara)
* `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.2
* enhancements
* Handle backwards incompatibility between Rails 3.2.6 and Thor 0.15.x
* bug fix
* Fix regression on strategy validation on previous release
== 2.1.1 (yanked)
* enhancements
* `sign_out_all_scopes` now locks warden and does not allow new logins in the same action
* `Devise.omniauth_path_prefix` is available to configure omniauth path prefix
* Redirect to sign in page when trying to access password#edit without a token (by @gbataille)
* Allow a lambda in authenticate(d) routes helpers to further select the scope
* Removed warnings on Rails 3.2.6 (by @nashby)
* bug fix
* `update_with_password` now relies on assign_attributes and forwards the :as option (by @wtn)
* Do not trigger timeout on sign in related actions
* Timeout does not explode when reset_authentication_token! is accidentally defined by Active Model (by @remomueller)
* deprecations
* Strategy#validate() no longer validates nil resources
== 2.1.0
* enhancements
* Add `check_fields!(model_class)` method on Devise::Models to check if the model includes the fields that Devise uses
* Add `skip_reconfirmation!` to skip reconfirmation
* Devise model generator now works with engines
* Devise encryptable was moved to its new gem (http://github.com/plataformatec/devise-encryptable)
* deprecations
* Deprecations warnings added on Devise 2.0 are now removed with their features
* All devise modules should now have a `required_fields(klass)` module method to help gathering missing attributes
* `use_salt_as_remember_token` and `apply_schema` does not have any effect since 2.0 and are now deprecated
* `valid_for_authentication?` must now return a boolean
* bug fix
* Ensure after sign in hook is not called without a resource
* Fix a term: now on Omniauth related flash messages, we say that we're authenticating from an omniauth provider instead of authorizing
* Fixed redirect when authenticated mounted apps (by @hakanensari)
* Ensure the failure app still respects config.relative_url_root
* `/users/sign_in` doesn't choke on protected attributes used to select sign in scope (by @Paymium)
* `failed_attempts` is set to zero after any sign in (including via reset password) (by @rodrigoflores)
* Added token expiration on timeout (by @antiarchitect)
* Do not accidentally mark `_prefixes` as private
* Better support for custom strategies on test helpers (by @mattconnolly)
* Return `head :no_content` in SessionsController now that most JS libraries handle it (by @julianvargasalvarez)
== 2.0.4
Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.0
* bug fix
* 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)
* bug fix
* Ensure warning is not shown by mistake on apps with mounted engines
* Fixes related to remember_token and rememberable_options
* Ensure serializable_hash does not depend on accessible attributes
* Ensure that timeout callback does not run on sign out action
== 2.0.2
* enhancements
* Add devise_i18n_options to customize I18n message
* bug fix
* Ensure Devise.available_router_name defaults to :main_app
* Set autocomplete to off for password on edit forms
* Better error messages in case a trackable model can't be saved
* 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
* enhancements
* Improved error messages on deprecation warnings
* Hide Devise's internal generators from `rails g` command
* bug fix
* Removed tmp and log files from gem
== 2.0.0
* enhancements
* Add support for e-mail reconfirmation on change (by @Mandaryn and @heimidal)
* Redirect users to sign in page after unlock (by @nashby)
* Redirect to the previous URL on timeout
* Inherit from the same Devise parent controller (by @sj26)
* Allow parent_controller to be customizable via Devise.parent_controller, useful for engines
* Allow router_name to be customizable via Devise.router_name, useful for engines
* Allow alternate ORMs to run compatibility setup code before Authenticatable is included (by @jm81)
* deprecation
* Devise now only supports Rails 3.1 forward
* Devise.confirm_within was deprecated in favor Devise.allow_unconfirmed_access_for
* Devise.stateless_token= is deprecated in favor of appending :token_auth to Devise.skip_session_storage
* Usage of Devise.apply_schema is deprecated
* Usage of Devise migration helpers are deprecated
* Usage of Devise.remember_across_browsers was deprecated
* Usage of rememberable with remember_token was removed
* Usage of recoverable without reset_password_sent_at was removed
* Usage of Devise.case_insensitive_keys equals to false was removed
* Move devise/shared/_links.erb to devise/_links.erb
* Deprecated support of nested devise_for blocks
* 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
* 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
* enhancements
* Add support for rails 3.1 new mass assignment conventions (by github.com/kirs)
* Add timeout_in method to Timeoutable, it can be overriden in a model (by github.com/lest)
* Add support for Rails 3.1 new mass assignment conventions (by @kirs)
* Add timeout_in method to Timeoutable, it can be overridden in a model (by @lest)
* bug fix
* OmniAuth error message now shows the proper option (:strategy_class instead of :klass)
@@ -17,10 +225,10 @@
* enhancements
* Timeoutable also skips tracking if skip_trackable is given
* devise_for now accepts :failure_app as an option
* Models can select the proper mailer via devise_mailer method (by github.com/locomotivecms)
* Migration generator now uses the change method (by github.com/nashby)
* Support to markerb templates on the mailer generator (by github.com/sbounmy)
* Support for Omniauth 1.0 (older versions are no longer supported) (by github.com/TamiasSibiricus)
* Models can select the proper mailer via devise_mailer method (by @locomotivecms)
* Migration generator now uses the change method (by @nashby)
* Support to markerb templates on the mailer generator (by @sbounmy)
* Support for Omniauth 1.0 (older versions are no longer supported) (by @TamiasSibiricus)
* bug fix
* Allow idempotent API requests
@@ -51,7 +259,7 @@
* bug fix
* Fix backward incompatible change from 1.4.6 for those using custom controllers
== 1.4.6
== 1.4.6 (yanked)
* enhancements
* Allow devise_for :skip => :all
@@ -63,7 +271,7 @@
* bug fix
* Failure app tries the root path if a session one does not exist
* No need to finalize Devise helpers all the time (by github.com/bradleypriest)
* No need to finalize Devise helpers all the time (by @bradleypriest)
* Reset password shows proper message if user is not active
* `clean_up_passwords` sets the accessors to nil to skip validations
@@ -98,7 +306,7 @@
* enhancements
* Add :defaults and :format support on router
* Add simple form generators
* Better localization for devise_error_messages! (by github.com/zedtux)
* Better localization for devise_error_messages! (by @zedtux)
* bug fix
* Ensure to_xml is properly white listened
@@ -107,20 +315,20 @@
== 1.4.0
* enhancements
* Added authenticated and unauthenticated to the router to route the used based on his status (by github.com/sj26)
* Improve e-mail regexp (by github.com/rodrigoflores)
* Add strip_whitespace_keys and default to e-mail (by github.com/swrobel)
* Do not run format and uniqueness validations on e-mail if it hasn't changed (by github.com/Thibaut)
* Added update_without_password to update models but not allowing the password to change (by github.com/fschwahn)
* Added config.paranoid, check the generator for more information (by github.com/rodrigoflores)
* Added authenticated and unauthenticated to the router to route the used based on his status (by @sj26)
* Improve e-mail regexp (by @rodrigoflores)
* Add strip_whitespace_keys and default to e-mail (by @swrobel)
* Do not run format and uniqueness validations on e-mail if it hasn't changed (by @Thibaut)
* Added update_without_password to update models but not allowing the password to change (by @fschwahn)
* Added config.paranoid, check the generator for more information (by @rodrigoflores)
* bug fix
* password_required? should not affect length validation
* User cannot access sign up and similar pages if he is already signed in through a cookie or token
* Do not convert booleans to strings on finders (by github.com/xavier)
* Run validations even if current_password fails (by github.com/crx)
* Devise now honors routes constraints (by github.com/macmartine)
* Do not return the user resource when requesting instructions (by github.com/rodrigoflores)
* Do not convert booleans to strings on finders (by @xavier)
* Run validations even if current_password fails (by @crx)
* Devise now honors routes constraints (by @macmartine)
* Do not return the user resource when requesting instructions (by @rodrigoflores)
== 1.3.4
@@ -135,31 +343,31 @@
== 1.3.2
* bug fix
* Fix another regression related to reset_password_sent_at (by github.com/alexdreher)
* Fix another regression related to reset_password_sent_at (by @alexdreher)
== 1.3.1
* enhancements
* Improve failure_app responses (by github.com/indirect)
* Improve failure_app responses (by @indirect)
* sessions/new and registrations/new also respond to xml and json now
* bug fix
* Fix a regression that occurred if reset_password_sent_at is not present (by github.com/stevehodgkiss)
* Fix a regression that occurred if reset_password_sent_at is not present (by @stevehodgkiss)
== 1.3.0
* enhancements
* All controllers can now handle different mime types than html using Responders (by github.com/sikachu)
* Added reset_password_within as configuration option to send the token for recovery (by github.com/jdguyot)
* Bump password length to 128 characters (by github.com/k33l0r)
* Add :only as option to devise_for (by github.com/timoschilling)
* Allow to override path after sending password instructions (by github.com/irohiroki)
* require_no_authentication has its own flash message (by github.com/jackdempsey)
* All controllers can now handle different mime types than html using Responders (by @sikachu)
* Added reset_password_within as configuration option to send the token for recovery (by @jdguyot)
* Bump password length to 128 characters (by @k33l0r)
* Add :only as option to devise_for (by @timoschilling)
* Allow to override path after sending password instructions (by @irohiroki)
* require_no_authentication has its own flash message (by @jackdempsey)
* bug fix
* Fix a bug where configuration options were being included too late
* Ensure Devise::TestHelpers can be used to tests Devise internal controllers (by github.com/jwilger)
* valid_password? should not choke on empty passwords (by github.com/mikel)
* Ensure Devise::TestHelpers can be used to tests Devise internal controllers (by @jwilger)
* valid_password? should not choke on empty passwords (by @mikel)
* Calling devise more than once does not include previously added modules anymore
* downcase_keys before validation
@@ -186,16 +394,16 @@
* bug fix
* Fix an issue causing infinite redirects in production
* rails g destroy works properly with devise generators (by github.com/andmej)
* before_failure callbacks should work on test helpers (by github.com/twinge)
* rememberable cookie now is httponly by default (by github.com/JamesFerguson)
* Add missing confirmation_keys (by github.com/JohnPlummer)
* rails g destroy works properly with devise generators (by @andmej)
* before_failure callbacks should work on test helpers (by @twinge)
* rememberable cookie now is httponly by default (by @JamesFerguson)
* Add missing confirmation_keys (by @JohnPlummer)
* Ensure after_* hooks are called on RegistrationsController
* When using database_authenticatable Devise will now only create an email field when appropriate (if using default authentication_keys or custom authentication_keys with email included)
* Ensure stateless token does not trigger timeout (by github.com/pixelauthority)
* Ensure stateless token does not trigger timeout (by @pixelauthority)
* Implement handle_unverified_request for Rails 3.0.4 compatibility and improve FailureApp reliance on symbols
* Consider namespaces while generating routes
* Custom failure apps no longer ignored in test mode (by github.com/jaghion)
* Custom failure apps no longer ignored in test mode (by @jaghion)
* Do not depend on ActiveModel::Dirty
* Manual sign_in now triggers remember token
* Be sure to halt strategies on failures
@@ -204,7 +412,7 @@
* Ensure there is no Mongoid injection
* deprecations
* Deprecated anybody_signed_in? in favor of signed_in? (by github.com/gavinhughes)
* Deprecated anybody_signed_in? in favor of signed_in? (by @gavinhughes)
* Removed --haml and --slim view templates
* Devise::OmniAuth helpers were deprecated and removed in favor of Omniauth.config.test_mode
@@ -217,11 +425,11 @@
* enhancements
* Added OmniAuth support
* Added ORM adapter to abstract ORM iteraction
* sign_out_via is available in the router to configure the method used for sign out (by github.com/martinrehfeld)
* Improved Ajax requests handling in failure app (by github.com/spastorino)
* sign_out_via is available in the router to configure the method used for sign out (by @martinrehfeld)
* Improved Ajax requests handling in failure app (by @spastorino)
* Added request_keys to easily use request specific values (like subdomain) in authentication
* Increased the size of friendly_token to 60 characters (reduces the chances of a successful brute attack)
* Ensure the friendly token does not include "_" or "-" since some e-mails may not autolink it properly (by github.com/rymai)
* Ensure the friendly token does not include "_" or "-" since some e-mails may not autolink it properly (by @rymai)
* Extracted encryptors into :encryptable for better bcrypt support
* :rememberable is now able to use salt as token if no remember_token is provided
* Store the salt in session and expire the session if the user changes his password
@@ -230,7 +438,7 @@
* Sign up now check if the user is active or not and redirect him accordingly setting the inactive_signed_up message
* Use ActiveModel#to_key instead of #id
* sign_out_all_scopes now destroys the whole session
* Added case_insensitive_keys that automatically downcases the given keys, by default downcases only e-mail (by github.com/adahl)
* Added case_insensitive_keys that automatically downcases the given keys, by default downcases only e-mail (by @adahl)
* default behavior changes
* sign_out_all_scopes defaults to true as security measure
@@ -239,12 +447,12 @@
* bugfix
* after_sign_in_path_for always receives a resource
* Do not execute Warden::Callbacks on Devise::TestHelpers (by github.com/sgronblo)
* Allow password recovery and account unlocking to change used keys (by github.com/RStankov)
* Do not execute Warden::Callbacks on Devise::TestHelpers (by @sgronblo)
* Allow password recovery and account unlocking to change used keys (by @RStankov)
* FailureApp now properly handles nil request.format
* Fix a bug causing FailureApp to return with HTTP Auth Headers for IE7
* Ensure namespaces has proper scoped views
* Ensure Devise does not set empty flash messages (by github.com/sxross)
* Ensure Devise does not set empty flash messages (by @sxross)
== 1.1.6
@@ -269,11 +477,11 @@
* bugfix
* Add reply-to to e-mail headers by default
* Updated the views generator to respect the rails :template_engine option (by github.com/fredwu)
* Updated the views generator to respect the rails :template_engine option (by @fredwu)
* Check the type of HTTP Authentication before using Basic headers
* Avoid invalid_salt errors by checking salt presence (by github.com/thibaudgg)
* Forget user deletes the right cookie before logout, not remembering the user anymore (by github.com/emtrane)
* Fix for failed first-ever logins on PostgreSQL where column default is nil (by github.com/bensie)
* Avoid invalid_salt errors by checking salt presence (by @thibaudgg)
* Forget user deletes the right cookie before logout, not remembering the user anymore (by @emtrane)
* 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
@@ -289,16 +497,16 @@
== 1.1.0
* enhancements
* Rememberable module allows user to be remembered across browsers and is enabled by default (by github.com/trevorturk)
* Rememberable module allows you to activate the period the remember me token is extended (by github.com/trevorturk)
* Rememberable module allows user to be remembered across browsers and is enabled by default (by @trevorturk)
* Rememberable module allows you to activate the period the remember me token is extended (by @trevorturk)
* devise_for can now be used together with scope method in routes but with a few limitations (check the documentation)
* Support `as` or `devise_scope` in the router to specify controller access scope
* HTTP Basic Auth can now be disabled/enabled for xhr(ajax) requests using http_authenticatable_on_xhr option (by github.com/pellja)
* HTTP Basic Auth can now be disabled/enabled for xhr(ajax) requests using http_authenticatable_on_xhr option (by @pellja)
* bug fix
* Fix a bug in Devise::TestHelpers where current_user was returning a Response object for non active accounts
* Devise should respect script_name and path_info contracts
* Fix a bug when accessing a path with (.:format) (by github.com/klacointe)
* Fix a bug when accessing a path with (.:format) (by @klacointe)
* Do not add unlock routes unless unlock strategy is email or both
* Email should be case insensitive
* Store classes as string in session, to avoid serialization and stale data issues
@@ -309,10 +517,10 @@
== 1.1.rc2
* enhancements
* Allow to set cookie domain for the remember token. (by github.com/mantas)
* Allow to set cookie domain for the remember token. (by @mantas)
* Added navigational formats to specify when it should return a 302 and when a 401.
* Added authenticate(scope) support in routes (by github.com/wildchild)
* Added after_update_path_for to registrations controller (by github.com/thedelchop)
* Added authenticate(scope) support in routes (by @wildchild)
* Added after_update_path_for to registrations controller (by @thedelchop)
* Allow the mailer object to be replaced through config.mailer = "MyOwnMailer"
* bug fix
@@ -360,10 +568,10 @@
* enhancements
* Support for latest MongoMapper
* Added anybody_signed_in? helper (by github.com/SSDany)
* Added anybody_signed_in? helper (by @SSDany)
* bug fix
* confirmation_required? is properly honored on active? calls. (by github.com/paulrosania)
* confirmation_required? is properly honored on active? calls. (by @paulrosania)
== 1.0.7
@@ -404,7 +612,7 @@
== 1.0.2
* enhancements
* Allows you set mailer content type (by github.com/glennr)
* Allows you set mailer content type (by @glennr)
* bug fix
* Uses the same content type as request on http authenticatable 401 responses
@@ -437,12 +645,12 @@
* enhancements
* Added gemspec to repo
* Added token authenticatable (by github.com/grimen)
* Added token authenticatable (by @grimen)
== 0.9.1
* bug fix
* Allow bigger salt size (by github.com/jgeiger)
* Allow bigger salt size (by @jgeiger)
* Fix relative url root
== 0.9.0
@@ -452,11 +660,11 @@
* :success and :failure flash messages are now :notice and :alert
* enhancements
* Added devise lockable (by github.com/mhfs)
* Added devise lockable (by @mhfs)
* Warden 0.9.0 compatibility
* Mongomapper 0.6.10 compatibility
* Added Devise.add_module as hooks for extensions (by github.com/grimen)
* Ruby 1.9.1 compatibility (by github.com/grimen)
* Added Devise.add_module as hooks for extensions (by @grimen)
* Ruby 1.9.1 compatibility (by @grimen)
* bug fix
* Accept path prefix not starting with slash
@@ -465,10 +673,10 @@
== 0.8.2
* enhancements
* Allow Devise.mailer_sender to be a proc (by github.com/grimen)
* Allow Devise.mailer_sender to be a proc (by @grimen)
* bug fix
* Fix bug with passenger, update is required to anyone deploying on passenger (by github.com/dvdpalm)
* Fix bug with passenger, update is required to anyone deploying on passenger (by @dvdpalm)
== 0.8.1
@@ -485,11 +693,11 @@
* enhancements
* Warden 0.8.0 compatibility
* Add an easy for map.connect "sign_in", :controller => "sessions", :action => "new" to work
* Added :bcrypt encryptor (by github.com/capotej)
* Added :bcrypt encryptor (by @capotej)
* bug fix
* sign_in_count is also increased when user signs in via password change, confirmation, etc..
* More DataMapper compatibility (by github.com/lancecarlson)
* More DataMapper compatibility (by @lancecarlson)
* deprecation
* Removed DeviseMailer.sender
@@ -529,7 +737,7 @@
== 0.7.1
* enhancements
* Small enhancements for other plugins compatibility (by github.com/grimen)
* Small enhancements for other plugins compatibility (by @grimen)
== 0.7.0
@@ -623,9 +831,9 @@
* Fixed a bug where remember me module was not working properly
* enhancements
* Moved encryption strategy into the Encryptors module to allow several algorithms (by github.com/mhfs)
* Implemented encryptors for Clearance, Authlogic and Restful-Authentication (by github.com/mhfs)
* Added support for MongoMapper (by github.com/shingara)
* Moved encryption strategy into the Encryptors module to allow several algorithms (by @mhfs)
* Implemented encryptors for Clearance, Authlogic and Restful-Authentication (by @mhfs)
* Added support for MongoMapper (by @shingara)
== 0.4.3

14
CONTRIBUTING.md Normal file
View File

@@ -0,0 +1,14 @@
### Please read before contributing
1) Do not post questions in the issues tracker. If you have any questions about Devise, search the [Wiki](https://github.com/plataformatec/devise/wiki) or use the [Mailing List](https://groups.google.com/group/plataformatec-devise) or [Stack Overflow](http://stackoverflow.com/questions/tagged/devise).
2) If you find a security bug, **DO NOT** submit an issue here. Please send an e-mail to [developers@plataformatec.com.br](mailto:developers@plataformatec.com.br) instead.
3) Do a small search on the issues tracker before submitting your issue to see if it was already reported / fixed.
4) When reporting an issue, include Rails, Devise and Warden versions. If you are getting exceptions, please include the full backtrace.
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.
Thanks!

21
Gemfile
View File

@@ -1,8 +1,8 @@
source "http://rubygems.org"
source "https://rubygems.org"
gemspec
gem "rails", "~> 3.1.0"
gem "rails", "~> 3.2.6"
gem "omniauth", "~> 1.0.0"
gem "omniauth-oauth2", "~> 1.0.0"
gem "rdoc"
@@ -10,12 +10,8 @@ gem "rdoc"
group :test do
gem "omniauth-facebook"
gem "omniauth-openid", "~> 1.0.1"
gem "webrat", "0.7.2", :require => false
gem "mocha", :require => false
platforms :mri_18 do
gem "ruby-debug", ">= 0.10.3"
end
gem "webrat", "0.7.3", :require => false
gem "mocha", "~> 0.13.1", :require => false
end
platforms :jruby do
@@ -25,11 +21,12 @@ platforms :jruby do
end
platforms :ruby do
gem "sqlite3-ruby"
gem "sqlite3"
end
platforms :mri_19 do
group :mongoid do
gem "mongo", "~> 1.3.0"
gem "mongoid", "~> 2.0"
gem "bson_ext", "~> 1.3.0"
gem "mongoid", "~> 3.0"
end
end

156
Gemfile.lock Normal file
View File

@@ -0,0 +1,156 @@
PATH
remote: .
specs:
devise (2.2.8)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.1)
railties (~> 3.1)
warden (~> 1.2.1)
GEM
remote: https://rubygems.org/
specs:
actionmailer (3.2.13)
actionpack (= 3.2.13)
mail (~> 2.5.3)
actionpack (3.2.13)
activemodel (= 3.2.13)
activesupport (= 3.2.13)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.4)
rack (~> 1.4.5)
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.2.1)
activemodel (3.2.13)
activesupport (= 3.2.13)
builder (~> 3.0.0)
activerecord (3.2.13)
activemodel (= 3.2.13)
activesupport (= 3.2.13)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activeresource (3.2.13)
activemodel (= 3.2.13)
activesupport (= 3.2.13)
activesupport (3.2.13)
i18n (= 0.6.1)
multi_json (~> 1.0)
arel (3.0.2)
bcrypt-ruby (3.1.2)
builder (3.0.4)
erubis (2.7.0)
faraday (0.8.7)
multipart-post (~> 1.1)
hashie (1.2.0)
hike (1.2.2)
httpauth (0.2.0)
i18n (0.6.1)
journey (1.0.4)
json (1.7.7)
jwt (0.1.8)
multi_json (>= 1.5)
mail (2.5.3)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
metaclass (0.0.1)
mime-types (1.22)
mocha (0.13.3)
metaclass (~> 0.0.1)
mongoid (3.1.2)
activemodel (~> 3.2)
moped (~> 1.4.2)
origin (~> 1.0)
tzinfo (~> 0.3.22)
moped (1.4.5)
multi_json (1.7.2)
multipart-post (1.2.0)
nokogiri (1.5.9)
oauth2 (0.8.1)
faraday (~> 0.8)
httpauth (~> 0.1)
jwt (~> 0.1.4)
multi_json (~> 1.0)
rack (~> 1.2)
omniauth (1.0.3)
hashie (~> 1.2)
rack
omniauth-facebook (1.4.0)
omniauth-oauth2 (~> 1.0.2)
omniauth-oauth2 (1.0.3)
oauth2 (~> 0.8.0)
omniauth (~> 1.0)
omniauth-openid (1.0.1)
omniauth (~> 1.0)
rack-openid (~> 1.3.1)
origin (1.0.11)
orm_adapter (0.4.0)
polyglot (0.3.3)
rack (1.4.5)
rack-cache (1.2)
rack (>= 0.4)
rack-openid (1.3.1)
rack (>= 1.1.0)
ruby-openid (>= 2.1.8)
rack-ssl (1.3.3)
rack
rack-test (0.6.2)
rack (>= 1.0)
rails (3.2.13)
actionmailer (= 3.2.13)
actionpack (= 3.2.13)
activerecord (= 3.2.13)
activeresource (= 3.2.13)
activesupport (= 3.2.13)
bundler (~> 1.0)
railties (= 3.2.13)
railties (3.2.13)
actionpack (= 3.2.13)
activesupport (= 3.2.13)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
rake (10.0.4)
rdoc (3.12.2)
json (~> 1.4)
ruby-openid (2.2.3)
sprockets (2.2.2)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.7)
thor (0.18.1)
tilt (1.3.7)
treetop (1.4.12)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.37)
warden (1.2.3)
rack (>= 1.0)
webrat (0.7.3)
nokogiri (>= 1.2.0)
rack (>= 1.0)
rack-test (>= 0.5.3)
PLATFORMS
ruby
DEPENDENCIES
activerecord-jdbc-adapter
activerecord-jdbcsqlite3-adapter
devise!
jruby-openssl
mocha (~> 0.13.1)
mongoid (~> 3.0)
omniauth (~> 1.0.0)
omniauth-facebook
omniauth-oauth2 (~> 1.0.0)
omniauth-openid (~> 1.0.1)
rails (~> 3.2.6)
rdoc
sqlite3
webrat (= 0.7.3)

View File

@@ -1,4 +1,4 @@
Copyright 2009-2011 Plataforma Tecnologia. http://blog.plataformatec.com.br
Copyright 2009-2013 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

400
README.md Normal file
View File

@@ -0,0 +1,400 @@
![Devise Logo](https://raw.github.com/plataformatec/devise/master/devise.png)
By [Plataformatec](http://plataformatec.com.br/).
[![Gem Version](https://fury-badge.herokuapp.com/rb/devise.png)](http://badge.fury.io/rb/devise)
[![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)
This README is [also available in a friendly navigable format](http://devise.plataformatec.com.br/).
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 roles (or models/scopes) signed in at the same time;
* Is based on a modularity concept: use just what you really need.
It's composed of 11 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.
* [Token Authenticatable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/TokenAuthenticatable): signs in a user based on an authentication token (also known as "single access token"). The token can be given both through query string or HTTP Basic Authentication.
* [Omniauthable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Omniauthable): adds Omniauth (https://github.com/intridea/omniauth) support;
* [Confirmable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Confirmable): sends emails with confirmation instructions and verifies whether an account is already confirmed during sign in.
* [Recoverable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Recoverable): resets the user password and sends reset instructions.
* [Registerable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Registerable): handles signing up users through a registration process, also allowing them to edit and destroy their account.
* [Rememberable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Rememberable): manages generating and clearing a token for remembering the user from a saved cookie.
* [Trackable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Trackable): tracks sign in count, timestamps and IP address.
* [Timeoutable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Timeoutable): expires sessions that have no activity in a specified period of time.
* [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.
## Information
### The Devise wiki
The Devise Wiki has lots of additional information about Devise including many "how-to" articles and answers to the most frequently asked questions. Please browse the Wiki after finishing this README:
https://wiki.github.com/plataformatec/devise
### Bug reports
If you discover a problem with Devise, we would like to know about it. However, we ask that you please review these guidelines before submitting a bug report:
https://github.com/plataformatec/devise/wiki/Bug-reports
If you found a security bug, do *NOT* use the GitHub issue tracker. Send an email to the maintainers listed at the bottom of the README.
### Mailing list
If you have any questions, comments, or concerns, please use the Google Group instead of the GitHub issue tracker:
https://groups.google.com/group/plataformatec-devise
### RDocs
You can view the Devise documentation in RDoc format here:
http://rubydoc.info/github/plataformatec/devise/master/frames
If you need to use Devise with Rails 2.3, you can always run "gem server" from the command line after you install the gem to access the old documentation.
### Example applications
There are a few example applications available on GitHub that demonstrate various features of Devise with different versions of Rails. You can view them here:
https://github.com/plataformatec/devise/wiki/Example-Applications
### Extensions
Our community has created a number of extensions that add functionality above and beyond what is included with Devise. You can view a list of available extensions and add your own here:
https://github.com/plataformatec/devise/wiki/Extensions
### Contributing
We hope that you will consider contributing to Devise. Please read this short overview for some information about how to get started:
https://github.com/plataformatec/devise/wiki/Contributing
You will usually want to write tests for your changes. To run the test suite, go into Devise's top-level directory and run "bundle install" and "rake". For the tests to pass, you will need to have a MongoDB server (version 2.0 or newer) running on your system.
## 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:
* Michael Hartl's online book: http://railstutorial.org/chapters/modeling-and-viewing-users-two#top
* Ryan Bates' Railscast: http://railscasts.com/episodes/250-authentication-from-scratch
Once you have solidified your understanding of Rails and authentication mechanisms, we assure you Devise will be very pleasant to work with. :)
## Getting started
Devise 2.0 works with Rails 3.1 onwards. You can add it to your Gemfile with:
```ruby
gem 'devise'
```
Run the bundle command to install it.
After you install Devise and add it to your Gemfile, you need to run the generator:
```console
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:
```console
rails generate devise MODEL
```
Replace MODEL by the class name used for the applications users, it's frequently 'User' but could also be 'Admin'. This will create a model (if one does not exist) and configure it with default Devise modules. Next, you'll usually run "rake db:migrate" as the generator will have created a migration file (if your ORM supports them). This generator also configures your config/routes.rb file to point to the Devise controller.
Note that you should re-start your app here if you've already started it. Otherwise you'll run into strange errors like users being unable to login and the route helpers being undefined.
### Controller filters and helpers
Devise will create some helpers to use inside your controllers and views. To set up a controller with user authentication, just add this before_filter:
```ruby
before_filter :authenticate_user!
```
To verify if a user is signed in, use the following helper:
```ruby
user_signed_in?
```
For the current signed-in user, this helper is available:
```ruby
current_user
```
You can access the session for this scope:
```ruby
user_session
```
After signing in a user, confirming the account or updating the password, Devise will look for a scoped root path to redirect. Example: For a :user resource, it will use `user_root_path` if it exists, otherwise default `root_path` will be used. This means that you need to set the root inside your routes:
```ruby
root :to => "home#index"
```
You can also overwrite `after_sign_in_path_for` and `after_sign_out_path_for` to customize your redirect hooks.
Finally, you need to set up default url options for the mailer in each environment. Here is the configuration for "config/environments/development.rb":
```ruby
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
```
Notice that if your devise model is not called "user" but "member", then the helpers you should use are:
```ruby
before_filter :authenticate_member!
member_signed_in?
current_member
member_session
```
### Configuring Models
The devise method in your models also accepts some options to configure its modules. For example, you can choose the cost of the encryption algorithm with:
```ruby
devise :database_authenticatable, :registerable, :confirmable, :recoverable, :stretches => 20
```
Besides :stretches, you can define :pepper, :encryptor, :confirm_within, :remember_for, :timeout_in, :unlock_in and other values. For details, see the initializer file that was created when you invoked the "devise:install" generator described above.
### Configuring multiple models
Devise allows you to set up as many roles as you want. For example, you may have a User model and also want an Admin model with just authentication and timeoutable features. If so, just follow these steps:
```ruby
# Create a migration with the required fields
create_table :admins do |t|
t.string :email
t.string :encrypted_password
t.timestamps
end
# Inside your Admin model
devise :database_authenticatable, :timeoutable
# Inside your routes
devise_for :admins
# Inside your protected controller
before_filter :authenticate_admin!
# Inside your controllers and views
admin_signed_in?
current_admin
admin_session
```
On the other hand, you can simply run the generator!
### Configuring views
We built Devise to help you quickly develop an application that uses authentication. However, we don't want to be in your way when you need to customize it.
Since Devise is an engine, all its views are packaged inside the gem. These views will help you get started, but after some time you may want to change them. If this is the case, you just need to invoke the following generator, and it will copy all views to your application:
```console
rails generate devise:views
```
If you have more than one role in your application (such as "User" and "Admin"), you will notice that Devise uses the same views for all roles. Fortunately, Devise offers an easy way to customize views. All you need to do is set "config.scoped_views = true" inside "config/initializers/devise.rb".
After doing so, you will be able to have views based on the role like "users/sessions/new" and "admins/sessions/new". If no view is found within the scope, Devise will use the default view at "devise/sessions/new". You can also use the generator to generate scoped views:
```console
rails generate devise:views users
```
### Configuring controllers
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:
```ruby
class Admins::SessionsController < Devise::SessionsController
end
```
2) Tell the router to use this controller:
```ruby
devise_for :admins, :controllers => { :sessions => "admins/sessions" }
```
3) And since we changed the controller, it won't use the "devise/sessions" views, so remember to copy "devise/sessions" to "admin/sessions".
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 specific keys or at least remove the `:timedout` key from the hash as Devise adds this key in some circumstances, this key is not meant for display.
### Configuring routes
Devise also ships with default routes. If you need to customize them, you should probably be able to do it through the devise_for method. It accepts several options like :class_name, :path_prefix and so on, including the possibility to change path names for I18n:
```ruby
devise_for :users, :path => "auth", :path_names => { :sign_in => 'login', :sign_out => 'logout', :password => 'secret', :confirmation => 'verification', :unlock => 'unblock', :registration => 'register', :sign_up => 'cmon_let_me_in' }
```
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:
```ruby
devise_scope :user do
get "sign_in", :to => "devise/sessions#new"
end
```
This way you tell devise to use the scope :user when "/sign_in" is accessed. Notice `devise_scope` is also aliased as `as` in your router.
### 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:
```yaml
en:
devise:
sessions:
signed_in: 'Signed in successfully.'
```
You can also create distinct messages based on the resource you've configured using the singular name given in routes:
```yaml
en:
devise:
sessions:
user:
signed_in: 'Welcome user, you are signed in.'
admin:
signed_in: 'Hello admin!'
```
The Devise mailer uses a similar pattern to create subject messages:
```yaml
en:
devise:
mailer:
confirmation_instructions:
subject: 'Hello everybody!'
user_subject: 'Hello User! Please confirm your email'
reset_password_instructions:
subject: 'Reset instructions'
```
Take a look at our locale file to check all available messages. You may also be interested in one of the many translations that are available on our wiki:
https://github.com/plataformatec/devise/wiki/I18n
### Test helpers
Devise includes some tests helpers for functional specs. In order to use them, you need to include Devise in your functional tests by adding the following to the bottom of your `test/test_helper.rb` file:
```ruby
class ActionController::TestCase
include Devise::TestHelpers
end
```
If you're using RSpec, you can put the following inside a file named `spec/support/devise.rb`:
```ruby
RSpec.configure do |config|
config.include Devise::TestHelpers, :type => :controller
end
```
Now you are ready to use the `sign_in` and `sign_out` methods. Such methods have the same signature as in controllers:
```ruby
sign_in :user, @user # sign_in(scope, resource)
sign_in @user # sign_in(resource)
sign_out :user # sign_out(scope)
sign_out @user # sign_out(resource)
```
There are two things that is 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 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:
@request.env["devise.mapping"] = Devise.mappings[:user]
get :new
### Omniauth
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`:
```ruby
config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'
```
You can read more about Omniauth support in the wiki:
* https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview
### Other ORMs
Devise supports ActiveRecord (default) and Mongoid. To choose other ORM, you just need to require it in the initializer file.
### Migrating from other solutions
Devise implements encryption strategies for Clearance, Authlogic and Restful-Authentication. To make use of these strategies, you need set the desired encryptor in the encryptor initializer config option and add :encryptable to your model. You might also need to rename your encrypted password and salt columns to match Devise's fields (encrypted_password and password_salt).
## Troubleshooting
### Heroku
Using devise on Heroku with Ruby on Rails 3.1 requires setting:
```ruby
config.assets.initialize_on_precompile = false
```
Read more about the potential issues at http://guides.rubyonrails.org/asset_pipeline.html
## Additional information
### Warden
Devise is based on Warden, which is a general Rack authentication framework created by Daniel Neighman. We encourage you to read more about Warden here:
https://github.com/hassox/warden
### Contributors
We have a long list of valued contributors. Check them all at:
https://github.com/plataformatec/devise/contributors
### Maintainers
* José Valim (https://github.com/josevalim)
* Carlos Antônio da Silva (https://github.com/carlosantoniodasilva)
* Rodrigo Flores (https://github.com/rodrigoflores)
## License
MIT License. Copyright 2009-2013 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.

View File

@@ -1,366 +0,0 @@
== Devise
{<img src="https://secure.travis-ci.org/plataformatec/devise.png" />}[http://travis-ci.org/plataformatec/devise]
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 roles (or models/scopes) signed in at the same time;
* Is based on a modularity concept: use just what you really need.
It's comprised of 12 modules:
* Database Authenticatable: 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.
* Token Authenticatable: signs in a user based on an authentication token (also known as "single access token"). The token can be given both through query string or HTTP Basic Authentication.
* Omniauthable: adds Omniauth (github.com/intridea/omniauth) support;
* Confirmable: sends emails with confirmation instructions and verifies whether an account is already confirmed during sign in.
* Recoverable: resets the user password and sends reset instructions.
* Registerable: handles signing up users through a registration process, also allowing them to edit and destroy their account.
* Rememberable: manages generating and clearing a token for remembering the user from a saved cookie.
* Trackable: tracks sign in count, timestamps and IP address.
* Timeoutable: expires sessions that have no activity in a specified period of time.
* Validatable: provides validations of email and password. It's optional and can be customized, so you're able to define your own validations.
* Lockable: locks an account after a specified number of failed sign-in attempts. Can unlock via email or after a specified time period.
* Encryptable: adds support of other authentication mechanisms besides the built-in Bcrypt (the default).
== Information
=== The Devise wiki
The Devise Wiki has lots of additional information about Devise including many "how-to" articles and answers to the most frequently asked questions. Please browse the Wiki after finishing this README:
https://wiki.github.com/plataformatec/devise
=== Bug reports
If you discover a problem with Devise, we would like to know about it. However, we ask that you please review these guidelines before submitting a bug report:
https://github.com/plataformatec/devise/wiki/Bug-reports
If you found a security bug, do *NOT* use the GitHub issue tracker. Send email or a private GitHub message to the maintainers listed at the bottom of the README.
=== Mailing list
If you have any questions, comments, or concerns, please use the Google Group instead of the GitHub issue tracker:
https://groups.google.com/group/plataformatec-devise
=== RDocs
You can view the Devise documentation in RDoc format here:
http://rubydoc.info/github/plataformatec/devise/master/frames
If you need to use Devise with Rails 2.3, you can always run `gem server` from the command line after you install the gem to access the old documentation.
=== Example applications
There are a few example applications available on GitHub that demonstrate various features of Devise with different versions of Rails. You can view them here:
https://github.com/plataformatec/devise/wiki/Example-Applications
=== Extensions
Our community has created a number of extensions that add functionality above and beyond what is included with Devise. You can view a list of available extensions and add your own here:
https://github.com/plataformatec/devise/wiki/Extensions
=== Contributing
We hope that you will consider contributing to Devise. Please read this short overview for some information about how to get started:
https://github.com/plataformatec/devise/wiki/Contributing
You will usually want to write tests for your changes. To run the test suite, `cd` into Devise's top-level directory and run `bundle install` and `rake`. For the tests to pass, you will need to have a MongoDB server (version 2.0 or newer) running on your system.
== Installation
You can use the latest Rails 3 gem with the latest Devise gem:
gem install devise
After you install Devise and add it to your Gemfile, you need to run the generator:
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:
rails generate devise MODEL
Replace MODEL by the class name used for the applications users, it's frequently 'User' but could also be 'Admin'. This will create a model (if one does not exist) and configure it with default Devise modules. Next, you'll usually run db:migrate as the generator will have created a migration file (if your ORM supports them). This generator also configures your config/routes.rb file, continue reading this file to understand exactly what the generator produces and how to use it. Finally, if your server was already running, then restart it as Rails doesn't automatically load methods from a new gem.
Support for Rails 2.3.x can be found by installing Devise 1.0.x from the v1.0 branch.
== 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:
* Michael Hartl's online book: http://railstutorial.org/chapters/modeling-and-viewing-users-two#top
* Ryan Bates' Railscast: http://railscasts.com/episodes/250-authentication-from-scratch
Once you have solidified your understanding of Rails and authentication mechanisms, we assure you Devise will be very pleasant to work with. :)
== Getting started
This is a walkthrough with all steps you need to setup a devise resource, including model, migration, route files, and optional configuration.
Devise must be set up within the model (or models) you want to use. Devise routes must be created inside your config/routes.rb file.
We're assuming here you want a User model with some Devise modules, as outlined below:
class User < ActiveRecord::Base
devise :database_authenticatable, :registerable, :confirmable, :recoverable, :rememberable, :trackable, :validatable
end
After you choose which modules to use, you need to set up your migrations. Luckily, Devise has some helpers to save you from this boring work:
create_table :users do |t|
t.database_authenticatable
t.confirmable
t.recoverable
t.rememberable
t.trackable
t.timestamps
end
Devise doesn't use _attr_accessible_ or _attr_protected_ inside its modules, so be sure to define attributes as accessible or protected in your model.
Configure your routes after setting up your model. Open your config/routes.rb file and add:
devise_for :users
This will use your User model to create a set of needed routes (you can see them by running `rake routes`). If you invoked the devise generator, you noticed that this is exactly what the generator produces for us: model, routes and migrations.
Don't forget to run rake db:migrate and you are ready to go! But don't stop reading here, we still have a lot to tell you.
=== Controller filters and helpers
Devise will create some helpers to use inside your controllers and views. To set up a controller with user authentication, just add this before_filter:
before_filter :authenticate_user!
To verify if a user is signed in, use the following helper:
user_signed_in?
For the current signed-in user, this helper is available:
current_user
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. Example: For a :user resource, it will use user_root_path if it exists, otherwise default root_path will be used. This means that you need to set the root inside your routes:
root :to => "home#index"
You can also overwrite after_sign_in_path_for and after_sign_out_path_for to customize your redirect hooks.
Finally, you need to set up default url options for the mailer in each environment. Here is the configuration for config/environments/development.rb:
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
Notice that if your devise model is not called "user" but "member", then the helpers you should use are:
before_filter :authenticate_member!
member_signed_in?
current_member
member_session
=== Configuring Models
The devise method in your models also accepts some options to configure its modules. For example, you can choose which encryptor to use in database_authenticatable:
devise :database_authenticatable, :registerable, :confirmable, :recoverable, :stretches => 20
Besides :stretches, you can define :pepper, :encryptor, :confirm_within, :remember_for, :timeout_in, :unlock_in and other values. For details, see the initializer file that was created when you invoked the "devise:install" generator described above.
=== Configuring multiple models
Devise allows you to set up as many roles as you want. For example, you may have a User model and also want an Admin model with just authentication, trackable, lockable and timeoutable features and no confirmation or password-recovery features. Just follow these steps:
# Create a migration with the required fields
create_table :admins do |t|
t.database_authenticatable
t.lockable
t.trackable
t.timestamps
end
# Inside your Admin model
devise :database_authenticatable, :trackable, :timeoutable, :lockable
# Inside your routes
devise_for :admins
# Inside your protected controller
before_filter :authenticate_admin!
# Inside your controllers and views
admin_signed_in?
current_admin
admin_session
=== Configuring views
We built Devise to help you quickly develop an application that uses authentication. However, we don't want to be in your way when you need to customize it.
Since Devise is an engine, all its views are packaged inside the gem. These views will help you get started, but after sometime you may want to change them. If this is the case, you just need to invoke the following generator, and it will copy all views to your application:
rails generate devise:views
If you have more than one role in your application (such as "User" and "Admin"), you will notice that Devise uses the same views for all roles. Fortunately, Devise offers an easy way to customize views. All you need to do is set "config.scoped_views = true" inside "config/initializers/devise.rb".
After doing so, you will be able to have views based on the role like "users/sessions/new" and "admins/sessions/new". If no view is found within the scope, Devise will use the default view at "devise/sessions/new". You can also use the generator to generate scoped views:
rails generate devise:views users
=== Configuring controllers
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:
class Admins::SessionsController < Devise::SessionsController
end
2) Tell the router to use this controller:
devise_for :admins, :controllers => { :sessions => "admins/sessions" }
3) And since we changed the controller, it won't use the "devise/sessions" views, so remember to copy "devise/sessions" to "admin/sessions".
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.
=== Configuring routes
Devise also ships with default routes. If you need to customize them, you should probably be able to do it through the devise_for method. It accepts several options like :class_name, :path_prefix and so on, including the possibility to change path names for I18n:
devise_for :users, :path => "usuarios", :path_names => { :sign_in => 'login', :sign_out => 'logout', :password => 'secret', :confirmation => 'verification', :unlock => 'unblock', :registration => 'register', :sign_up => 'cmon_let_me_in' }
Be sure to check devise_for documentation for details.
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:
devise_scope :user do
get "sign_in", :to => "devise/sessions#new"
end
This way you tell devise to use the scope :user when "/sign_in" is accessed. Notice +devise_scope+ is also aliased as +as+ and you can also give a block to +devise_for+, resulting in the same behavior:
devise_for :users do
get "sign_in", :to => "devise/sessions#new"
end
Feel free to choose the one you prefer!
=== 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:
en:
devise:
sessions:
signed_in: 'Signed in successfully.'
You can also create distinct messages based on the resource you've configured using the singular name given in routes:
en:
devise:
sessions:
user:
signed_in: 'Welcome user, you are signed in.'
admin:
signed_in: 'Hello admin!'
The Devise mailer uses a similar pattern to create subject messages:
en:
devise:
mailer:
confirmation_instructions:
subject: 'Hello everybody!'
user_subject: 'Hello User! Please confirm your email'
reset_password_instructions:
subject: 'Reset instructions'
Take a look at our locale file to check all available messages. You may also be interested in one of the many translations that are available on our wiki:
https://github.com/plataformatec/devise/wiki/I18n
=== Test helpers
Devise includes some tests helpers for functional specs. To use them, you just need to include Devise::TestHelpers in your test class and use the sign_in and sign_out method. Such methods have the same signature as in controllers:
sign_in :user, @user # sign_in(scope, resource)
sign_in @user # sign_in(resource)
sign_out :user # sign_out(scope)
sign_out @user # sign_out(resource)
You can include the Devise Test Helpers in all of your tests by adding the following to the bottom of your test/test_helper.rb file:
class ActionController::TestCase
include Devise::TestHelpers
end
If you're using RSpec and want the helpers automatically included within all +describe+ blocks, add a file called spec/support/devise.rb with the following contents:
RSpec.configure do |config|
config.include Devise::TestHelpers, :type => :controller
end
Do not use such helpers for integration tests such as Cucumber or Webrat. Instead, fill in the form or explicitly set the user in session. For more tips, check the wiki (https://wiki.github.com/plataformatec/devise).
=== Omniauth
Devise comes with Omniauth support out of the box to authenticate from other providers. You can read more about Omniauth support in the wiki:
* https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview
=== Other ORMs
Devise supports ActiveRecord (default) and Mongoid. To choose other ORM, you just need to require it in the initializer file.
=== Migrating from other solutions
Devise implements encryption strategies for Clearance, Authlogic and Restful-Authentication. To make use of these strategies, you need set the desired encryptor in the encryptor initializer config option and add :encryptable to your model. You might also need to rename your encrypted password and salt columns to match Devise's fields (encrypted_password and password_salt).
== Troubleshooting
=== Heroku
Using devise on Heroku with Ruby on Rails 3.1 requires setting:
config.assets.initialize_on_precompile = false
Read more about the potential issues at http://guides.rubyonrails.org/asset_pipeline.html
== Additional information
=== Warden
Devise is based on Warden, which is a general Rack authentication framework created by Daniel Neighman. We encourage you to read more about Warden here:
https://github.com/hassox/warden
=== Contributors
We have a long list of valued contributors. Check them all at:
https://github.com/plataformatec/devise/contributors
=== Maintainers
* José Valim (https://github.com/josevalim)
* Carlos Antônio da Silva (https://github.com/carlosantoniodasilva)
* Rodrigo Flores (https://github.com/rodrigoflores)
== License
MIT License. Copyright 2011 Plataforma Tecnologia. http://blog.plataformatec.com.br

View File

@@ -1,5 +1,5 @@
# encoding: UTF-8
require "bundler/gem_tasks"
require 'rake/testtask'
require 'rdoc/task'
@@ -22,6 +22,7 @@ Rake::TestTask.new(:test) do |t|
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
t.warning = false
end
desc 'Generate documentation for Devise.'
@@ -29,6 +30,6 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'Devise'
rdoc.options << '--line-numbers' << '--inline-source'
rdoc.rdoc_files.include('README.rdoc')
rdoc.rdoc_files.include('README.md')
rdoc.rdoc_files.include('lib/**/*.rb')
end

View File

@@ -1,20 +1,17 @@
class Devise::ConfirmationsController < ApplicationController
include Devise::Controllers::InternalHelpers
class Devise::ConfirmationsController < DeviseController
# GET /resource/confirmation/new
def new
build_resource({})
render_with_scope :new
end
# POST /resource/confirmation
def create
self.resource = resource_class.send_confirmation_instructions(params[resource_name])
self.resource = resource_class.send_confirmation_instructions(resource_params)
if successfully_sent?(resource)
respond_with({}, :location => after_resending_confirmation_instructions_path_for(resource_name))
else
respond_with_navigational(resource){ render_with_scope :new }
respond_with(resource)
end
end
@@ -27,7 +24,7 @@ class Devise::ConfirmationsController < ApplicationController
sign_in(resource_name, resource)
respond_with_navigational(resource){ redirect_to after_confirmation_path_for(resource_name, resource) }
else
respond_with_navigational(resource.errors, :status => :unprocessable_entity){ render_with_scope :new }
respond_with_navigational(resource.errors, :status => :unprocessable_entity){ render :new }
end
end
@@ -35,7 +32,7 @@ class Devise::ConfirmationsController < ApplicationController
# The path used after resending confirmation instructions.
def after_resending_confirmation_instructions_path_for(resource_name)
new_session_path(resource_name)
new_session_path(resource_name) if is_navigational_format?
end
# The path used after confirmation.

View File

@@ -1,8 +1,12 @@
class Devise::OmniauthCallbacksController < ApplicationController
include Devise::Controllers::InternalHelpers
class Devise::OmniauthCallbacksController < DeviseController
prepend_before_filter { request.env["devise.skip_timeout"] = true }
def passthru
render :status => 404, :text => "Not found. Authentication passthru."
end
def failure
set_flash_message :alert, :failure, :kind => failed_strategy.name.to_s.humanize, :reason => failure_message
set_flash_message :alert, :failure, :kind => OmniAuth::Utils.camelize(failed_strategy.name), :reason => failure_message
redirect_to after_omniauth_failure_path_for(resource_name)
end

View File

@@ -1,21 +1,21 @@
class Devise::PasswordsController < ApplicationController
class Devise::PasswordsController < DeviseController
prepend_before_filter :require_no_authentication
include Devise::Controllers::InternalHelpers
# Render the #edit only if coming from a reset password email link
append_before_filter :assert_reset_token_passed, :only => :edit
# GET /resource/password/new
def new
build_resource({})
render_with_scope :new
end
# POST /resource/password
def create
self.resource = resource_class.send_reset_password_instructions(params[resource_name])
self.resource = resource_class.send_reset_password_instructions(resource_params)
if successfully_sent?(resource)
respond_with({}, :location => after_sending_reset_password_instructions_path_for(resource_name))
else
respond_with_navigational(resource){ render_with_scope :new }
respond_with(resource)
end
end
@@ -23,28 +23,46 @@ class Devise::PasswordsController < ApplicationController
def edit
self.resource = resource_class.new
resource.reset_password_token = params[:reset_password_token]
render_with_scope :edit
end
# PUT /resource/password
def update
self.resource = resource_class.reset_password_by_token(params[resource_name])
self.resource = resource_class.reset_password_by_token(resource_params)
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_navigational_format?
sign_in(resource_name, resource)
respond_with resource, :location => after_sign_in_path_for(resource)
respond_with resource, :location => after_resetting_password_path_for(resource)
else
respond_with_navigational(resource){ render_with_scope :edit }
respond_with resource
end
end
protected
def after_resetting_password_path_for(resource)
after_sign_in_path_for(resource)
end
# The path used after sending reset password instructions
def after_sending_reset_password_instructions_path_for(resource_name)
new_session_path(resource_name)
new_session_path(resource_name) if is_navigational_format?
end
# Check if a reset_password_token is provided in the request
def assert_reset_token_passed
if params[:reset_password_token].blank?
set_flash_message(:error, :no_token)
redirect_to new_session_path(resource_name)
end
end
# Check if proper Lockable module methods are present & unlock strategy
# allows to unlock resource on password reset
def unlockable?(resource)
resource.respond_to?(:unlock_access!) &&
resource.respond_to?(:unlock_strategy_enabled?) &&
resource.unlock_strategy_enabled?(:email)
end
end

View File

@@ -1,12 +1,11 @@
class Devise::RegistrationsController < ApplicationController
class Devise::RegistrationsController < DeviseController
prepend_before_filter :require_no_authentication, :only => [ :new, :create, :cancel ]
prepend_before_filter :authenticate_scope!, :only => [:edit, :update, :destroy]
include Devise::Controllers::InternalHelpers
# GET /resource/sign_up
def new
resource = build_resource({})
respond_with_navigational(resource){ render_with_scope :new }
respond_with resource
end
# POST /resource
@@ -16,22 +15,22 @@ class Devise::RegistrationsController < ApplicationController
if resource.save
if resource.active_for_authentication?
set_flash_message :notice, :signed_up if is_navigational_format?
sign_in(resource_name, resource)
sign_up(resource_name, resource)
respond_with resource, :location => after_sign_up_path_for(resource)
else
set_flash_message :notice, :inactive_signed_up, :reason => inactive_reason(resource) if is_navigational_format?
set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_navigational_format?
expire_session_data_after_sign_in!
respond_with resource, :location => after_inactive_sign_up_path_for(resource)
end
else
clean_up_passwords(resource)
respond_with_navigational(resource) { render_with_scope :new }
clean_up_passwords resource
respond_with resource
end
end
# GET /resource/edit
def edit
render_with_scope :edit
render :edit
end
# PUT /resource
@@ -39,14 +38,19 @@ class Devise::RegistrationsController < ApplicationController
# the current user in place.
def update
self.resource = resource_class.to_adapter.get!(send(:"current_#{resource_name}").to_key)
prev_unconfirmed_email = resource.unconfirmed_email if resource.respond_to?(:unconfirmed_email)
if resource.update_with_password(params[resource_name])
set_flash_message :notice, :updated if is_navigational_format?
if resource.update_with_password(resource_params)
if is_navigational_format?
flash_key = update_needs_confirmation?(resource, prev_unconfirmed_email) ?
:update_needs_confirmation : :updated
set_flash_message :notice, flash_key
end
sign_in resource_name, resource, :bypass => true
respond_with resource, :location => after_update_path_for(resource)
else
clean_up_passwords(resource)
respond_with_navigational(resource){ render_with_scope :edit }
clean_up_passwords resource
respond_with resource
end
end
@@ -70,40 +74,46 @@ class Devise::RegistrationsController < ApplicationController
protected
# Build a devise resource passing in the session. Useful to move
# temporary session data to the newly created user.
def build_resource(hash=nil)
hash ||= params[resource_name] || {}
self.resource = resource_class.new_with_session(hash, session)
end
def update_needs_confirmation?(resource, previous)
resource.respond_to?(:pending_reconfirmation?) &&
resource.pending_reconfirmation? &&
previous != resource.unconfirmed_email
end
# The path used after sign up. You need to overwrite this method
# in your own RegistrationsController.
def after_sign_up_path_for(resource)
after_sign_in_path_for(resource)
end
# Build a devise resource passing in the session. Useful to move
# temporary session data to the newly created user.
def build_resource(hash=nil)
hash ||= resource_params || {}
self.resource = resource_class.new_with_session(hash, session)
end
# Returns the inactive reason translated.
def inactive_reason(resource)
reason = resource.inactive_message.to_s
I18n.t("devise.registrations.reasons.#{reason}", :default => reason)
end
# Signs in a user on sign up. You can overwrite this method in your own
# RegistrationsController.
def sign_up(resource_name, resource)
sign_in(resource_name, resource)
end
# The path used after sign up for inactive accounts. You need to overwrite
# this method in your own RegistrationsController.
def after_inactive_sign_up_path_for(resource)
root_path
end
# The path used after sign up. You need to overwrite this method
# in your own RegistrationsController.
def after_sign_up_path_for(resource)
after_sign_in_path_for(resource)
end
# The default url to be used after updating a resource. You need to overwrite
# this method in your own RegistrationsController.
def after_update_path_for(resource)
signed_in_root_path(resource)
end
# The path used after sign up for inactive accounts. You need to overwrite
# this method in your own RegistrationsController.
def after_inactive_sign_up_path_for(resource)
respond_to?(:root_path) ? root_path : "/"
end
# Authenticates the current scope and gets the current resource from the session.
def authenticate_scope!
send(:"authenticate_#{resource_name}!", :force => true)
self.resource = send(:"current_#{resource_name}")
end
# The default url to be used after updating a resource. You need to overwrite
# this method in your own RegistrationsController.
def after_update_path_for(resource)
signed_in_root_path(resource)
end
# Authenticates the current scope and gets the current resource from the session.
def authenticate_scope!
send(:"authenticate_#{resource_name}!", :force => true)
self.resource = send(:"current_#{resource_name}")
end
end

View File

@@ -1,18 +1,18 @@
class Devise::SessionsController < ApplicationController
class Devise::SessionsController < DeviseController
prepend_before_filter :require_no_authentication, :only => [ :new, :create ]
prepend_before_filter :allow_params_authentication!, :only => :create
include Devise::Controllers::InternalHelpers
prepend_before_filter { request.env["devise.skip_timeout"] = true }
# GET /resource/sign_in
def new
resource = build_resource
self.resource = build_resource(nil, :unsafe => true)
clean_up_passwords(resource)
respond_with_navigational(resource, stub_options(resource)){ render_with_scope :new }
respond_with(resource, serialize_options(resource))
end
# POST /resource/sign_in
def create
resource = warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#new")
self.resource = warden.authenticate!(auth_options)
set_flash_message(:notice, :signed_in) if is_navigational_format?
sign_in(resource_name, resource)
respond_with resource, :location => after_sign_in_path_for(resource)
@@ -20,30 +20,28 @@ class Devise::SessionsController < ApplicationController
# DELETE /resource/sign_out
def destroy
signed_in = signed_in?(resource_name)
redirect_path = after_sign_out_path_for(resource_name)
Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name)
set_flash_message :notice, :signed_out if signed_in
signed_out = (Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name))
set_flash_message :notice, :signed_out if signed_out && is_navigational_format?
# We actually need to hardcode this as Rails default responder doesn't
# support returning empty response on GET request
respond_to do |format|
format.all { head :no_content }
format.any(*navigational_formats) { redirect_to redirect_path }
format.all do
method = "to_#{request_format}"
text = {}.respond_to?(method) ? {}.send(method) : ""
render :text => text, :status => :ok
end
end
end
protected
def stub_options(resource)
def serialize_options(resource)
methods = resource_class.authentication_keys.dup
methods = methods.keys if methods.is_a?(Hash)
methods << :password if resource.respond_to?(:password)
{ :methods => methods, :only => [:password] }
end
end
def auth_options
{ :scope => resource_name, :recall => "#{controller_path}#new" }
end
end

View File

@@ -1,21 +1,19 @@
class Devise::UnlocksController < ApplicationController
class Devise::UnlocksController < DeviseController
prepend_before_filter :require_no_authentication
include Devise::Controllers::InternalHelpers
# GET /resource/unlock/new
def new
build_resource({})
render_with_scope :new
end
# POST /resource/unlock
def create
self.resource = resource_class.send_unlock_instructions(params[resource_name])
self.resource = resource_class.send_unlock_instructions(resource_params)
if successfully_sent?(resource)
respond_with({}, :location => new_session_path(resource_name))
respond_with({}, :location => after_sending_unlock_instructions_path_for(resource))
else
respond_with_navigational(resource){ render_with_scope :new }
respond_with(resource)
end
end
@@ -25,10 +23,22 @@ class Devise::UnlocksController < ApplicationController
if resource.errors.empty?
set_flash_message :notice, :unlocked if is_navigational_format?
sign_in(resource_name, resource)
respond_with_navigational(resource){ redirect_to after_sign_in_path_for(resource) }
respond_with_navigational(resource){ redirect_to after_unlock_path_for(resource) }
else
respond_with_navigational(resource.errors, :status => :unprocessable_entity){ render_with_scope :new }
respond_with_navigational(resource.errors, :status => :unprocessable_entity){ render :new }
end
end
protected
# The path used after sending unlock password instructions
def after_sending_unlock_instructions_path_for(resource)
new_session_path(resource) if is_navigational_format?
end
# The path used after unlocking the resource
def after_unlock_path_for(resource)
new_session_path(resource) if is_navigational_format?
end
end

View File

@@ -0,0 +1,189 @@
# All Devise controllers are inherited from here.
class DeviseController < Devise.parent_controller.constantize
include Devise::Controllers::ScopedViews
helper DeviseHelper
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?
# Gets the actual resource stored in the instance variable
def resource
instance_variable_get(:"@#{resource_name}")
end
# Proxy to devise map name
def resource_name
devise_mapping.name
end
alias :scope_name :resource_name
# Proxy to devise map class
def resource_class
devise_mapping.to
end
def resource_params
params[resource_name]
end
# Returns a signed in resource from session (if one exists)
def signed_in_resource
warden.authenticate(:scope => resource_name)
end
# Attempt to find the mapped route for devise based on request path
def devise_mapping
@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
super.unshift("#{devise_mapping.scoped_path}/#{controller_name}")
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
Could not find devise mapping for path #{request.fullpath.inspect}.
This may happen for two reasons:
1) You forgot to wrap your route inside the scope block. For example:
devise_scope :user do
get "/some/route" => "some_devise_controller"
end
2) You are testing a Devise controller bypassing the router.
If so, you can explicitly tell Devise which mapping to use:
@request.env["devise.mapping"] = Devise.mappings[:user]
MESSAGE
end
# Returns real navigational formats which are supported by Rails
def navigational_formats
@navigational_formats ||= Devise.navigational_formats.select { |format| Mime::EXTENSION_LOOKUP[format.to_s] }
end
def unknown_action!(msg)
logger.debug "[Devise] #{msg}" if logger
raise AbstractController::ActionNotFound, msg
end
# Sets the resource creating an instance variable
def resource=(new_resource)
instance_variable_set(:"@#{resource_name}", new_resource)
end
# Build a devise resource.
# Assignment bypasses attribute protection when :unsafe option is passed
def build_resource(hash = nil, options = {})
hash ||= resource_params || {}
if options[:unsafe]
self.resource = resource_class.new.tap do |resource|
hash.each do |key, value|
setter = :"#{key}="
resource.send(setter, value) if resource.respond_to?(setter)
end
end
else
self.resource = resource_class.new(hash)
end
end
# Helper for use in before_filters where no authentication is required.
#
# Example:
# before_filter :require_no_authentication, :only => :new
def require_no_authentication
assert_is_devise_resource!
return unless is_navigational_format?
no_input = devise_mapping.no_input_strategies
authenticated = if no_input.present?
args = no_input.dup.push :scope => resource_name
warden.authenticate?(*args)
else
warden.authenticated?(resource_name)
end
if authenticated && resource = warden.user(resource_name)
flash[:alert] = I18n.t("devise.failure.already_authenticated")
redirect_to after_sign_in_path_for(resource)
end
end
# Helper for use after calling send_*_instructions methods on a resource.
# If we are in paranoid mode, we always act as if the resource was valid
# and instructions were sent.
def successfully_sent?(resource)
notice = if Devise.paranoid
resource.errors.clear
:send_paranoid_instructions
elsif resource.errors.empty?
:send_instructions
end
if notice
set_flash_message :notice, notice if is_navigational_format?
true
end
end
# Sets the flash message with :key, using I18n. By default you are able
# to setup your messages using specific resource scope, and if no one is
# found we look to default scope.
# Example (i18n locale file):
#
# en:
# devise:
# passwords:
# #default_scope_messages - only if resource_scope is not found
# user:
# #resource_scope_messages
#
# Please refer to README or en.yml locale file to check what messages are
# available.
def set_flash_message(key, kind, options = {})
message = find_message(kind, options)
flash[key] = message if message.present?
end
# Get message for given
def find_message(kind, options = {})
options[:scope] = "devise.#{controller_name}"
options[:default] = Array(options[:default]).unshift(kind.to_sym)
options[:resource_name] = resource_name
options = devise_i18n_options(options) if respond_to?(:devise_i18n_options, true)
I18n.t("#{options[:resource_name]}.#{kind}", options)
end
def clean_up_passwords(object)
object.clean_up_passwords if object.respond_to?(:clean_up_passwords)
end
def respond_with_navigational(*args, &block)
respond_with(*args) do |format|
format.any(*navigational_formats, &block)
end
end
end

View File

@@ -1,15 +1,15 @@
class Devise::Mailer < ::ActionMailer::Base
class Devise::Mailer < Devise.parent_mailer.constantize
include Devise::Mailers::Helpers
def confirmation_instructions(record)
devise_mail(record, :confirmation_instructions)
def confirmation_instructions(record, opts={})
devise_mail(record, :confirmation_instructions, opts)
end
def reset_password_instructions(record)
devise_mail(record, :reset_password_instructions)
def reset_password_instructions(record, opts={})
devise_mail(record, :reset_password_instructions, opts)
end
def unlock_instructions(record)
devise_mail(record, :unlock_instructions)
def unlock_instructions(record, opts={})
devise_mail(record, :unlock_instructions, opts)
end
end

View File

@@ -0,0 +1,3 @@
<% ActiveSupport::Deprecation.warn "Rendering partials devise/_links.erb is deprecated" \
"please use devise/shared/_links.erb instead."%>
<%= render "shared/links" %>

View File

@@ -4,9 +4,9 @@
<%= devise_error_messages! %>
<div><%= f.label :email %><br />
<%= f.email_field :email %></div>
<%= f.email_field :email, :autofocus => true %></div>
<div><%= f.submit "Resend confirmation instructions" %></div>
<% end %>
<%= render :partial => "devise/shared/links" %>
<%= render "devise/shared/links" %>

View File

@@ -1,5 +1,5 @@
<p>Welcome <%= @resource.email %>!</p>
<p>Welcome <%= @email %>!</p>
<p>You can confirm your account through the link below:</p>
<p>You can confirm your account email through the link below:</p>
<p><%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %></p>

View File

@@ -1,6 +1,6 @@
<p>Hello <%= @resource.email %>!</p>
<p>Someone has requested a link to change your password, and you can do this through the link below.</p>
<p>Someone has requested a link to change your password. You can do this through the link below.</p>
<p><%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %></p>

View File

@@ -1,6 +1,6 @@
<p>Hello <%= @resource.email %>!</p>
<p>Your account has been locked due to an excessive amount of unsuccessful sign in attempts.</p>
<p>Your account has been locked due to an excessive number of unsuccessful sign in attempts.</p>
<p>Click the link below to unlock your account:</p>

View File

@@ -5,7 +5,7 @@
<%= f.hidden_field :reset_password_token %>
<div><%= f.label :password, "New password" %><br />
<%= f.password_field :password %></div>
<%= f.password_field :password, :autofocus => true %></div>
<div><%= f.label :password_confirmation, "Confirm new password" %><br />
<%= f.password_field :password_confirmation %></div>
@@ -13,4 +13,4 @@
<div><%= f.submit "Change my password" %></div>
<% end %>
<%= render :partial => "devise/shared/links" %>
<%= render "devise/shared/links" %>

View File

@@ -4,9 +4,9 @@
<%= devise_error_messages! %>
<div><%= f.label :email %><br />
<%= f.email_field :email %></div>
<%= f.email_field :email, :autofocus => true %></div>
<div><%= f.submit "Send me reset password instructions" %></div>
<% end %>
<%= render :partial => "devise/shared/links" %>
<%= render "devise/shared/links" %>

View File

@@ -4,10 +4,14 @@
<%= devise_error_messages! %>
<div><%= f.label :email %><br />
<%= f.email_field :email %></div>
<%= 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 %></div>
<%= f.password_field :password, :autocomplete => "off" %></div>
<div><%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation %></div>
@@ -20,6 +24,6 @@
<h3>Cancel my account</h3>
<p>Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete %>.</p>
<p>Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), :data => { :confirm => "Are you sure?" }, :method => :delete %></p>
<%= link_to "Back", :back %>

View File

@@ -4,7 +4,7 @@
<%= devise_error_messages! %>
<div><%= f.label :email %><br />
<%= f.email_field :email %></div>
<%= f.email_field :email, :autofocus => true %></div>
<div><%= f.label :password %><br />
<%= f.password_field :password %></div>
@@ -15,4 +15,4 @@
<div><%= f.submit "Sign up" %></div>
<% end %>
<%= render :partial => "devise/shared/links" %>
<%= render "devise/shared/links" %>

View File

@@ -2,7 +2,7 @@
<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
<div><%= f.label :email %><br />
<%= f.email_field :email %></div>
<%= f.email_field :email, :autofocus => true %></div>
<div><%= f.label :password %><br />
<%= f.password_field :password %></div>
@@ -14,4 +14,4 @@
<div><%= f.submit "Sign in" %></div>
<% end %>
<%= render :partial => "devise/shared/links" %>
<%= render "devise/shared/links" %>

View File

@@ -4,9 +4,9 @@
<%= devise_error_messages! %>
<div><%= f.label :email %><br />
<%= f.email_field :email %></div>
<%= f.email_field :email, :autofocus => true %></div>
<div><%= f.submit "Resend unlock instructions" %></div>
<% end %>
<%= render :partial => "devise/shared/links" %>
<%= render "devise/shared/links" %>

View File

@@ -1,58 +1,59 @@
# Additional translations at https://github.com/plataformatec/devise/wiki/I18n
en:
devise:
confirmations:
confirmed: "Your account was successfully confirmed. You are now signed in."
send_instructions: "You will receive an email with instructions about how to confirm your account in a few minutes."
send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions about how to confirm your account in a few minutes."
failure:
already_authenticated: "You are already signed in."
inactive: "Your account was not activated yet."
invalid: "Invalid email or password."
invalid_token: "Invalid authentication token."
locked: "Your account is locked."
not_found_in_database: "Invalid email 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 account before continuing."
mailer:
confirmation_instructions:
subject: "Confirmation instructions"
reset_password_instructions:
subject: "Reset password instructions"
unlock_instructions:
subject: "Unlock Instructions"
omniauth_callbacks:
failure: "Could not authenticate you from %{kind} because \"%{reason}\"."
success: "Successfully authenticated from %{kind} account."
passwords:
no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided."
send_instructions: "You will receive an email with instructions about how to reset your password in a few minutes."
send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."
updated: "Your password was changed successfully. You are now signed in."
updated_not_active: "Your password was changed successfully."
registrations:
destroyed: "Bye! Your account was successfully cancelled. We hope to see you again soon."
signed_up: "Welcome! You have signed up successfully."
signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated."
signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked."
signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please open the link to activate your account."
update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and click on the confirm link to finalize confirming your new email address."
updated: "You updated your account successfully."
sessions:
signed_in: "Signed in successfully."
signed_out: "Signed out successfully."
unlocks:
send_instructions: "You will receive an email with instructions about how to unlock your account in a few minutes."
send_paranoid_instructions: "If your account exists, you will receive an email with instructions about how to unlock it in a few minutes."
unlocked: "Your account has been unlocked successfully. Please sign in to continue."
errors:
messages:
already_confirmed: "was already confirmed, please try signing in"
confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one"
expired: "has expired, please request a new one"
not_found: "not found"
already_confirmed: "was already confirmed, please try signing in"
not_locked: "was not locked"
not_saved:
one: "1 error prohibited this %{resource} from being saved:"
other: "%{count} errors prohibited this %{resource} from being saved:"
devise:
failure:
already_authenticated: 'You are already signed in.'
unauthenticated: 'You need to sign in or sign up before continuing.'
unconfirmed: 'You have to confirm your account before continuing.'
locked: 'Your account is locked.'
invalid: 'Invalid email or password.'
invalid_token: 'Invalid authentication token.'
timeout: 'Your session expired, please sign in again to continue.'
inactive: 'Your account was not activated yet.'
sessions:
signed_in: 'Signed in successfully.'
signed_out: 'Signed out successfully.'
passwords:
send_instructions: 'You will receive an email with instructions about how to reset your password in a few minutes.'
updated: 'Your password was changed successfully. You are now signed in.'
updated_not_active: 'Your password was changed successfully.'
send_paranoid_instructions: "If your e-mail exists on our database, you will receive a password recovery link on your e-mail"
confirmations:
send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.'
send_paranoid_instructions: 'If your e-mail exists on our database, you will receive an email with instructions about how to confirm your account in a few minutes.'
confirmed: 'Your account was successfully confirmed. You are now signed in.'
registrations:
signed_up: 'Welcome! You have signed up successfully.'
inactive_signed_up: 'You have signed up successfully. However, we could not sign you in because your account is %{reason}.'
updated: 'You updated your account successfully.'
destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.'
reasons:
inactive: 'inactive'
unconfirmed: 'unconfirmed'
locked: 'locked'
unlocks:
send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.'
unlocked: 'Your account was successfully unlocked. You are now signed in.'
send_paranoid_instructions: 'If your account exists, you will receive an email with instructions about how to unlock it in a few minutes.'
omniauth_callbacks:
success: 'Successfully authorized from %{kind} account.'
failure: 'Could not authorize you from %{kind} because "%{reason}".'
mailer:
confirmation_instructions:
subject: 'Confirmation instructions'
reset_password_instructions:
subject: 'Reset password instructions'
unlock_instructions:
subject: 'Unlock Instructions'

View File

@@ -5,7 +5,8 @@ require "devise/version"
Gem::Specification.new do |s|
s.name = "devise"
s.version = Devise::VERSION.dup
s.platform = Gem::Platform::RUBY
s.platform = Gem::Platform::RUBY
s.licenses = ["MIT"]
s.summary = "Flexible authentication solution for Rails with Warden"
s.email = "contact@plataformatec.com.br"
s.homepage = "http://github.com/plataformatec/devise"
@@ -15,11 +16,11 @@ Gem::Specification.new do |s|
s.rubyforge_project = "devise"
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.test_files = `git ls-files -- test/*`.split("\n")
s.require_paths = ["lib"]
s.add_dependency("warden", "~> 1.1")
s.add_dependency("orm_adapter", "~> 0.0.3")
s.add_dependency("warden", "~> 1.2.1")
s.add_dependency("orm_adapter", "~> 0.1")
s.add_dependency("bcrypt-ruby", "~> 3.0")
end
s.add_dependency("railties", "~> 3.1")
end

BIN
devise.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

@@ -0,0 +1,35 @@
source "https://rubygems.org"
gem "devise", :path => ".."
gem "rails", "~> 3.1.0"
gem "omniauth", "~> 1.0.0"
gem "omniauth-oauth2", "~> 1.0.0"
gem "rdoc"
group :test do
gem "omniauth-facebook"
gem "omniauth-openid", "~> 1.0.1"
gem "webrat", "0.7.3", :require => false
gem "mocha", "~> 0.13.1", :require => false
platforms :mri_18 do
gem "ruby-debug", ">= 0.10.3"
end
end
platforms :jruby do
gem "activerecord-jdbc-adapter"
gem "activerecord-jdbcsqlite3-adapter"
gem "jruby-openssl"
end
platforms :ruby do
gem "sqlite3"
end
platforms :mri_19 do
group :mongoid do
gem "mongoid", "~> 3.0"
end
end

View File

@@ -0,0 +1,167 @@
PATH
remote: ..
specs:
devise (2.2.8)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.1)
railties (~> 3.1)
warden (~> 1.2.1)
GEM
remote: https://rubygems.org/
specs:
actionmailer (3.1.12)
actionpack (= 3.1.12)
mail (~> 2.4.4)
actionpack (3.1.12)
activemodel (= 3.1.12)
activesupport (= 3.1.12)
builder (~> 3.0.0)
erubis (~> 2.7.0)
i18n (~> 0.6)
rack (~> 1.3.6)
rack-cache (~> 1.2)
rack-mount (~> 0.8.2)
rack-test (~> 0.6.1)
sprockets (~> 2.0.4)
activemodel (3.1.12)
activesupport (= 3.1.12)
builder (~> 3.0.0)
i18n (~> 0.6)
activerecord (3.1.12)
activemodel (= 3.1.12)
activesupport (= 3.1.12)
arel (~> 2.2.3)
tzinfo (~> 0.3.29)
activeresource (3.1.12)
activemodel (= 3.1.12)
activesupport (= 3.1.12)
activesupport (3.1.12)
multi_json (~> 1.0)
arel (2.2.3)
bcrypt-ruby (3.1.2)
builder (3.0.4)
columnize (0.3.6)
erubis (2.7.0)
faraday (0.8.7)
multipart-post (~> 1.1)
hashie (1.2.0)
hike (1.2.2)
httpauth (0.2.0)
i18n (0.6.4)
json (1.7.7)
jwt (0.1.8)
multi_json (>= 1.5)
linecache (0.46)
rbx-require-relative (> 0.0.4)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
metaclass (0.0.1)
mime-types (1.23)
mocha (0.13.3)
metaclass (~> 0.0.1)
mongoid (3.0.23)
activemodel (~> 3.1)
moped (~> 1.2)
origin (~> 1.0)
tzinfo (~> 0.3.22)
moped (1.4.5)
multi_json (1.7.3)
multipart-post (1.2.0)
nokogiri (1.5.9)
oauth2 (0.8.1)
faraday (~> 0.8)
httpauth (~> 0.1)
jwt (~> 0.1.4)
multi_json (~> 1.0)
rack (~> 1.2)
omniauth (1.0.3)
hashie (~> 1.2)
rack
omniauth-facebook (1.4.0)
omniauth-oauth2 (~> 1.0.2)
omniauth-oauth2 (1.0.3)
oauth2 (~> 0.8.0)
omniauth (~> 1.0)
omniauth-openid (1.0.1)
omniauth (~> 1.0)
rack-openid (~> 1.3.1)
origin (1.1.0)
orm_adapter (0.4.0)
polyglot (0.3.3)
rack (1.3.10)
rack-cache (1.2)
rack (>= 0.4)
rack-mount (0.8.3)
rack (>= 1.0.0)
rack-openid (1.3.1)
rack (>= 1.1.0)
ruby-openid (>= 2.1.8)
rack-ssl (1.3.3)
rack
rack-test (0.6.2)
rack (>= 1.0)
rails (3.1.12)
actionmailer (= 3.1.12)
actionpack (= 3.1.12)
activerecord (= 3.1.12)
activeresource (= 3.1.12)
activesupport (= 3.1.12)
bundler (~> 1.0)
railties (= 3.1.12)
railties (3.1.12)
actionpack (= 3.1.12)
activesupport (= 3.1.12)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.6)
rake (10.0.4)
rbx-require-relative (0.0.9)
rdoc (3.12.2)
json (~> 1.4)
ruby-debug (0.10.4)
columnize (>= 0.1)
ruby-debug-base (~> 0.10.4.0)
ruby-debug-base (0.10.4)
linecache (>= 0.3)
ruby-openid (2.2.3)
sprockets (2.0.4)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.7)
thor (0.14.6)
tilt (1.4.0)
treetop (1.4.12)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.37)
warden (1.2.3)
rack (>= 1.0)
webrat (0.7.3)
nokogiri (>= 1.2.0)
rack (>= 1.0)
rack-test (>= 0.5.3)
PLATFORMS
ruby
DEPENDENCIES
activerecord-jdbc-adapter
activerecord-jdbcsqlite3-adapter
devise!
jruby-openssl
mocha (~> 0.13.1)
mongoid (~> 3.0)
omniauth (~> 1.0.0)
omniauth-facebook
omniauth-oauth2 (~> 1.0.0)
omniauth-openid (~> 1.0.1)
rails (~> 3.1.0)
rdoc
ruby-debug (>= 0.10.3)
sqlite3
webrat (= 0.7.3)

View File

@@ -6,32 +6,20 @@ require 'set'
require 'securerandom'
module Devise
autoload :Delegator, 'devise/delegator'
autoload :FailureApp, 'devise/failure_app'
autoload :OmniAuth, 'devise/omniauth'
autoload :ParamFilter, 'devise/param_filter'
autoload :PathChecker, 'devise/path_checker'
autoload :Schema, 'devise/schema'
autoload :TestHelpers, 'devise/test_helpers'
autoload :Delegator, 'devise/delegator'
autoload :FailureApp, 'devise/failure_app'
autoload :OmniAuth, 'devise/omniauth'
autoload :ParamFilter, 'devise/param_filter'
autoload :TestHelpers, 'devise/test_helpers'
autoload :TimeInflector, 'devise/time_inflector'
module Controllers
autoload :Helpers, 'devise/controllers/helpers'
autoload :InternalHelpers, 'devise/controllers/internal_helpers'
autoload :Rememberable, 'devise/controllers/rememberable'
autoload :ScopedViews, 'devise/controllers/scoped_views'
autoload :SharedHelpers, 'devise/controllers/shared_helpers'
autoload :UrlHelpers, 'devise/controllers/url_helpers'
end
module Encryptors
autoload :Base, 'devise/encryptors/base'
autoload :AuthlogicSha512, 'devise/encryptors/authlogic_sha512'
autoload :ClearanceSha1, 'devise/encryptors/clearance_sha1'
autoload :RestfulAuthenticationSha1, 'devise/encryptors/restful_authentication_sha1'
autoload :Sha512, 'devise/encryptors/sha512'
autoload :Sha1, 'devise/encryptors/sha1'
end
module Mailers
autoload :Helpers, 'devise/mailers/helpers'
end
@@ -55,23 +43,18 @@ module Devise
# True values used to check params
TRUE_VALUES = [true, 1, '1', 't', 'T', 'true', 'TRUE']
# Declare encryptors length which are used in migrations.
ENCRYPTORS_LENGTH = {
:sha1 => 40,
:sha512 => 128,
:clearance_sha1 => 40,
:restful_authentication_sha1 => 40,
:authlogic_sha512 => 128
}
# Custom domain for cookies. Not set by default
mattr_accessor :cookie_options
@@cookie_options = {}
# Custom domain or key for cookies. Not set by default
mattr_accessor :rememberable_options
@@rememberable_options = {}
# The number of times to encrypt password.
mattr_accessor :stretches
@@stretches = 10
# The default key used when authenticating over http auth.
mattr_accessor :http_authentication_key
@@http_authentication_key = nil
# Keys used when authenticating a user.
mattr_accessor :authentication_keys
@@authentication_keys = [ :email ]
@@ -81,14 +64,12 @@ module Devise
@@request_keys = []
# Keys that should be case-insensitive.
# False by default for backwards compatibility.
mattr_accessor :case_insensitive_keys
@@case_insensitive_keys = false
@@case_insensitive_keys = [ :email ]
# Keys that should have whitespace stripped.
# False by default for backwards compatibility.
mattr_accessor :strip_whitespace_keys
@@strip_whitespace_keys = false
@@strip_whitespace_keys = []
# If http authentication is enabled by default.
mattr_accessor :http_authenticatable
@@ -110,7 +91,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[^@]+@([^@\.]+\.)+[^@\.]+\z/
@@email_regexp = /\A[^@\s]+@([^@\s]+\.)+[^@\s]+\z/
# Range validation for password length
mattr_accessor :password_length
@@ -120,44 +101,40 @@ module Devise
mattr_accessor :remember_for
@@remember_for = 2.weeks
# If true, a valid remember token can be re-used between multiple browsers.
mattr_accessor :remember_across_browsers
@@remember_across_browsers = true
# If true, extends the user's remember period when remembered via cookie.
mattr_accessor :extend_remember_period
@@extend_remember_period = false
# If true, uses salt as remember token and does not create it in the database.
# By default is false for backwards compatibility.
mattr_accessor :use_salt_as_remember_token
@@use_salt_as_remember_token = false
# Time interval you can access your account before confirming your account.
mattr_accessor :confirm_within
@@confirm_within = 0.days
# nil - allows unconfirmed access for unlimited time
mattr_accessor :allow_unconfirmed_access_for
@@allow_unconfirmed_access_for = 0.days
# Defines which key will be used when confirming an account
# Time interval the confirmation token is valid. nil = unlimited
mattr_accessor :confirm_within
@@confirm_within = nil
# Defines which key will be used when confirming an account.
mattr_accessor :confirmation_keys
@@confirmation_keys = [ :email ]
# Defines if email should be reconfirmable.
# False by default for backwards compatibility.
mattr_accessor :reconfirmable
@@reconfirmable = false
# Time interval to timeout the user session without activity.
mattr_accessor :timeout_in
@@timeout_in = 30.minutes
# Authentication token expiration on timeout
mattr_accessor :expire_auth_token_on_timeout
@@expire_auth_token_on_timeout = false
# Used to encrypt password. Please generate one with rake secret.
mattr_accessor :pepper
@@pepper = nil
# Used to define the password encryption algorithm.
mattr_accessor :encryptor
@@encryptor = nil
# Tells if devise should apply the schema in ORMs where devise declaration
# and schema belongs to the same class (as Datamapper and Mongoid).
mattr_accessor :apply_schema
@@apply_schema = true
# Scoped views. Since it relies on fallbacks to render default views, it's
# turned off by default.
mattr_accessor :scoped_views
@@ -191,7 +168,7 @@ module Devise
# Time interval you can reset your password with a reset password key
mattr_accessor :reset_password_within
@@reset_password_within = nil
@@reset_password_within = 6.hours
# The default scope which is used by warden.
mattr_accessor :default_scope
@@ -205,14 +182,13 @@ module Devise
mattr_accessor :token_authentication_key
@@token_authentication_key = :auth_token
# If true, authentication through token does not store user in session
mattr_accessor :stateless_token
@@stateless_token = false
# Skip session storage for the following strategies
mattr_accessor :skip_session_storage
@@skip_session_storage = []
# Which formats should be treated as navigational.
# We need both :"*/*" and "*/*" to work on different Rails versions.
mattr_accessor :navigational_formats
@@navigational_formats = [:"*/*", "*/*", :html]
@@navigational_formats = ["*/*", :html]
# When set to true, signing out a user signs out all other scopes.
mattr_accessor :sign_out_all_scopes
@@ -222,6 +198,45 @@ module Devise
mattr_accessor :sign_out_via
@@sign_out_via = :get
# The parent controller all Devise controllers inherits from.
# Defaults to ApplicationController. This should be set early
# in the initialization process and should be set to a string.
mattr_accessor :parent_controller
@@parent_controller = "ApplicationController"
# The parent mailer all Devise mailers inherit from.
# Defaults to ActionMailer::Base. This should be set early
# in the initialization process and should be set to a string.
mattr_accessor :parent_mailer
@@parent_mailer = "ActionMailer::Base"
# The router Devise should use to generate routes. Defaults
# to :main_app. Should be overriden by engines in order
# to provide custom routes.
mattr_accessor :router_name
@@router_name = nil
# Set the omniauth path prefix so it can be overriden when
# Devise is used in a mountable engine
mattr_accessor :omniauth_path_prefix
@@omniauth_path_prefix = nil
# Set if we should clean up the CSRF Token on authentication
mattr_accessor :clean_up_csrf_token_on_authentication
@@clean_up_csrf_token_on_authentication = true
def self.encryptor=(value)
warn "\n[DEVISE] To select a encryption which isn't bcrypt, you should use devise-encryptable gem.\n"
end
def self.use_salt_as_remember_token=(value)
warn "\n[DEVISE] Devise.use_salt_as_remember_token is deprecated and has no effect. Please remove it.\n"
end
def self.apply_schema=(value)
warn "\n[DEVISE] Devise.apply_schema is deprecated and has no effect. Please remove it.\n"
end
# PRIVATE CONFIGURATION
# Store scopes mappings.
@@ -271,6 +286,10 @@ module Devise
end
end
def self.available_router_name
router_name || :main_app
end
def self.omniauth_providers
omniauth_configs.keys
end
@@ -300,7 +319,7 @@ module Devise
# == Options:
#
# +model+ - String representing the load path to a custom *model* for this module (to autoload.)
# +controller+ - Symbol representing the name of an exisiting or custom *controller* for this module.
# +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*.
#
@@ -315,7 +334,7 @@ module Devise
#
def self.add_module(module_name, options = {})
ALL << module_name
options.assert_valid_keys(:strategy, :model, :controller, :route)
options.assert_valid_keys(:strategy, :model, :controller, :route, :no_input)
if strategy = options[:strategy]
strategy = (strategy == true ? module_name : strategy)
@@ -327,7 +346,7 @@ module Devise
CONTROLLERS[module_name] = controller
end
NO_INPUT << strategy if strategy && controller != :sessions
NO_INPUT << strategy if options[:no_input]
if route = options[:route]
case route
@@ -361,7 +380,7 @@ module Devise
# initialization.
#
# Devise.initialize do |config|
# config.confirm_within = 2.days
# config.allow_unconfirmed_access_for = 2.days
#
# config.warden do |manager|
# # Configure warden to use other strategies, like oauth.
@@ -394,11 +413,6 @@ module Devise
end
end
# Returns true if Rails version is bigger than 3.0.x
def self.rack_session?
Rails::VERSION::STRING[0,3] != "3.0"
end
# Regenerates url helpers considering Devise.mapping
def self.regenerate_helpers!
Devise::Controllers::UrlHelpers.remove_helpers!
@@ -415,6 +429,17 @@ module Devise
Devise.mappings.each_value do |mapping|
warden_config.scope_defaults mapping.name, :strategies => mapping.strategies
warden_config.serialize_into_session(mapping.name) do |record|
mapping.to.serialize_into_session(record)
end
warden_config.serialize_from_session(mapping.name) do |key|
# Previous versions contained an additional entry at the beginning of
# key with the record's class name.
args = key[-2, 2]
mapping.to.serialize_from_session(*args)
end
end
@@warden_config_block.try :call, Devise.warden_config
@@ -422,7 +447,7 @@ module Devise
end
end
# Generate a friendly string randomically to be used as token.
# Generate a friendly string randomly to be used as token.
def self.friendly_token
SecureRandom.base64(15).tr('+/=lIO0', 'pqrsxyz')
end

View File

@@ -75,9 +75,9 @@ module Devise
# the controllers defined inside devise. Useful if you want to apply a before
# filter to all controllers, except the ones in devise:
#
# before_filter :my_filter, :unless => { |c| c.devise_controller? }
# before_filter :my_filter, :unless => :devise_controller?
def devise_controller?
false
is_a?(DeviseController)
end
# Tell warden that params authentication is allowed for that specific page.
@@ -88,8 +88,8 @@ 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|
warden.authenticate?(:scope => scope)
[ scope || Devise.mappings.keys ].flatten.any? do |_scope|
warden.authenticate?(:scope => _scope)
end
end
@@ -126,7 +126,8 @@ module Devise
end
# Sign out a given user or scope. This helper is useful for signing out a user
# after deleting accounts.
# after deleting accounts. Returns true if there was a logout and false if there
# is no user logged in on the referred scope
#
# Examples:
#
@@ -136,23 +137,33 @@ module Devise
def sign_out(resource_or_scope=nil)
return sign_out_all_scopes unless resource_or_scope
scope = Devise::Mapping.find_scope!(resource_or_scope)
warden.user(scope) # Without loading user here, before_logout hook is not called
user = warden.user(:scope => scope, :run_callbacks => false) # If there is no user
warden.raw_session.inspect # Without this inspect here. The session does not clear.
warden.logout(scope)
warden.clear_strategies_cache!(:scope => scope)
instance_variable_set(:"@current_#{scope}", nil)
!!user
end
# Sign out all active users or scopes. This helper is useful for signing out all roles
# in one click. This signs out ALL scopes in warden.
def sign_out_all_scopes
Devise.mappings.keys.each { |s| warden.user(s) }
# in one click. This signs out ALL scopes in warden. Returns true if there was at least one logout
# and false if there was no user logged in on all scopes.
def sign_out_all_scopes(lock=true)
users = Devise.mappings.keys.map { |s| warden.user(:scope => s, :run_callbacks => false) }
warden.raw_session.inspect
warden.logout
expire_devise_cached_variables!
warden.clear_strategies_cache!
warden.lock! if lock
users.any?
end
# Returns and delete the url stored in the session for the given scope. Useful
# for giving redirect backs after sign up:
# Returns and delete (if it's navigational format) the url stored in the session for
# the given scope. Useful for giving redirect backs after sign up:
#
# Example:
#
@@ -160,7 +171,12 @@ module Devise
#
def stored_location_for(resource_or_scope)
scope = Devise::Mapping.find_scope!(resource_or_scope)
session.delete("#{scope}_return_to")
if is_navigational_format?
session.delete("#{scope}_return_to")
else
session["#{scope}_return_to"]
end
end
# The scope root url to be used when he's signed in. By default, it first
@@ -168,7 +184,13 @@ module Devise
def signed_in_root_path(resource_or_scope)
scope = Devise::Mapping.find_scope!(resource_or_scope)
home_path = "#{scope}_root_path"
respond_to?(home_path, true) ? send(home_path) : root_path
if respond_to?(home_path, true)
send(home_path)
elsif respond_to?(:root_path)
root_path
else
"/"
end
end
# The default url to be used after signing in. This is used by all Devise
@@ -194,7 +216,7 @@ module Devise
# if resource.is_a?(User) && resource.can_publish?
# publisher_url
# else
# signed_in_root_path(resource)
# super
# end
# end
#
@@ -209,7 +231,7 @@ module Devise
#
# By default it is the root_path.
def after_sign_out_path_for(resource_or_scope)
root_path
respond_to?(:root_path) ? root_path : "/"
end
# Sign in a user and tries to redirect first to the stored location and
@@ -223,11 +245,6 @@ module Devise
redirect_to after_sign_in_path_for(resource)
end
def redirect_location(scope, resource) #:nodoc:
ActiveSupport::Deprecation.warn "redirect_location in Devise is deprecated. Please use after_sign_in_path_for instead.", caller
after_sign_in_path_for(resource)
end
def expire_session_data_after_sign_in!
session.keys.grep(/^devise\./).each { |k| session.delete(k) }
end
@@ -244,12 +261,20 @@ module Devise
# Overwrite Rails' handle unverified request to sign out all scopes,
# clear run strategies and remove cached variables.
def handle_unverified_request
sign_out_all_scopes
warden.clear_strategies_cache!
sign_out_all_scopes(false)
request.env["devise.skip_storage"] = true
expire_devise_cached_variables!
super # call the default behaviour which resets the session
end
def request_format
@request_format ||= request.format.try(:ref)
end
def is_navigational_format?
Devise.navigational_formats.include?(request_format)
end
private
def expire_devise_cached_variables!

View File

@@ -1,154 +0,0 @@
module Devise
module Controllers
# Those helpers are used only inside Devise controllers and should not be
# included in ApplicationController since they all depend on the url being
# accessed.
module InternalHelpers #:nodoc:
extend ActiveSupport::Concern
include Devise::Controllers::ScopedViews
include Devise::Controllers::SharedHelpers
included do
helper DeviseHelper
helpers = %w(resource scope_name resource_name signed_in_resource
resource_class devise_mapping devise_controller?)
hide_action *helpers
helper_method *helpers
prepend_before_filter :is_devise_resource?
respond_to *Mime::SET.map(&:to_sym) if mimes_for_respond_to.empty?
end
# Gets the actual resource stored in the instance variable
def resource
instance_variable_get(:"@#{resource_name}")
end
# Proxy to devise map name
def resource_name
devise_mapping.name
end
alias :scope_name :resource_name
# Proxy to devise map class
def resource_class
devise_mapping.to
end
# Returns a signed in resource from session (if one exists)
def signed_in_resource
warden.authenticate(:scope => resource_name)
end
# Attempt to find the mapped route for devise based on request path
def devise_mapping
@devise_mapping ||= request.env["devise.mapping"]
end
# Overwrites devise_controller? to return true
def devise_controller?
true
end
protected
# Checks whether it's a devise mapped resource or not.
def is_devise_resource? #:nodoc:
unknown_action! <<-MESSAGE unless devise_mapping
Could not find devise mapping for path #{request.fullpath.inspect}.
Maybe you forgot to wrap your route inside the scope block? For example:
devise_scope :user do
match "/some/route" => "some_devise_controller"
end
MESSAGE
end
# Returns real navigational formats which are supported by Rails
def navigational_formats
@navigational_formats ||= Devise.navigational_formats.select{ |format| Mime::EXTENSION_LOOKUP[format.to_s] }
end
def unknown_action!(msg)
logger.debug "[Devise] #{msg}" if logger
raise ActionController::UnknownAction, msg
end
# Sets the resource creating an instance variable
def resource=(new_resource)
instance_variable_set(:"@#{resource_name}", new_resource)
end
# Build a devise resource.
def build_resource(hash=nil)
hash ||= params[resource_name] || {}
self.resource = resource_class.new(hash)
end
# Helper for use in before_filters where no authentication is required.
#
# Example:
# before_filter :require_no_authentication, :only => :new
def require_no_authentication
return unless is_navigational_format?
no_input = devise_mapping.no_input_strategies
args = no_input.dup.push :scope => resource_name
if no_input.present? && warden.authenticate?(*args)
resource = warden.user(resource_name)
flash[:alert] = I18n.t("devise.failure.already_authenticated")
redirect_to after_sign_in_path_for(resource)
end
end
# Helper for use after calling send_*_instructions methods on a resource.
# If we are in paranoid mode, we always act as if the resource was valid
# and instructions were sent.
def successfully_sent?(resource)
notice = if Devise.paranoid
resource.errors.clear
:send_paranoid_instructions
elsif resource.errors.empty?
:send_instructions
end
if notice
set_flash_message :notice, notice if is_navigational_format?
true
end
end
# Sets the flash message with :key, using I18n. By default you are able
# to setup your messages using specific resource scope, and if no one is
# found we look to default scope.
# Example (i18n locale file):
#
# en:
# devise:
# passwords:
# #default_scope_messages - only if resource_scope is not found
# user:
# #resource_scope_messages
#
# Please refer to README or en.yml locale file to check what messages are
# available.
def set_flash_message(key, kind, options={}) #:nodoc:
options[:scope] = "devise.#{controller_name}"
options[:default] = Array(options[:default]).unshift(kind.to_sym)
options[:resource_name] = resource_name
message = I18n.t("#{resource_name}.#{kind}", options)
flash[key] = message if message.present?
end
def clean_up_passwords(object) #:nodoc:
object.clean_up_passwords if object.respond_to?(:clean_up_passwords)
end
def respond_with_navigational(*args, &block)
respond_with(*args) do |format|
format.any(*navigational_formats, &block)
end
end
end
end
end

View File

@@ -21,22 +21,23 @@ module Devise
# 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)
cookies.signed["remember_#{scope}_token"] = remember_cookie_values(resource)
cookies.signed[remember_key(resource, scope)] = remember_cookie_values(resource)
end
# Forgets the given resource by deleting a cookie
def forget_me(resource)
scope = Devise::Mapping.find_scope!(resource)
resource.forget_me!
cookies.delete("remember_#{scope}_token", forget_cookie_values(resource))
cookies.delete(remember_key(resource, scope), forget_cookie_values(resource))
end
protected
def forget_cookie_values(resource)
Devise::Controllers::Rememberable.cookie_values.merge!(resource.cookie_options)
Devise::Controllers::Rememberable.cookie_values.merge!(resource.rememberable_options)
end
def remember_cookie_values(resource)
@@ -47,6 +48,10 @@ module Devise
:expires => resource.remember_expires_at
)
end
def remember_key(resource, scope)
resource.rememberable_options.fetch(:key, "remember_#{scope}_token")
end
end
end
end
end

View File

@@ -12,22 +12,6 @@ module Devise
@scoped_views = value
end
end
protected
# Render a view for the specified scope. Turned off by default.
# Accepts just :controller as option.
def render_with_scope(action, path=self.controller_path)
if self.class.scoped_views?
begin
render :template => "#{devise_mapping.scoped_path}/#{path.split("/").last}/#{action}"
rescue ActionView::MissingTemplate
render :template => "#{path}/#{action}"
end
else
render :template => "#{path}/#{action}"
end
end
end
end
end

View File

@@ -1,26 +0,0 @@
module Devise
module Controllers
# Helpers used in both FailureApp and Devise controllers.
module SharedHelpers
MIME_REFERENCES = Mime::HTML.respond_to?(:ref)
protected
# Helper used by FailureApp and Devise controllers to retrieve proper formats.
def request_format
@request_format ||= if request.format.respond_to?(:ref)
request.format.ref
elsif MIME_REFERENCES
request.format
elsif request.format # Rails < 3.0.4
request.format.to_sym
end
end
# Check whether it's navigational format, such as :html or :iphone, or not.
def is_navigational_format?
Devise.navigational_formats.include?(request_format)
end
end
end
end

View File

@@ -16,7 +16,15 @@ module Devise
# new_confirmation_path(:user) => new_user_confirmation_path
# confirmation_path(:user) => user_confirmation_path
#
# Those helpers are added to your ApplicationController.
# Those helpers are included by default to ActionController::Base.
#
# In case you want to add such helpers to another class, you can do
# that as long as this new class includes both url_helpers and
# mounted_helpers. Example:
#
# include Rails.application.routes.url_helpers
# include Rails.application.routes.mounted_helpers
#
module UrlHelpers
def self.remove_helpers!
self.instance_methods.map(&:to_s).grep(/_(url|path)$/).each do |method|
@@ -39,7 +47,7 @@ module Devise
class_eval <<-URL_HELPERS, __FILE__, __LINE__ + 1
def #{method}(resource_or_scope, *args)
scope = Devise::Mapping.find_scope!(resource_or_scope)
send("#{action}\#{scope}_#{module_name}_#{path_or_url}", *args)
_devise_route_context.send("#{action}\#{scope}_#{module_name}_#{path_or_url}", *args)
end
URL_HELPERS
end
@@ -48,6 +56,12 @@ module Devise
end
generate_helpers!(Devise::URL_HELPERS)
private
def _devise_route_context
@_devise_route_context ||= send(Devise.available_router_name)
end
end
end
end

View File

@@ -8,9 +8,9 @@ module Devise
def failure_app(env)
app = env["warden.options"] &&
(scope = env["warden.options"][:scope]) &&
Devise.mappings[scope].failure_app
Devise.mappings[scope.to_sym].failure_app
app || Devise::FailureApp
end
end
end
end

View File

@@ -1,19 +0,0 @@
require "digest/sha2"
module Devise
module Encryptors
# = AuthlogicSha512
# Simulates Authlogic's default encryption mechanism.
# Warning: it uses Devise's stretches configuration to port Authlogic's one. Should be set to 20 in the initializer to simulate
# the default behavior.
class AuthlogicSha512 < Base
# Generates a default password digest based on salt, pepper and the
# incoming password.
def self.digest(password, stretches, salt, pepper)
digest = [password, salt].flatten.join('')
stretches.times { digest = Digest::SHA512.hexdigest(digest) }
digest
end
end
end
end

View File

@@ -1,20 +0,0 @@
module Devise
# Implements a way of adding different encryptions.
# The class should implement a self.digest method that taks the following params:
# - password
# - stretches: the number of times the encryption will be applied
# - salt: the password salt as defined by devise
# - pepper: Devise config option
#
module Encryptors
class Base
def self.digest
raise NotImplemented
end
def self.salt(stretches)
Devise.friendly_token[0,20]
end
end
end
end

View File

@@ -1,17 +0,0 @@
require "digest/sha1"
module Devise
module Encryptors
# = ClearanceSha1
# Simulates Clearance's default encryption mechanism.
# Warning: it uses Devise's pepper to port the concept of REST_AUTH_SITE_KEY
# Warning: it uses Devise's stretches configuration to port the concept of REST_AUTH_DIGEST_STRETCHES
class ClearanceSha1 < Base
# Generates a default password digest based on salt, pepper and the
# incoming password.
def self.digest(password, stretches, salt, pepper)
Digest::SHA1.hexdigest("--#{salt}--#{password}--")
end
end
end
end

View File

@@ -1,22 +0,0 @@
require "digest/sha1"
module Devise
module Encryptors
# = RestfulAuthenticationSha1
# Simulates Restful Authentication's default encryption mechanism.
# Warning: it uses Devise's pepper to port the concept of REST_AUTH_SITE_KEY
# Warning: it uses Devise's stretches configuration to port the concept of REST_AUTH_DIGEST_STRETCHES. Should be set to 10 in
# the initializer to simulate the default behavior.
class RestfulAuthenticationSha1 < Base
# Generates a default password digest based on salt, pepper and the
# incoming password.
def self.digest(password, stretches, salt, pepper)
digest = pepper
stretches.times { digest = Digest::SHA1.hexdigest([digest, salt, password, pepper].flatten.join('--')) }
digest
end
end
end
end

View File

@@ -1,25 +0,0 @@
require "digest/sha1"
module Devise
module Encryptors
# = Sha1
# Uses the Sha1 hash algorithm to encrypt passwords.
class Sha1 < Base
# Generates a default password digest based on stretches, salt, pepper and the
# incoming password.
def self.digest(password, stretches, salt, pepper)
digest = pepper
stretches.times { digest = self.secure_digest(salt, digest, password, pepper) }
digest
end
private
# Generate a SHA1 digest joining args. Generated token is something like
# --arg1--arg2--arg3--argN--
def self.secure_digest(*tokens)
::Digest::SHA1.hexdigest('--' << tokens.flatten.join('--') << '--')
end
end
end
end

View File

@@ -1,25 +0,0 @@
require "digest/sha2"
module Devise
module Encryptors
# = Sha512
# Uses the Sha512 hash algorithm to encrypt passwords.
class Sha512 < Base
# Generates a default password digest based on salt, pepper and the
# incoming password.
def self.digest(password, stretches, salt, pepper)
digest = pepper
stretches.times { digest = self.secure_digest(salt, digest, password, pepper) }
digest
end
private
# Generate a Sha512 digest joining args. Generated token is something like
# --arg1--arg2--arg3--argN--
def self.secure_digest(*tokens)
::Digest::SHA512.hexdigest('--' << tokens.flatten.join('--') << '--')
end
end
end
end

View File

@@ -9,8 +9,9 @@ module Devise
include ActionController::RackDelegation
include ActionController::UrlFor
include ActionController::Redirecting
include Rails.application.routes.url_helpers
include Devise::Controllers::SharedHelpers
include Rails.application.routes.mounted_helpers
delegate :flash, :to => :request
@@ -20,7 +21,11 @@ module Devise
end
def self.default_url_options(*args)
ApplicationController.default_url_options(*args)
if defined?(ApplicationController)
ApplicationController.default_url_options(*args)
else
{}
end
end
def respond
@@ -48,32 +53,53 @@ module Devise
def redirect
store_location!
flash[:alert] = i18n_message
if flash[:timedout] && flash[:alert]
flash.keep(:timedout)
flash.keep(:alert)
else
flash[:alert] = i18n_message
end
redirect_to redirect_url
end
protected
def i18n_message(default = nil)
message = warden.message || warden_options[:message] || default || :unauthenticated
message = warden_message || default || :unauthenticated
if message.is_a?(Symbol)
I18n.t(:"#{scope}.#{message}", :resource_name => scope,
:scope => "devise.failure", :default => [message, message.to_s])
:scope => "devise.failure", :default => [message])
else
message.to_s
end
end
def redirect_url
if warden_message == :timeout
flash[:timedout] = true
attempted_path || scope_path
else
scope_path
end
end
def scope_path
opts = {}
route = :"new_#{scope}_session_path"
opts[:format] = request_format unless skip_format?
if respond_to?(route)
send(route, opts)
else
config = Rails.application.config
opts[:script_name] = (config.relative_url_root if config.respond_to?(:relative_url_root))
context = send(Devise.available_router_name)
if context.respond_to?(route)
context.send(route, opts)
elsif respond_to?(:root_path)
root_path(opts)
else
"/"
end
end
@@ -130,6 +156,10 @@ module Devise
env['warden.options']
end
def warden_message
@message ||= warden.message || warden_options[:message]
end
def scope
@scope ||= warden_options[:scope] || Devise.default_scope
end
@@ -145,5 +175,13 @@ module Devise
def store_location!
session["#{scope}_return_to"] = attempted_path if request.get? && !http_auth?
end
def is_navigational_format?
Devise.navigational_formats.include?(request_format)
end
def request_format
@request_format ||= request.format.try(:ref)
end
end
end

View File

@@ -0,0 +1,5 @@
Warden::Manager.after_authentication do |record, warden, options|
if Devise.clean_up_csrf_token_on_authentication
warden.request.session.try(:delete, :_csrf_token)
end
end

View File

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

View File

@@ -5,19 +5,20 @@
# verify timeout in the following request.
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
last_request_at = warden.session(scope)['last_request_at']
if record.timedout?(last_request_at)
path_checker = Devise::PathChecker.new(warden.env, scope)
unless path_checker.signing_out?
warden.logout(scope)
throw :warden, :scope => scope, :message => :timeout
if record.timedout?(last_request_at) && !env['devise.skip_timeout']
warden.logout(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
unless warden.request.env['devise.skip_trackable']
unless env['devise.skip_trackable']
warden.session(scope)['last_request_at'] = Time.now.utc
end
end

View File

@@ -11,9 +11,9 @@ module Devise
protected
# Configure default email options
def devise_mail(record, action)
def devise_mail(record, action, opts={})
initialize_from_record(record)
mail headers_for(action)
mail headers_for(action, opts)
end
def initialize_from_record(record)
@@ -25,28 +25,38 @@ module Devise
@devise_mapping ||= Devise.mappings[scope_name]
end
def headers_for(action)
def headers_for(action, opts)
headers = {
:subject => translate(devise_mapping, action),
:from => mailer_sender(devise_mapping),
:subject => subject_for(action),
:to => resource.email,
:template_path => template_paths
}
:from => mailer_sender(devise_mapping),
:reply_to => mailer_reply_to(devise_mapping),
:template_path => template_paths,
:template_name => action
}.merge(opts)
if resource.respond_to?(:headers_for)
ActiveSupport::Deprecation.warn "Calling headers_for in the model is no longer supported. " <<
"Please customize your mailer instead."
headers.merge!(resource.headers_for(action))
end
unless headers.key?(:reply_to)
headers[:reply_to] = headers[:from]
end
@email = headers[:to]
headers
end
def mailer_sender(mapping)
if default_params[:from].present?
default_params[:from]
def mailer_reply_to(mapping)
mailer_sender(mapping, :reply_to)
end
def mailer_from(mapping)
mailer_sender(mapping, :from)
end
def mailer_sender(mapping, sender = :from)
default_sender = default_params[sender]
if default_sender.present?
default_sender.respond_to?(:to_proc) ? instance_eval(&default_sender) : default_sender
elsif Devise.mailer_sender.is_a?(Proc)
Devise.mailer_sender.call(mapping.name)
else
@@ -55,12 +65,12 @@ module Devise
end
def template_paths
template_path = [self.class.mailer_name]
template_path = _prefixes.dup
template_path.unshift "#{@devise_mapping.scoped_path}/mailer" if self.class.scoped_views?
template_path
end
# Setup a subject doing an I18n lookup. At first, it attemps to set a subject
# Setup a subject doing an I18n lookup. At first, it attempts to set a subject
# based on the current mapping:
#
# en:
@@ -77,8 +87,8 @@ module Devise
# confirmation_instructions:
# subject: '...'
#
def translate(mapping, key)
I18n.t(:"#{mapping.name}_subject", :scope => [:devise, :mailer, key],
def subject_for(key)
I18n.t(:"#{devise_mapping.name}_subject", :scope => [:devise, :mailer, key],
:default => [:subject, key.to_s.humanize])
end
end

View File

@@ -23,8 +23,7 @@ module Devise
#
class Mapping #:nodoc:
attr_reader :singular, :scoped_path, :path, :controllers, :path_names,
:class_name, :sign_out_via, :format, :used_routes, :used_helpers,
:constraints, :defaults, :failure_app
:class_name, :sign_out_via, :format, :used_routes, :used_helpers, :failure_app
alias :name :singular
@@ -64,8 +63,6 @@ module Devise
default_failure_app(options)
default_controllers(options)
default_path_names(options)
default_constraints(options)
default_defaults(options)
default_used_route(options)
default_used_helpers(options)
end

View File

@@ -1,5 +1,15 @@
module Devise
module Models
class MissingAttribute < StandardError
def initialize(attributes)
@attributes = attributes
end
def message
"The following attribute(s) is (are) missing on your model: #{@attributes.join(", ")}"
end
end
# Creates configuration values for Devise and for the given module.
#
# Devise::Models.config(Devise::Authenticatable, :stretches, 10)
@@ -17,7 +27,7 @@ module Devise
# inside the given class.
#
def self.config(mod, *accessors) #:nodoc:
(class << mod; self; end).send :attr_accessor, :available_configs
class << mod; attr_accessor :available_configs; end
mod.available_configs = accessors
accessors.each do |accessor|
@@ -39,6 +49,29 @@ module Devise
end
end
def self.check_fields!(klass)
failed_attributes = []
instance = klass.new
klass.devise_modules.each do |mod|
constant = const_get(mod.to_s.classify)
if constant.respond_to?(:required_fields)
constant.required_fields(klass).each do |field|
failed_attributes << field unless instance.respond_to?(field)
end
else
ActiveSupport::Deprecation.warn "The module #{mod} doesn't implement self.required_fields(klass). " \
"Devise uses required_fields to warn developers of any missing fields in their models. " \
"Please implement #{mod}.required_fields(klass) that returns an array of symbols with the required fields."
end
end
if failed_attributes.any?
fail Devise::Models::MissingAttribute.new(failed_attributes)
end
end
# Include the chosen devise modules in your model:
#
# devise :database_authenticatable, :confirmable, :recoverable
@@ -48,7 +81,6 @@ module Devise
# for a complete description on those values.
#
def devise(*modules)
include Devise::Models::Authenticatable
options = modules.extract_options!.dup
selected_modules = modules.map(&:to_sym).uniq.sort_by do |s|
@@ -56,7 +88,12 @@ module Devise
end
devise_modules_hook! do
include Devise::Models::Authenticatable
selected_modules.each do |m|
if m == :encryptable && !(defined?(Devise::Models::Encryptable))
warn "[DEVISE] You're trying to include :encryptable in your model but it is not bundled with the Devise gem anymore. Please add `devise-encryptable` to your Gemfile to proceed.\n"
end
mod = Devise::Models.const_get(m.to_s.classify)
if mod.const_defined?("ClassMethods")
@@ -66,7 +103,7 @@ module Devise
if class_mod.respond_to?(:available_configs)
available_configs = class_mod.available_configs
available_configs.each do |config|
next unless options.key?(config)
next unless options.key?(config)
send(:"#{config}=", options.delete(config))
end
end
@@ -80,12 +117,12 @@ module Devise
end
end
# The hook which is called inside devise. So your ORM can include devise
# compatibility stuff.
# The hook which is called inside devise.
# So your ORM can include devise compatibility stuff.
def devise_modules_hook!
yield
end
end
end
require 'devise/models/authenticatable'
require 'devise/models/authenticatable'

View File

@@ -1,5 +1,5 @@
require 'devise/hooks/activatable'
require 'devise/models/serializable'
require 'devise/hooks/csrf_cleaner'
module Devise
module Models
@@ -11,12 +11,15 @@ module Devise
#
# * +authentication_keys+: parameters used for authentication. By default [:email].
#
# * +http_authentication_key+: map the username passed via HTTP Auth to this parameter. Defaults to
# the first element in +authentication_keys+.
#
# * +request_keys+: parameters from the request object used for authentication.
# By specifying a symbol (which should be a request method), it will automatically be
# passed to find_for_authentication method and considered in your model lookup.
#
# For instance, if you set :request_keys to [:subdomain], :subdomain will be considered
# as key on authentication. This can also be a hash where the value is a boolean expliciting
# as key on authentication. This can also be a hash where the value is a boolean specifying
# if the value is required or not.
#
# * +http_authenticatable+: if this model allows http authentication. By default true.
@@ -25,10 +28,15 @@ module Devise
# * +params_authenticatable+: if this model allows authentication through request params. By default true.
# It also accepts an array specifying the strategies that should allow params authentication.
#
# * +skip_session_storage+: By default Devise will store the user in session.
# You can skip storage for http and token auth by appending values to array:
# :skip_session_storage => [:token_auth] or :skip_session_storage => [:http_auth, :token_auth],
# by default is set to :skip_session_storage => [:http_auth].
#
# == active_for_authentication?
#
# After authenticating a user and in each request, Devise checks if your model is active by
# calling model.active_for_authentication?. This method is overwriten by other devise modules. For instance,
# 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:
@@ -47,11 +55,21 @@ module Devise
module Authenticatable
extend ActiveSupport::Concern
include Devise::Models::Serializable
BLACKLIST_FOR_SERIALIZATION = [:encrypted_password, :reset_password_token, :reset_password_sent_at,
:remember_created_at, :sign_in_count, :current_sign_in_at, :last_sign_in_at, :current_sign_in_ip,
:last_sign_in_ip, :password_salt, :confirmation_token, :confirmed_at, :confirmation_sent_at,
:remember_token, :unconfirmed_email, :failed_attempts, :unlock_token, :locked_at, :authentication_token]
included do
class_attribute :devise_modules, :instance_writer => false
self.devise_modules ||= []
before_validation :downcase_keys
before_validation :strip_whitespace
end
def self.required_fields(klass)
[]
end
# Check if the current object is valid for authentication. This method and
@@ -64,6 +82,10 @@ module Devise
block_given? ? yield : true
end
def unauthenticated_message
:invalid
end
def active_for_authentication?
true
end
@@ -75,12 +97,109 @@ 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"
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
super(options)
end
RUBY
end
protected
def devise_mailer
Devise.mailer
end
# This is an internal method called every time Devise needs
# to send a notification/mail. This can be overriden if you
# need to customize the e-mail delivery logic. For instance,
# if you are using a queue to deliver e-mails (delayed job,
# sidekiq, resque, etc), you must add the delivery to the queue
# just after the transaction was committed. To achieve this,
# you can override send_devise_notification to store the
# deliveries until the after_commit callback is triggered:
#
# class User
# devise :database_authenticatable, :confirmable
#
# after_commit :send_pending_notifications
#
# protected
#
# def send_devise_notification(notification, opts = {})
# # if the record is new or changed then delay the
# # delivery until the after_commit callback otherwise
# # send now because after_commit will not be called.
# if new_record? || changed?
# pending_notifications << [notification, opts]
# else
# devise_mailer.send(notification, self, opts).deliver
# end
# end
#
# def send_pending_notifications
# pending_notifications.each do |n, opts|
# devise_mailer.send(n, self, opts).deliver
# end
#
# # Empty the pending notifications array because the
# # after_commit hook can be called multiple times which
# # could cause multiple emails to be sent.
# pending_notifications.clear
# end
#
# def pending_notifications
# @pending_notifications ||= []
# end
# end
#
def send_devise_notification(notification, opts={})
devise_mailer.send(notification, self, opts).deliver
end
def downcase_keys
self.class.case_insensitive_keys.each { |k| apply_to_attribute_or_variable(k, :downcase!) }
end
def strip_whitespace
self.class.strip_whitespace_keys.each { |k| apply_to_attribute_or_variable(k, :strip!) }
end
def apply_to_attribute_or_variable(attr, method)
if self[attr]
self[attr].try(method)
# Use respond_to? here to avoid a regression where globally
# configured strip_whitespace_keys or case_insensitive_keys were
# attempting to strip! or downcase! when a model didn't have the
# globally configured key.
elsif respond_to?(attr)
send(attr).try(method)
end
end
module ClassMethods
Devise::Models.config(self, :authentication_keys, :request_keys, :strip_whitespace_keys, :case_insensitive_keys, :http_authenticatable, :params_authenticatable)
Devise::Models.config(self, :authentication_keys, :request_keys, :strip_whitespace_keys,
:case_insensitive_keys, :http_authenticatable, :params_authenticatable, :skip_session_storage,
:http_authentication_key)
def serialize_into_session(record)
[record.to_key, record.authenticatable_salt]
@@ -102,21 +221,30 @@ module Devise
end
# Find first record based on conditions given (ie by the sign in form).
# This method is always called during an authentication process but
# it may be wrapped as well. For instance, database authenticatable
# provides a `find_for_database_authentication` that wraps a call to
# this method. This allows you to customize both database authenticatable
# or the whole authenticate stack by customize `find_for_authentication.`
#
# Overwrite to add customized conditions, create a join, or maybe use a
# namedscope to filter records while authenticating.
# Example:
#
# def self.find_for_authentication(conditions={})
# conditions[:active] = true
# super
# def self.find_for_authentication(tainted_conditions)
# find_first_by_auth_conditions(tainted_conditions, :active => true)
# end
#
def find_for_authentication(conditions)
find_first_by_auth_conditions(conditions)
# Finally, notice that Devise also queries for users in other scenarios
# besides authentication, for example when retrieving an user to send
# an e-mail for password reset. In such cases, find_for_authentication
# is not called.
def find_for_authentication(tainted_conditions)
find_first_by_auth_conditions(tainted_conditions)
end
def find_first_by_auth_conditions(conditions)
to_adapter.find_first devise_param_filter.filter(conditions)
def find_first_by_auth_conditions(tainted_conditions, opts={})
to_adapter.find_first(devise_param_filter.filter(tainted_conditions).merge(opts))
end
# Find an initialize a record setting an error if it can't be found.
@@ -162,4 +290,4 @@ module Devise
end
end
end
end
end

View File

@@ -9,11 +9,18 @@ module Devise
#
# Confirmable adds the following options to devise_for:
#
# * +confirm_within+: the time you want to allow the user to access his account
# * +allow_unconfirmed_access_for+: the time you want to allow the user to access his account
# before confirming it. After this period, the user access is denied. You can
# use this to let your user access some features of your application without
# confirming the account, but blocking it after a certain period (ie 7 days).
# By default confirm_within is zero, it means users always have to confirm to sign in.
# 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
# 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.
#
# == Examples
#
@@ -23,19 +30,52 @@ module Devise
#
module Confirmable
extend ActiveSupport::Concern
include ActionView::Helpers::DateHelper
included do
before_create :generate_confirmation_token, :if => :confirmation_required?
after_create :send_confirmation_instructions, :if => :confirmation_required?
after_create :send_on_create_confirmation_instructions, :if => :send_confirmation_notification?
before_update :postpone_email_change_until_confirmation, :if => :postpone_email_change?
after_update :send_confirmation_instructions, :if => :reconfirmation_required?
end
# Confirm a user by setting its confirmed_at to actual time. If the user
# is already confirmed, add en error to email field
def initialize(*args, &block)
@bypass_postpone = false
@reconfirmation_required = false
@skip_confirmation_notification = false
super
end
def self.required_fields(klass)
required_methods = [:confirmation_token, :confirmed_at, :confirmation_sent_at]
required_methods << :unconfirmed_email if klass.reconfirmable
required_methods
end
# 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!
unless_confirmed do
pending_any_confirmation do
if confirmation_period_expired?
self.errors.add(:email, :confirmation_period_expired,
:period => Devise::TimeInflector.time_ago_in_words(self.class.confirm_within.ago))
return false
end
self.confirmation_token = nil
self.confirmed_at = Time.now.utc
save(:validate => false)
if self.class.reconfirmable && unconfirmed_email.present?
skip_reconfirmation!
self.email = unconfirmed_email
self.unconfirmed_email = nil
# We need to validate in such cases to enforce e-mail uniqueness
save(:validate => true)
else
save(:validate => false)
end
end
end
@@ -44,15 +84,27 @@ module Devise
!!confirmed_at
end
def pending_reconfirmation?
self.class.reconfirmable && unconfirmed_email.present?
end
# Send confirmation instructions by email
def send_confirmation_instructions
generate_confirmation_token! if self.confirmation_token.nil?
self.devise_mailer.confirmation_instructions(self).deliver
self.confirmation_token = nil if reconfirmation_required?
@reconfirmation_required = false
generate_confirmation_token! if self.confirmation_token.blank?
opts = pending_reconfirmation? ? { :to => unconfirmed_email } : { }
send_devise_notification(:confirmation_instructions, opts)
end
# Resend confirmation token. This method does not need to generate a new token.
def resend_confirmation_token
unless_confirmed { send_confirmation_instructions }
pending_any_confirmation do
self.confirmation_token = nil if confirmation_period_expired?
send_confirmation_instructions
end
end
# Overwrites active_for_authentication? for confirmation
@@ -74,8 +126,27 @@ module Devise
self.confirmed_at = Time.now.utc
end
# Skips sending the confirmation notification email after_create. Unlike
# #skip_confirmation!, record still requires confirmation.
def skip_confirmation_notification!
@skip_confirmation_notification = true
end
# If you don't want reconfirmation to be sent, neither a code
# to be generated, call skip_reconfirmation!
def skip_reconfirmation!
@bypass_postpone = true
end
protected
# A callback method used to deliver confirmation
# instructions on creation. This can be overriden
# in models to map to a nice sign up e-mail.
def send_on_create_confirmation_instructions
send_devise_notification(:confirmation_instructions)
end
# Callback to overwrite if confirmation is required or not.
def confirmation_required?
!confirmed?
@@ -88,26 +159,44 @@ module Devise
#
# Example:
#
# # confirm_within = 1.day and confirmation_sent_at = today
# # allow_unconfirmed_access_for = 1.day and confirmation_sent_at = today
# confirmation_period_valid? # returns true
#
# # confirm_within = 5.days and confirmation_sent_at = 4.days.ago
# # allow_unconfirmed_access_for = 5.days and confirmation_sent_at = 4.days.ago
# confirmation_period_valid? # returns true
#
# # confirm_within = 5.days and confirmation_sent_at = 5.days.ago
# # allow_unconfirmed_access_for = 5.days and confirmation_sent_at = 5.days.ago
# confirmation_period_valid? # returns false
#
# # confirm_within = 0.days
# # allow_unconfirmed_access_for = 0.days
# confirmation_period_valid? # will always return false
#
# # allow_unconfirmed_access_for = nil
# confirmation_period_valid? # will always return true
#
def confirmation_period_valid?
confirmation_sent_at && confirmation_sent_at.utc >= self.class.confirm_within.ago
self.class.allow_unconfirmed_access_for.nil? || (confirmation_sent_at && confirmation_sent_at.utc >= self.class.allow_unconfirmed_access_for.ago)
end
# Checks whether the record is confirmed or not, yielding to the block
# if it's already confirmed, otherwise adds an error to email.
def unless_confirmed
unless confirmed?
# Checks if the user confirmation happens before the token becomes invalid
# Examples:
#
# # confirm_within = 3.days and confirmation_sent_at = 2.days.ago
# confirmation_period_expired? # returns false
#
# # confirm_within = 3.days and confirmation_sent_at = 4.days.ago
# confirmation_period_expired? # returns true
#
# # confirm_within = nil
# 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 )
end
# Checks whether the record requires any confirmation.
def pending_any_confirmation
if (!confirmed? || pending_reconfirmation?)
yield
else
self.errors.add(:email, :already_confirmed)
@@ -118,7 +207,6 @@ module Devise
# Generates a new random token for confirmation, and stores the time
# this token is being generated
def generate_confirmation_token
self.confirmed_at = nil
self.confirmation_token = self.class.confirmation_token
self.confirmation_sent_at = Time.now.utc
end
@@ -127,18 +215,36 @@ module Devise
generate_confirmation_token && save(:validate => false)
end
def after_password_reset
super
confirm! unless confirmed?
def postpone_email_change_until_confirmation
@reconfirmation_required = true
self.unconfirmed_email = self.email
self.email = self.email_was
end
def postpone_email_change?
postpone = self.class.reconfirmable && email_changed? && !@bypass_postpone
@bypass_postpone = false
postpone
end
def reconfirmation_required?
self.class.reconfirmable && @reconfirmation_required
end
def send_confirmation_notification?
confirmation_required? && !@skip_confirmation_notification
end
module ClassMethods
# Attempt to find a user by its email. If a record is found, send new
# confirmation instructions to it. If not user is found, returns a new user
# with an email not found error.
# confirmation instructions to it. If not, try searching for a user by unconfirmed_email
# field. If no user is found, returns a new user with an email not found error.
# Options must contain the user email
def send_confirmation_instructions(attributes={})
confirmable = find_or_initialize_with_errors(confirmation_keys, attributes, :not_found)
confirmable = find_by_unconfirmed_email_with_errors(attributes) if reconfirmable
unless confirmable.try(:persisted?)
confirmable = find_or_initialize_with_errors(confirmation_keys, attributes, :not_found)
end
confirmable.resend_confirmation_token if confirmable.persisted?
confirmable
end
@@ -158,7 +264,15 @@ module Devise
generate_token(:confirmation_token)
end
Devise::Models.config(self, :confirm_within, :confirmation_keys)
# Find a record for confirmation by unconfirmed email field
def find_by_unconfirmed_email_with_errors(attributes = {})
unconfirmed_required_attributes = confirmation_keys.map { |k| k == :email ? :unconfirmed_email : k }
unconfirmed_attributes = attributes.symbolize_keys
unconfirmed_attributes[:unconfirmed_email] = unconfirmed_attributes.delete(:email)
find_or_initialize_with_errors(unconfirmed_required_attributes, unconfirmed_attributes, :not_found)
end
Devise::Models.config(self, :allow_unconfirmed_access_for, :confirmation_keys, :reconfirmable, :confirm_within)
end
end
end

View File

@@ -25,8 +25,10 @@ module Devise
included do
attr_reader :password, :current_password
attr_accessor :password_confirmation
before_validation :downcase_keys
before_validation :strip_whitespace
end
def self.required_fields(klass)
[:encrypted_password] + klass.authentication_keys
end
# Generates password encryption based on the given value.
@@ -38,9 +40,9 @@ module Devise
# Verifies whether an password (ie from sign in) is the user password.
def valid_password?(password)
return false if encrypted_password.blank?
bcrypt = ::BCrypt::Password.new(self.encrypted_password)
bcrypt = ::BCrypt::Password.new(encrypted_password)
password = ::BCrypt::Engine.hash_secret("#{password}#{self.class.pepper}", bcrypt.salt)
Devise.secure_compare(password, self.encrypted_password)
Devise.secure_compare(password, encrypted_password)
end
# Set password and password confirmation to nil
@@ -62,7 +64,7 @@ module Devise
result = if valid_password?(current_password)
update_attributes(params, *options)
else
self.attributes = params
self.assign_attributes(params, *options)
self.valid?
self.errors.add(:current_password, current_password.blank? ? :blank : :invalid)
false
@@ -73,7 +75,7 @@ module Devise
end
# Updates record attributes without asking for the current password.
# Never allows to change the current password. If you are using this
# Never allows a change to the current password. If you are using this
# method, you should probably override this method to protect other
# attributes you would not like to be updated without a password.
#
@@ -93,25 +95,31 @@ module Devise
result
end
# Destroy record when :current_password matches, otherwise returns
# error on :current_password. It also automatically rejects
# :current_password if it is blank.
def destroy_with_password(current_password)
result = if valid_password?(current_password)
destroy
else
self.valid?
self.errors.add(:current_password, current_password.blank? ? :blank : :invalid)
false
end
result
end
def after_database_authentication
end
# A reliable way to expose the salt regardless of the implementation.
def authenticatable_salt
self.encrypted_password[0,29] if self.encrypted_password
encrypted_password[0,29] if encrypted_password
end
protected
# Downcase case-insensitive keys
def downcase_keys
(self.class.case_insensitive_keys || []).each { |k| self[k].try(:downcase!) }
end
def strip_whitespace
(self.class.strip_whitespace_keys || []).each { |k| self[k].try(:strip!) }
end
# Digests the password using bcrypt.
def password_digest(password)
::BCrypt::Password.create("#{password}#{self.class.pepper}", :cost => self.class.stretches).to_s

View File

@@ -1,72 +0,0 @@
require 'devise/strategies/database_authenticatable'
module Devise
module Models
# Encryptable Module adds support to several encryptors.
#
# == Options
#
# Encryptable adds the following options to devise_for:
#
# * +pepper+: a random string used to provide a more secure hash.
#
# * +encryptor+: the encryptor going to be used. By default is nil.
#
# == Examples
#
# User.find(1).valid_password?('password123') # returns true/false
#
module Encryptable
extend ActiveSupport::Concern
included do
attr_reader :password, :current_password
attr_accessor :password_confirmation
end
# Generates password salt.
def password=(new_password)
self.password_salt = self.class.password_salt if new_password.present?
super
end
def authenticatable_salt
self.password_salt
end
# Verifies whether an incoming_password (ie from sign in) is the user password.
def valid_password?(incoming_password)
Devise.secure_compare(password_digest(incoming_password), self.encrypted_password)
end
protected
# Digests the password using the configured encryptor.
def password_digest(password)
if self.password_salt.present?
self.class.encryptor_class.digest(password, self.class.stretches, self.password_salt, self.class.pepper)
end
end
module ClassMethods
Devise::Models.config(self, :encryptor)
# Returns the class for the configured encryptor.
def encryptor_class
@encryptor_class ||= case encryptor
when :bcrypt
raise "In order to use bcrypt as encryptor, simply remove :encryptable from your devise model"
when nil
raise "You need to give an :encryptor as option in order to use :encryptable"
else
::Devise::Encryptors.const_get(encryptor.to_s.classify)
end
end
def password_salt
self.encryptor_class.salt(self.stretches)
end
end
end
end
end

View File

@@ -1,3 +1,5 @@
require "devise/hooks/lockable"
module Devise
module Models
# Handles blocking a user access after a certain number of attempts.
@@ -22,19 +24,28 @@ module Devise
delegate :lock_strategy_enabled?, :unlock_strategy_enabled?, :to => "self.class"
def self.required_fields(klass)
attributes = []
attributes << :failed_attempts if klass.lock_strategy_enabled?(:failed_attempts)
attributes << :locked_at if klass.unlock_strategy_enabled?(:time)
attributes << :unlock_token if klass.unlock_strategy_enabled?(:email)
attributes
end
# Lock a user setting its locked_at to actual time.
def lock_access!
self.locked_at = Time.now.utc
if unlock_strategy_enabled?(:email)
generate_unlock_token
generate_unlock_token!
send_unlock_instructions
else
save(:validate => false)
end
save(:validate => false)
end
# Unlock a user by cleaning locket_at and failed_attempts.
# Unlock a user by cleaning locked_at and failed_attempts.
def unlock_access!
self.locked_at = nil
self.failed_attempts = 0 if respond_to?(:failed_attempts=)
@@ -49,7 +60,7 @@ module Devise
# Send unlock instructions by email
def send_unlock_instructions
self.devise_mailer.unlock_instructions(self).deliver
send_devise_notification(:unlock_instructions)
end
# Resend the unlock instructions if the user is locked.
@@ -79,16 +90,13 @@ module Devise
# if the user can login or not (wrong password, etc)
unlock_access! if lock_expired?
if super
self.failed_attempts = 0
save(:validate => false)
if super && !access_locked?
true
else
self.failed_attempts ||= 0
self.failed_attempts += 1
if attempts_exceeded?
lock_access! unless access_locked?
return :locked
else
save(:validate => false)
end
@@ -96,6 +104,18 @@ module Devise
end
end
def unauthenticated_message
# If set to paranoid mode, do not show the locked message because it
# leaks the existence of an account.
if Devise.paranoid
super
elsif lock_strategy_enabled?(:failed_attempts) && attempts_exceeded?
:locked
else
super
end
end
protected
def attempts_exceeded?
@@ -107,6 +127,10 @@ module Devise
self.unlock_token = self.class.unlock_token
end
def generate_unlock_token!
generate_unlock_token && save(:validate => false)
end
# Tells if the lock is expired if :time unlock strategy is active
def lock_expired?
if unlock_strategy_enabled?(:time)
@@ -133,9 +157,9 @@ module Devise
# with an email not found error.
# Options must contain the user email
def send_unlock_instructions(attributes={})
lockable = find_or_initialize_with_errors(unlock_keys, attributes, :not_found)
lockable.resend_unlock_token if lockable.persisted?
lockable
lockable = find_or_initialize_with_errors(unlock_keys, attributes, :not_found)
lockable.resend_unlock_token if lockable.persisted?
lockable
end
# Find a user by its unlock token and try to unlock it.

View File

@@ -8,16 +8,20 @@ module Devise
#
# Oauthable adds the following options to devise_for:
#
# * +omniauth_providers+: Which providers are avaialble to this model. It expects an array:
# * +omniauth_providers+: Which providers are available to this model. It expects an array:
#
# devise_for :database_authenticatable, :omniauthable, :omniauth_providers => [:twitter]
#
module Omniauthable
extend ActiveSupport::Concern
def self.required_fields(klass)
[]
end
module ClassMethods
Devise::Models.config(self, :omniauth_providers)
end
end
end
end
end

View File

@@ -1,7 +1,7 @@
module Devise
module Models
# Recoverable takes care of reseting the user password and send reset instructions.
# Recoverable takes care of resetting the user password and send reset instructions.
#
# ==Options
#
@@ -24,11 +24,16 @@ module Devise
module Recoverable
extend ActiveSupport::Concern
def self.required_fields(klass)
[:reset_password_sent_at, :reset_password_token]
end
# Update password saving the record and clearing token. Returns true if
# the passwords are valid and the record was saved, false otherwise.
def reset_password!(new_password, new_password_confirmation)
self.password = new_password
self.password_confirmation = new_password_confirmation
if valid?
clear_reset_password_token
after_password_reset
@@ -39,8 +44,8 @@ module Devise
# Resets reset password token and send reset password instructions by email
def send_reset_password_instructions
generate_reset_password_token! if should_generate_token?
self.devise_mailer.reset_password_instructions(self).deliver
generate_reset_password_token! if should_generate_reset_token?
send_devise_notification(:reset_password_instructions)
end
# Checks if the reset password token sent is within the limit time.
@@ -64,20 +69,19 @@ module Devise
# reset_password_period_valid? # will always return false
#
def reset_password_period_valid?
return true unless respond_to?(:reset_password_sent_at)
reset_password_sent_at && reset_password_sent_at.utc >= self.class.reset_password_within.ago
end
protected
def should_generate_token?
def should_generate_reset_token?
reset_password_token.nil? || !reset_password_period_valid?
end
# Generates a new random token for reset password
def generate_reset_password_token
self.reset_password_token = self.class.reset_password_token
self.reset_password_sent_at = Time.now.utc if respond_to?(:reset_password_sent_at=)
self.reset_password_sent_at = Time.now.utc
self.reset_password_token
end
@@ -90,7 +94,7 @@ module Devise
# Removes reset_password token
def clear_reset_password_token
self.reset_password_token = nil
self.reset_password_sent_at = nil if respond_to?(:reset_password_sent_at=)
self.reset_password_sent_at = nil
end
def after_password_reset
@@ -98,9 +102,9 @@ module Devise
module ClassMethods
# Attempt to find a user by its email. If a record is found, send new
# password instructions to it. If not user is found, returns a new user
# password instructions to it. If user is not found, returns a new user
# with an email not found error.
# Attributes must contain the user email
# Attributes must contain the user's email
def send_reset_password_instructions(attributes={})
recoverable = find_or_initialize_with_errors(reset_password_keys, attributes, :not_found)
recoverable.send_reset_password_instructions if recoverable.persisted?

View File

@@ -5,6 +5,10 @@ module Devise
module Registerable
extend ActiveSupport::Concern
def self.required_fields(klass)
[]
end
module ClassMethods
# A convenience method that receives both parameters and session to
# initialize a user. This can be used by OAuth, for example, to send

View File

@@ -21,15 +21,10 @@ module Devise
# used to calculate the expires time for the cookie created to remember
# the user. By default remember_for is 2.weeks.
#
# * +remember_across_browsers+: if a valid remember token can be re-used
# between multiple browsers. By default remember_across_browsers is true
# and cannot be turned off if you are using password salt instead of remember
# token.
#
# * +extend_remember_period+: if true, extends the user's remember period
# when remembered via cookie. False by default.
#
# * +cookie_options+: configuration options passed to the created cookie.
# * +rememberable_options+: configuration options passed to the created cookie.
#
# == Examples
#
@@ -46,10 +41,14 @@ module Devise
attr_accessor :remember_me, :extend_remember_period
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 respond_to?(:remember_token) && generate_remember_token?
self.remember_token = self.class.remember_token if generate_remember_token?
self.remember_created_at = Time.now.utc if generate_remember_timestamp?(extend_period)
save(:validate => false)
end
@@ -57,11 +56,10 @@ module Devise
# If the record is persisted, remove the remember token (but only if
# it exists), and save the record without validations.
def forget_me!
if persisted?
self.remember_token = nil if respond_to?(:remember_token=)
self.remember_created_at = nil
save(:validate => false)
end
return unless persisted?
self.remember_token = nil if respond_to?(:remember_token=)
self.remember_created_at = nil
save(:validate => false)
end
# Remember token should be expired if expiration time not overpass now.
@@ -80,22 +78,21 @@ module Devise
elsif respond_to?(:authenticatable_salt) && (salt = authenticatable_salt)
salt
else
raise "The #{self.class.name} class does not respond to remember_token and " <<
"authenticatable_salt returns nil. In order to use rememberable, you must " <<
"add a remember_token field to your model or ensure a password is always set."
raise "authenticable_salt returned nil for the #{self.class.name} model. " \
"In order to use rememberable, you must ensure a password is always set " \
"or have a remember_token column in your model or implement your own " \
"rememberable_value in the model with custom logic."
end
end
def cookie_options
self.class.cookie_options
def rememberable_options
self.class.rememberable_options
end
protected
# Generate a token unless remember_across_browsers is true and there is
# an existing remember_token or the existing remember_token has expried.
def generate_remember_token? #:nodoc:
!(self.class.remember_across_browsers && remember_token) || remember_expired?
respond_to?(:remember_token) && remember_expired?
end
# Generate a timestamp if extend_remember_period is true, if no remember_token
@@ -117,12 +114,11 @@ module Devise
end
# Generate a token checking if one does not already exist in the database.
def remember_token
def remember_token #:nodoc:
generate_token(:remember_token)
end
Devise::Models.config(self, :remember_for, :remember_across_browsers,
:extend_remember_period, :cookie_options)
Devise::Models.config(self, :remember_for, :extend_remember_period, :rememberable_options)
end
end
end

View File

@@ -1,43 +0,0 @@
module Devise
module Models
# This module 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.
module Serializable
extend ActiveSupport::Concern
# TODO: to_xml does not call serializable_hash. Hopefully someone will fix this in AR.
%w(to_xml serializable_hash).each do |method|
class_eval <<-RUBY, __FILE__, __LINE__
def #{method}(options=nil)
options ||= {}
if options.key?(:force_except)
options[:except] = options.delete(:force_except)
super(options)
elsif self.class.blacklist_keys?
except = Array(options[:except])
super(options.merge(:except => except + self.class.blacklist_keys))
else
super
end
end
RUBY
end
module ClassMethods
# Return true if we can retrieve blacklist keys from the record.
def blacklist_keys?
@has_except_keys ||= respond_to?(:accessible_attributes) && !accessible_attributes.to_a.empty?
end
# Returns keys that should be removed when serializing the record.
def blacklist_keys
@blacklist_keys ||= to_adapter.column_names.map(&:to_s) - accessible_attributes.to_a.map(&:to_s)
end
end
end
end
end

View File

@@ -2,7 +2,7 @@ require 'devise/hooks/timeoutable'
module Devise
module Models
# Timeoutable takes care of veryfing whether a user session has already
# Timeoutable takes care of verifyng whether a user session has already
# expired or not. When a session expires after the configured time, the user
# will be asked for credentials again, it means, he/she will be redirected
# to the sign in page.
@@ -20,10 +20,13 @@ module Devise
module Timeoutable
extend ActiveSupport::Concern
def self.required_fields(klass)
[]
end
# 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
@@ -34,8 +37,7 @@ module Devise
private
def remember_exists_and_not_expired?
return false unless respond_to?(:remember_expired?)
return false unless respond_to?(:remember_created_at)
remember_created_at && !remember_expired?
end

View File

@@ -18,18 +18,31 @@ module Devise
# If you want to delete the token after it is used, you can do so in the
# after_token_authentication callback.
#
# == APIs
#
# If you are using token authentication with APIs and using trackable. Every
# request will be considered as a new sign in (since there is no session in
# APIs). You can disable this by creating a before filter as follow:
#
# before_filter :skip_trackable
#
# def skip_trackable
# request.env['devise.skip_trackable'] = true
# end
#
# == Options
#
# TokenAuthenticatable adds the following options to devise_for:
#
# * +token_authentication_key+: Defines name of the authentication token params key. E.g. /users/sign_in?some_key=...
#
# * +stateless_token+: By default, when you sign up with a token, Devise will store the user in session
# as any other authentication strategy. You can set stateless_token to true to avoid this.
#
module TokenAuthenticatable
extend ActiveSupport::Concern
def self.required_fields(klass)
[:authentication_token]
end
# Generate new authentication token (a.k.a. "single access token").
def reset_authentication_token
self.authentication_token = self.class.authentication_token
@@ -55,6 +68,10 @@ module Devise
def after_token_authentication
end
def expire_auth_token_on_timeout
self.class.expire_auth_token_on_timeout
end
module ClassMethods
def find_for_token_authentication(conditions)
find_for_authentication(:authentication_token => conditions[token_authentication_key])
@@ -65,7 +82,7 @@ module Devise
generate_token(:authentication_token)
end
::Devise::Models.config(self, :token_authentication_key, :stateless_token)
Devise::Models.config(self, :token_authentication_key, :expire_auth_token_on_timeout)
end
end
end

View File

@@ -11,19 +11,24 @@ module Devise
# * last_sign_in_ip - Holds the remote ip of the previous sign in
#
module Trackable
def self.required_fields(klass)
[:current_sign_in_at, :current_sign_in_ip, :last_sign_in_at, :last_sign_in_ip, :sign_in_count]
end
def update_tracked_fields!(request)
old_current, new_current = self.current_sign_in_at, Time.now.utc
self.last_sign_in_at = old_current || new_current
self.current_sign_in_at = new_current
old_current, new_current = self.current_sign_in_ip, request.ip
old_current, new_current = self.current_sign_in_ip, request.remote_ip
self.last_sign_in_ip = old_current || new_current
self.current_sign_in_ip = new_current
self.sign_in_count ||= 0
self.sign_in_count += 1
save(:validate => false)
save(:validate => false) or raise "Devise trackable could not save #{inspect}." \
"Please make sure a model using trackable can be saved at sign in."
end
end
end

View File

@@ -10,20 +10,24 @@ 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 6..128.
# * +password_length+: a range expressing password length. Defaults to 8..128.
#
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
def self.required_fields(klass)
[]
end
def self.included(base)
base.extend ClassMethods
assert_validations_api!(base)
base.class_eval do
validates_presence_of :email, :if => :email_required?
validates_uniqueness_of :email, :case_sensitive => (case_insensitive_keys != false), :allow_blank => true, :if => :email_changed?
validates_uniqueness_of :email, :allow_blank => true, :if => :email_changed?
validates_format_of :email, :with => email_regexp, :allow_blank => true, :if => :email_changed?
validates_presence_of :password, :if => :password_required?

View File

@@ -5,12 +5,11 @@ Devise.with_options :model => true do |d|
d.with_options :strategy => true do |s|
routes = [nil, :new, :destroy]
s.add_module :database_authenticatable, :controller => :sessions, :route => { :session => routes }
s.add_module :token_authenticatable
s.add_module :rememberable
s.add_module :token_authenticatable, :controller => :sessions, :route => { :session => routes }, :no_input => true
s.add_module :rememberable, :no_input => true
end
# Other authentications
d.add_module :encryptable
d.add_module :omniauthable, :controller => :omniauth_callbacks, :route => :omniauth_callback
# Misc after

View File

@@ -1,7 +1,7 @@
begin
require "omniauth"
require "omniauth/version"
rescue LoadError => e
rescue LoadError
warn "Could not load 'omniauth'. Please ensure you have the omniauth gem >= 1.0.0 installed and listed in your Gemfile."
raise
end

View File

@@ -2,21 +2,6 @@ module Devise
module OmniAuth
module UrlHelpers
def self.define_helpers(mapping)
return unless mapping.omniauthable?
class_eval <<-URL_HELPERS, __FILE__, __LINE__ + 1
def #{mapping.name}_omniauth_authorize_path(provider, params = {})
if Devise.omniauth_configs[provider.to_sym]
script_name = request.env["SCRIPT_NAME"]
path = "\#{script_name}/#{mapping.path}/auth/\#{provider}\".squeeze("/")
path << '?' + params.to_param if params.present?
path
else
raise ArgumentError, "Could not find omniauth provider \#{provider.inspect}"
end
end
URL_HELPERS
end
def omniauth_authorize_path(resource_or_scope, *args)

View File

@@ -1,38 +1,3 @@
require 'orm_adapter/adapters/active_record'
module Devise
module Orm
# This module contains some helpers and handle schema (migrations):
#
# create_table :accounts do |t|
# t.database_authenticatable
# t.confirmable
# t.recoverable
# t.rememberable
# t.trackable
# t.lockable
# t.timestamps
# end
#
# However this method does not add indexes. If you need them, here is the declaration:
#
# add_index "accounts", ["email"], :name => "email", :unique => true
# add_index "accounts", ["confirmation_token"], :name => "confirmation_token", :unique => true
# add_index "accounts", ["reset_password_token"], :name => "reset_password_token", :unique => true
#
module ActiveRecord
module Schema
include Devise::Schema
# Tell how to apply schema methods.
def apply_devise_schema(name, type, options={})
column name, type.to_s.downcase.to_sym, options
end
end
end
end
end
ActiveRecord::Base.extend Devise::Models
ActiveRecord::ConnectionAdapters::Table.send :include, Devise::Orm::ActiveRecord::Schema
ActiveRecord::ConnectionAdapters::TableDefinition.send :include, Devise::Orm::ActiveRecord::Schema
ActiveRecord::Base.extend Devise::Models

View File

@@ -1,31 +1,3 @@
require 'orm_adapter/adapters/mongoid'
module Devise
module Orm
module Mongoid
module Hook
def devise_modules_hook!
extend Schema
yield
return unless Devise.apply_schema
devise_modules.each { |m| send(m) if respond_to?(m, true) }
end
end
module Schema
include Devise::Schema
# Tell how to apply schema methods
def apply_devise_schema(name, type, options={})
type = Time if type == DateTime
field name, { :type => type }.merge!(options)
end
end
end
end
end
Mongoid::Document::ClassMethods.class_eval do
include Devise::Models
include Devise::Orm::Mongoid::Hook
end
Mongoid::Document::ClassMethods.send :include, Devise::Models

View File

@@ -8,16 +8,16 @@ module Devise
def filter(conditions)
conditions = stringify_params(conditions.dup)
@case_insensitive_keys.each do |k|
value = conditions[k]
next unless value.respond_to?(:downcase)
conditions[k] = value.downcase
end
conditions.merge!(filtered_hash_by_method_for_given_keys(conditions.dup, :downcase, @case_insensitive_keys))
conditions.merge!(filtered_hash_by_method_for_given_keys(conditions.dup, :strip, @strip_whitespace_keys))
@strip_whitespace_keys.each do |k|
conditions
end
def filtered_hash_by_method_for_given_keys(conditions, method, condition_keys)
condition_keys.each do |k|
value = conditions[k]
next unless value.respond_to?(:strip)
conditions[k] = value.strip
conditions[k] = value.send(method) if value.respond_to?(method)
end
conditions
@@ -33,9 +33,8 @@ module Devise
private
# Determine which values should be transformed to string or passed as-is to the query builder underneath
def param_requires_string_conversion?(value)
true unless value.is_a?(TrueClass) || value.is_a?(FalseClass) || value.is_a?(Fixnum)
true
end
end
end

View File

@@ -1,18 +0,0 @@
module Devise
class PathChecker
include Rails.application.routes.url_helpers
def self.default_url_options(*args)
ApplicationController.default_url_options(*args)
end
def initialize(env, scope)
@current_path = "/#{env["SCRIPT_NAME"]}/#{env["PATH_INFO"]}".squeeze("/")
@scope = scope
end
def signing_out?
@current_path == send("destroy_#{@scope}_session_path")
end
end
end

View File

@@ -41,5 +41,14 @@ module Devise
end
end
end
initializer "devise.fix_routes_proxy_missing_respond_to_bug" do
# We can get rid of this once we support only Rails > 3.2
ActionDispatch::Routing::RoutesProxy.class_eval do
def respond_to?(method, include_private = false)
super || routes.url_helpers.respond_to?(method)
end
end
end
end
end

View File

@@ -1,15 +1,28 @@
require "active_support/core_ext/object/try"
require "active_support/core_ext/hash/slice"
module ActionDispatch::Routing
class RouteSet #:nodoc:
# Ensure Devise modules are included only after loading routes, because we
# need devise_for mappings already declared to create filters and helpers.
def finalize_with_devise!
finalize_without_devise!
result = finalize_without_devise!
@devise_finalized ||= begin
if Devise.router_name.nil? && defined?(@devise_finalized) && self != Rails.application.try(:routes)
warn "[DEVISE] We have detected that you are using devise_for inside engine routes. " \
"In this case, you probably want to set Devise.router_name = MOUNT_POINT, where " \
"MOUNT_POINT is a symbol representing where this engine will be mounted at. For " \
"now Devise will default the mount point to :main_app. You can explicitly set it" \
" to :main_app as well in case you want to keep the current behavior."
end
Devise.configure_warden!
Devise.regenerate_helpers!
true
end
result
end
alias_method_chain :finalize!, :devise
end
@@ -30,20 +43,20 @@ module ActionDispatch::Routing
# needed routes:
#
# # Session routes for Authenticatable (default)
# new_user_session GET /users/sign_in {:controller=>"devise/sessions", :action=>"new"}
# user_session POST /users/sign_in {:controller=>"devise/sessions", :action=>"create"}
# destroy_user_session GET /users/sign_out {:controller=>"devise/sessions", :action=>"destroy"}
# new_user_session GET /users/sign_in {:controller=>"devise/sessions", :action=>"new"}
# user_session POST /users/sign_in {:controller=>"devise/sessions", :action=>"create"}
# destroy_user_session DELETE /users/sign_out {:controller=>"devise/sessions", :action=>"destroy"}
#
# # Password routes for Recoverable, if User model has :recoverable configured
# new_user_password GET /users/password/new(.:format) {:controller=>"devise/passwords", :action=>"new"}
# edit_user_password GET /users/password/edit(.:format) {:controller=>"devise/passwords", :action=>"edit"}
# user_password PUT /users/password(.:format) {:controller=>"devise/passwords", :action=>"update"}
# POST /users/password(.:format) {:controller=>"devise/passwords", :action=>"create"}
# new_user_password GET /users/password/new(.:format) {:controller=>"devise/passwords", :action=>"new"}
# edit_user_password GET /users/password/edit(.:format) {:controller=>"devise/passwords", :action=>"edit"}
# user_password PUT /users/password(.:format) {:controller=>"devise/passwords", :action=>"update"}
# POST /users/password(.:format) {:controller=>"devise/passwords", :action=>"create"}
#
# # Confirmation routes for Confirmable, if User model has :confirmable configured
# new_user_confirmation GET /users/confirmation/new(.:format) {:controller=>"devise/confirmations", :action=>"new"}
# user_confirmation GET /users/confirmation(.:format) {:controller=>"devise/confirmations", :action=>"show"}
# POST /users/confirmation(.:format) {:controller=>"devise/confirmations", :action=>"create"}
# new_user_confirmation GET /users/confirmation/new(.:format) {:controller=>"devise/confirmations", :action=>"new"}
# user_confirmation GET /users/confirmation(.:format) {:controller=>"devise/confirmations", :action=>"show"}
# POST /users/confirmation(.:format) {:controller=>"devise/confirmations", :action=>"create"}
#
# ==== Options
#
@@ -84,15 +97,16 @@ module ActionDispatch::Routing
#
# You need to make sure that your sign_out controls trigger a request with a matching HTTP method.
#
# * :module => the namespace to find controlers. By default, devise will access devise/sessions,
# devise/registrations and so on. If you want to namespace all at once, use module:
# * :module => the namespace to find controllers (default: "devise", thus
# accessing devise/sessions, devise/registrations, and so on). If you want
# to namespace all at once, use module:
#
# devise_for :users, :module => "users"
#
# Notice that whenever you use namespace in the router DSL, it automatically sets the module.
# So the following setup:
#
# namespace :publisher
# namespace :publisher do
# devise_for :account
# end
#
@@ -123,7 +137,7 @@ module ActionDispatch::Routing
#
# devise_for :users, :format => false
#
# * :constraints => works the same as Rails' contraints
# * :constraints => works the same as Rails' constraints
#
# * :defaults => works the same as Rails' defaults
#
@@ -135,15 +149,15 @@ module ActionDispatch::Routing
# devise_for :users
# end
#
# However, since Devise uses the request path to retrieve the current user, it has one caveats.
# If you are using a dynamic segment, as below:
# However, since Devise uses the request path to retrieve the current user,
# this has one caveat: If you are using a dynamic segment, like so ...
#
# scope ":locale" do
# devise_for :users
# end
#
# You are required to configure default_url_options in your ApplicationController class level, so
# Devise can pick it:
# you are required to configure default_url_options in your
# ApplicationController class, so Devise can pick it:
#
# class ApplicationController < ActionController::Base
# def self.default_url_options
@@ -169,9 +183,9 @@ module ActionDispatch::Routing
# end
# end
#
# In order to get Devise to recognize the deactivate action, your devise_for entry should look like this,
# In order to get Devise to recognize the deactivate action, your devise_scope entry should look like this:
#
# devise_for :owners, :controllers => { :registrations => "registrations" } do
# devise_scope :owner do
# post "deactivate", :to => "registrations#deactivate", :as => "deactivate_registration"
# end
#
@@ -185,7 +199,8 @@ module ActionDispatch::Routing
options[:path_names] = (@scope[:path_names] || {}).merge(options[:path_names] || {})
options[:constraints] = (@scope[:constraints] || {}).merge(options[:constraints] || {})
options[:defaults] = (@scope[:defaults] || {}).merge(options[:defaults] || {})
@scope[:options] = (@scope[:options] || {}).merge({:format => false}) if options[:format] == false
options[:options] = @scope[:options] || {}
options[:options][:format] = false if options[:format] == false
resources.map!(&:to_sym)
@@ -207,15 +222,24 @@ module ActionDispatch::Routing
routes = mapping.used_routes
devise_scope mapping.name do
yield if block_given?
with_devise_exclusive_scope mapping.fullpath, mapping.name, mapping.constraints, mapping.defaults do
if block_given?
ActiveSupport::Deprecation.warn "Passing a block to devise_for is deprecated. " \
"Please remove the block from devise_for (only the block, the call to " \
"devise_for must still exist) and call devise_scope :#{mapping.name} do ... end " \
"with the block instead", caller
yield
end
with_devise_exclusive_scope mapping.fullpath, mapping.name, options do
routes.each { |mod| send("devise_#{mod}", mapping, mapping.controllers) }
end
end
end
end
# Allow you to add authentication request from the router:
# Allow you to add authentication request from the router.
# Takes an optional scope and block to provide constraints
# on the model instance itself.
#
# authenticate do
# resources :post
@@ -225,35 +249,36 @@ module ActionDispatch::Routing
# resources :users
# end
#
def authenticate(scope=nil)
constraint = lambda do |request|
request.env["warden"].authenticate!(:scope => scope)
end
constraints(constraint) do
# authenticate :user, lambda {|u| u.role == "admin"} do
# root :to => "admin/dashboard#show", :as => :user_root
# end
#
def authenticate(scope=nil, block=nil)
constraints_for(:authenticate!, scope, block) do
yield
end
end
# Allow you to route based on whether a scope is authenticated. You
# can optionally specify which scope.
# can optionally specify which scope and a block. The block accepts
# a model and allows extra constraints to be done on the instance.
#
# authenticated :admin do
# root :to => 'admin/dashboard#show'
# root :to => 'admin/dashboard#show', :as => :admin_root
# end
#
# authenticated do
# root :to => 'dashboard#show'
# root :to => 'dashboard#show', :as => :authenticated_root
# end
#
# authenticated :user, lambda {|u| u.role == "admin"} do
# root :to => "admin/dashboard#show", :as => :user_root
# end
#
# root :to => 'landing#show'
#
def authenticated(scope=nil)
constraint = lambda do |request|
request.env["warden"].authenticate? :scope => scope
end
constraints(constraint) do
def authenticated(scope=nil, block=nil)
constraints_for(:authenticate?, scope, block) do
yield
end
end
@@ -296,7 +321,7 @@ module ActionDispatch::Routing
# good and working example.
#
# devise_scope :user do
# match "/some/route" => "some_devise_controller"
# get "/some/route" => "some_devise_controller"
# end
# devise_for :users
#
@@ -346,34 +371,75 @@ module ActionDispatch::Routing
:cancel => mapping.path_names[:cancel]
}
resource :registration, :only => [:new, :create, :edit, :update, :destroy], :path => mapping.path_names[:registration],
:path_names => path_names, :controller => controllers[:registrations] do
options = {
:only => [:new, :create, :edit, :update, :destroy],
:path => mapping.path_names[:registration],
:path_names => path_names,
:controller => controllers[:registrations]
}
resource :registration, options do
get :cancel
end
end
def devise_omniauth_callback(mapping, controllers) #:nodoc:
path, @scope[:path] = @scope[:path], nil
path_prefix = "/#{mapping.path}/auth".squeeze("/")
path_prefix = Devise.omniauth_path_prefix || "/#{mapping.path}/auth".squeeze("/")
set_omniauth_path_prefix!(path_prefix)
if ::OmniAuth.config.path_prefix && ::OmniAuth.config.path_prefix != path_prefix
raise "You can only add :omniauthable behavior to one Devise model"
else
::OmniAuth.config.path_prefix = path_prefix
end
providers = Regexp.union(mapping.to.omniauth_providers.map(&:to_s))
match "#{path_prefix}/:action/callback", :constraints => { :action => Regexp.union(mapping.to.omniauth_providers.map(&:to_s)) },
:to => controllers[:omniauth_callbacks], :as => :omniauth_callback
match "#{path_prefix}/:provider",
:constraints => { :provider => providers },
:to => "#{controllers[:omniauth_callbacks]}#passthru",
:as => :omniauth_authorize,
:via => [:get, :post]
match "#{path_prefix}/:action/callback",
:constraints => { :action => providers },
:to => controllers[:omniauth_callbacks],
:as => :omniauth_callback,
:via => [:get, :post]
ensure
@scope[:path] = path
end
def with_devise_exclusive_scope(new_path, new_as, new_constraints, new_defaults) #:nodoc:
old_as, old_path, old_module, old_constraints, old_defaults = @scope[:as], @scope[:path], @scope[:module], @scope[:constraints], @scope[:defaults]
@scope[:as], @scope[:path], @scope[:module], @scope[:constraints], @scope[:defaults] = new_as, new_path, nil, new_constraints, new_defaults
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] }
new = { :as => new_as, :path => new_path, :module => nil }
new.merge!(options.slice(:constraints, :defaults, :options))
@scope.merge!(new)
yield
ensure
@scope[:as], @scope[:path], @scope[:module], @scope[:constraints], @scope[:defaults] = old_as, old_path, old_module, old_constraints, old_defaults
@scope.merge!(old)
end
def constraints_for(method_to_apply, scope=nil, block=nil)
constraint = lambda do |request|
request.env['warden'].send(method_to_apply, :scope => scope) &&
(block.nil? || block.call(request.env["warden"].user(scope)))
end
constraints(constraint) do
yield
end
end
def set_omniauth_path_prefix!(path_prefix) #:nodoc:
if ::OmniAuth.config.path_prefix && ::OmniAuth.config.path_prefix != path_prefix
raise "Wrong OmniAuth configuration. If you are getting this exception, it means that either:\n\n" \
"1) You are manually setting OmniAuth.config.path_prefix and it doesn't match the Devise one\n" \
"2) You are setting :omniauthable in more than one model\n" \
"3) You changed your Devise routes/OmniAuth setting and haven't restarted your server"
else
::OmniAuth.config.path_prefix = path_prefix
end
end
def raise_no_devise_method_error!(klass) #:nodoc:

View File

@@ -3,118 +3,19 @@ module Warden::Mixins::Common
@request ||= ActionDispatch::Request.new(env)
end
# This is called internally by Warden on logout
NULL_STORE =
defined?(ActionController::RequestForgeryProtection::ProtectionMethods::NullSession::NullSessionHash) ?
ActionController::RequestForgeryProtection::ProtectionMethods::NullSession::NullSessionHash : nil
def reset_session!
request.reset_session
# Calling reset_session on NULL_STORE causes it fail.
# This is a bug that needs to be fixed in Rails.
unless NULL_STORE && request.session.is_a?(NULL_STORE)
request.reset_session
end
end
def cookies
request.cookie_jar
end
end
class Warden::SessionSerializer
def serialize(record)
klass = record.class
array = klass.serialize_into_session(record)
array.unshift(klass.name)
end
def deserialize(keys)
klass, *args = keys
begin
ActiveSupport::Inflector.constantize(klass).serialize_from_session(*args)
rescue NameError => e
if e.message =~ /uninitialized constant/
Rails.logger.debug "[Devise] Trying to deserialize invalid class #{klass}"
nil
else
raise
end
end
end
end
unless Devise.rack_session?
# We cannot use Rails Indifferent Hash because it messes up the flash object.
class Devise::IndifferentHash < Hash
alias_method :regular_writer, :[]= unless method_defined?(:regular_writer)
alias_method :regular_update, :update unless method_defined?(:regular_update)
def [](key)
super(convert_key(key))
end
def []=(key, value)
regular_writer(convert_key(key), value)
end
alias_method :store, :[]=
def update(other_hash)
other_hash.each_pair { |key, value| regular_writer(convert_key(key), value) }
self
end
alias_method :merge!, :update
def key?(key)
super(convert_key(key))
end
alias_method :include?, :key?
alias_method :has_key?, :key?
alias_method :member?, :key?
def fetch(key, *extras)
super(convert_key(key), *extras)
end
def values_at(*indices)
indices.collect {|key| self[convert_key(key)]}
end
def merge(hash)
self.dup.update(hash)
end
def delete(key)
super(convert_key(key))
end
def stringify_keys!; self end
def stringify_keys; dup end
undef :symbolize_keys!
def symbolize_keys; to_hash.symbolize_keys end
def to_options!; self end
def to_hash; Hash.new.update(self) end
protected
def convert_key(key)
key.kind_of?(Symbol) ? key.to_s : key
end
end
class ActionDispatch::Request
def reset_session
session.destroy if session && session.respond_to?(:destroy)
self.session = {}
@env['action_dispatch.request.flash_hash'] = nil
end
end
Warden::Manager.after_set_user :event => [:set_user, :authentication] do |record, warden, options|
if options[:scope] && warden.authenticated?(options[:scope])
request, flash = warden.request, warden.env['action_dispatch.request.flash_hash']
backup = request.session.to_hash
backup.delete("session_id")
request.reset_session
warden.env['action_dispatch.request.flash_hash'] = flash
request.session = Devise::IndifferentHash.new.update(backup)
end
end
end

View File

@@ -1,104 +0,0 @@
module Devise
# Holds devise schema information. To use it, just include its methods
# and overwrite the apply_schema method.
module Schema
# Creates encrypted_password, and email when it is used as an authentication
# key (default).
#
# == Options
# * :null - When true, allow columns to be null.
# * :default - Set to "" when :null is false, unless overridden.
#
# == Notes
# For Datamapper compatibility, we explicitly hardcode the limit for the
# encrypter password field in 128 characters.
def database_authenticatable(options={})
null = options[:null] || false
default = options.key?(:default) ? options[:default] : ("" if null == false)
include_email = !respond_to?(:authentication_keys) || self.authentication_keys.include?(:email)
apply_devise_schema :email, String, :null => null, :default => default if include_email
apply_devise_schema :encrypted_password, String, :null => null, :default => default, :limit => 128
end
# Creates password salt for encryption support when using encryptors other
# than the database_authenticable default of bcrypt.
def encryptable
apply_devise_schema :password_salt, String
end
# Creates authentication_token.
def token_authenticatable
apply_devise_schema :authentication_token, String
end
# Creates confirmation_token, confirmed_at and confirmation_sent_at.
def confirmable
apply_devise_schema :confirmation_token, String
apply_devise_schema :confirmed_at, DateTime
apply_devise_schema :confirmation_sent_at, DateTime
end
# Creates reset_password_token and reset_password_sent_at.
#
# == Options
# * :reset_within - When true, adds a column that reset passwords within some date
def recoverable(options={})
use_within = options.fetch(:reset_within, Devise.reset_password_within.present?)
apply_devise_schema :reset_password_token, String
apply_devise_schema :reset_password_sent_at, DateTime if use_within
end
# Creates remember_token and remember_created_at.
#
# == Options
# * :use_salt - When true, does not create a remember_token and use password_salt instead.
def rememberable(options={})
use_salt = options.fetch(:use_salt, Devise.use_salt_as_remember_token)
apply_devise_schema :remember_token, String unless use_salt
apply_devise_schema :remember_created_at, DateTime
end
# Creates sign_in_count, current_sign_in_at, last_sign_in_at,
# current_sign_in_ip, last_sign_in_ip.
def trackable
apply_devise_schema :sign_in_count, Integer, :default => 0
apply_devise_schema :current_sign_in_at, DateTime
apply_devise_schema :last_sign_in_at, DateTime
apply_devise_schema :current_sign_in_ip, String
apply_devise_schema :last_sign_in_ip, String
end
# Creates failed_attempts, unlock_token and locked_at depending on the options given.
#
# == Options
# * :unlock_strategy - The strategy used for unlock. Can be :time, :email, :both (default), :none.
# If :email or :both, creates a unlock_token field.
# * :lock_strategy - The strategy used for locking. Can be :failed_attempts (default) or :none.
def lockable(options={})
unlock_strategy = options[:unlock_strategy]
unlock_strategy ||= self.unlock_strategy if respond_to?(:unlock_strategy)
unlock_strategy ||= :both
lock_strategy = options[:lock_strategy]
lock_strategy ||= self.lock_strategy if respond_to?(:lock_strategy)
lock_strategy ||= :failed_attempts
if lock_strategy == :failed_attempts
apply_devise_schema :failed_attempts, Integer, :default => 0
end
if [:both, :email].include?(unlock_strategy)
apply_devise_schema :unlock_token, String
end
apply_devise_schema :locked_at, DateTime
end
# Overwrite with specific modification to create your own schema.
def apply_devise_schema(name, type, options={})
raise NotImplementedError
end
end
end

View File

@@ -6,7 +6,11 @@ module Devise
# parameters both from params or from http authorization headers. See database_authenticatable
# for an example.
class Authenticatable < Base
attr_accessor :authentication_hash, :password
attr_accessor :authentication_hash, :authentication_type, :password
def store?
super && !mapping.to.skip_session_storage.include?(authentication_type)
end
def valid?
valid_for_params_auth? || valid_for_http_auth?
@@ -14,19 +18,36 @@ module Devise
private
# Simply invokes valid_for_authentication? with the given block and deal with the result.
# 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?
# for more information.
#
# In case the resource can't be validated, it will fail with the given
# unauthenticated_message.
def validate(resource, &block)
unless resource
ActiveSupport::Deprecation.warn "an empty resource was given to #{self.class.name}#validate. " \
"Please ensure the resource is not nil", caller
end
result = resource && resource.valid_for_authentication?(&block)
case result
when String, Symbol
when Symbol, String
ActiveSupport::Deprecation.warn "valid_for_authentication? should return a boolean value"
fail!(result)
false
when TrueClass
return false
end
if result
decorate(resource)
true
else
result
if resource
fail!(resource.unauthenticated_message)
end
false
end
end
@@ -47,7 +68,7 @@ module Devise
# * If all authentication keys are present;
#
def valid_for_http_auth?
http_authenticatable? && request.authorization && with_authentication_hash(http_auth_hash)
http_authenticatable? && request.authorization && with_authentication_hash(:http_auth, http_auth_hash)
end
# Check if this is strategy is valid for params authentication by:
@@ -58,8 +79,8 @@ module Devise
# * If all authentication keys are present;
#
def valid_for_params_auth?
params_authenticatable? && valid_request? &&
valid_params? && with_authentication_hash(params_auth_hash)
params_authenticatable? && valid_params_request? &&
valid_params? && with_authentication_hash(:params_auth, params_auth_hash)
end
# Check if the model accepts this strategy as http authenticatable.
@@ -74,17 +95,17 @@ module Devise
# Extract the appropriate subhash for authentication from params.
def params_auth_hash
params[scope]
end
params[scope]
end
# Extract a hash with attributes:values from the http params.
def http_auth_hash
keys = [authentication_keys.first, :password]
keys = [http_authentication_key, :password]
Hash[*keys.zip(decode_credentials).flatten]
end
# By default, a request is valid if the controller is allowed and the VERB is POST.
def valid_request?
# By default, a request is valid if the controller set the proper env variable.
def valid_params_request?
!!env["devise.allow_params_authentication"]
end
@@ -101,36 +122,39 @@ module Devise
# Helper to decode credentials from HTTP.
def decode_credentials
return [] unless request.authorization && request.authorization =~ /^Basic (.*)/m
ActiveSupport::Base64.decode64($1).split(/:/, 2)
Base64.decode64($1).split(/:/, 2)
end
# Sets the authentication hash and the password from params_auth_hash or http_auth_hash.
def with_authentication_hash(auth_values)
self.authentication_hash = {}
def with_authentication_hash(auth_type, auth_values)
self.authentication_hash, self.authentication_type = {}, auth_type
self.password = auth_values[:password]
parse_authentication_key_values(auth_values, authentication_keys) &&
parse_authentication_key_values(request_values, request_keys)
end
# Holds the authentication keys.
def authentication_keys
@authentication_keys ||= mapping.to.authentication_keys
end
# Holds request keys.
def http_authentication_key
@http_authentication_key ||= mapping.to.http_authentication_key || case authentication_keys
when Array then authentication_keys.first
when Hash then authentication_keys.keys.first
end
end
def request_keys
@request_keys ||= mapping.to.request_keys
end
# Returns values from the request object.
def request_values
keys = request_keys.respond_to?(:keys) ? request_keys.keys : request_keys
values = keys.map { |k| self.request.send(k) }
Hash[keys.zip(values)]
end
# Parse authentication keys considering if they should be enforced or not.
def parse_authentication_key_values(hash, keys)
keys.each do |key, enforce|
value = hash[key].presence
@@ -152,4 +176,4 @@ module Devise
end
end
end
end
end

View File

@@ -2,6 +2,11 @@ module Devise
module Strategies
# Base strategy for Devise. Responsible for verifying correct scope and mapping.
class Base < ::Warden::Strategies::Base
# Whenever CSRF cannot be verified, we turn off any kind of storage
def store?
!env["devise.skip_storage"]
end
# Checks if a valid scope was given for devise and find mapping based on this scope.
def mapping
@mapping ||= begin

View File

@@ -5,14 +5,16 @@ module Devise
# Default strategy for signing in a user, based on his email and password in the database.
class DatabaseAuthenticatable < Authenticatable
def authenticate!
resource = valid_password? && mapping.to.find_for_database_authentication(authentication_hash)
resource = valid_password? && mapping.to.find_for_database_authentication(authentication_hash)
encrypted = false
if validate(resource){ resource.valid_password?(password) }
if validate(resource){ encrypted = true; resource.valid_password?(password) }
resource.after_database_authentication
success!(resource)
elsif !halted?
fail(:invalid)
end
mapping.to.new.password = password if !encrypted && Devise.paranoid
fail(:not_found_in_database) unless resource
end
end
end

View File

@@ -1,4 +1,4 @@
require 'devise/strategies/base'
require 'devise/strategies/authenticatable'
module Devise
module Strategies
@@ -19,11 +19,13 @@ module Devise
def authenticate!
resource = mapping.to.serialize_from_cookie(*remember_cookie)
unless resource
cookies.delete(remember_key)
return pass
end
if validate(resource)
success!(resource)
elsif !halted?
cookies.delete(remember_key)
pass
end
end
@@ -39,7 +41,7 @@ module Devise
end
def remember_key
"remember_#{scope}_token"
mapping.to.rememberable_options.fetch(:key, "remember_#{scope}_token")
end
def remember_cookie
@@ -50,4 +52,4 @@ module Devise
end
end
Warden::Strategies.add(:rememberable, Devise::Strategies::Rememberable)
Warden::Strategies.add(:rememberable, Devise::Strategies::Rememberable)

View File

@@ -7,28 +7,36 @@ module Devise
#
# http://myapp.example.com/?user_token=SECRET
#
# For HTTP, you can pass the token as username and blank password. Since some clients may require
# a password, you can pass "X" as password and it will simply be ignored.
# For headers, you can use basic authentication passing the token as username and
# blank password. Since some clients may require a password, you can pass "X" as
# password and it will simply be ignored.
#
# You may also pass the token using the Token authentication mechanism provided
# by Rails: http://api.rubyonrails.org/classes/ActionController/HttpAuthentication/Token.html
# The token options are stored in request.env['devise.token_options']
class TokenAuthenticatable < Authenticatable
def store?
!mapping.to.stateless_token
super && !mapping.to.skip_session_storage.include?(:token_auth)
end
def valid?
super || valid_for_token_auth?
end
def authenticate!
resource = mapping.to.find_for_token_authentication(authentication_hash)
return fail(:invalid_token) unless resource
if validate(resource)
resource.after_token_authentication
success!(resource)
elsif !halted?
fail(:invalid_token)
end
end
private
# TokenAuthenticatable request is valid for any controller and any verb.
def valid_request?
# Token Authenticatable can be authenticated with params in any controller and any verb.
def valid_params_request?
true
end
@@ -37,7 +45,33 @@ module Devise
false
end
# Try both scoped and non scoped keys.
# Check if the model accepts this strategy as token authenticatable.
def token_authenticatable?
mapping.to.http_authenticatable?(:token_options)
end
# Check if this is strategy is valid for token authentication by:
#
# * Validating if the model allows http token authentication;
# * If the http auth token exists;
# * If all authentication keys are present;
#
def valid_for_token_auth?
token_authenticatable? && auth_token.present? && with_authentication_hash(:token_auth, token_auth_hash)
end
# Extract the auth token from the request
def auth_token
@auth_token ||= ActionController::HttpAuthentication::Token.token_and_options(request)
end
# Extract a hash with attributes:values from the auth_token
def token_auth_hash
request.env['devise.token_options'] = auth_token.last
{ authentication_keys.first => auth_token.first }
end
# Try both scoped and non scoped keys
def params_auth_hash
if params[scope].kind_of?(Hash) && params[scope].has_key?(authentication_keys.first)
params[scope]

View File

@@ -15,9 +15,8 @@ module Devise
# Override process to consider warden.
def process(*)
result = nil
_catch_warden { result = super }
result
# Make sure we always return @response, a la ActionController::TestCase::Behaviour#process, even if warden interrupts
_catch_warden { super } || @response
end
# We need to setup the environment variables and the response in the controller.
@@ -46,6 +45,7 @@ module Devise
def sign_in(resource_or_scope, resource=nil)
scope ||= Devise::Mapping.find_scope!(resource_or_scope)
resource ||= resource_or_scope
warden.instance_variable_get(:@users).delete(scope)
warden.session_serializer.store(resource, scope)
end
@@ -66,25 +66,66 @@ module Devise
protected
# Catch warden continuations and handle like the middleware would.
# Returns nil when interrupted, otherwise the normal result of the block.
def _catch_warden(&block)
result = catch(:warden, &block)
if result.is_a?(Hash) && !warden.custom_failure? && !@controller.send(:performed?)
result[:action] ||= :unauthenticated
env = @controller.request.env
env = @controller.request.env
env["PATH_INFO"] = "/#{result[:action]}"
env["warden.options"] = result
Warden::Manager._run_callbacks(:before_failure, env, result)
result ||= {}
status, headers, body = Devise.warden_config[:failure_app].call(env).to_a
@controller.send :render, :status => status, :text => body,
:content_type => headers["Content-Type"], :location => headers["Location"]
nil
# Set the response. In production, the rack result is returned
# from Warden::Manager#call, which the following is modelled on.
case result
when Array
if result.first == 401 && intercept_401?(env) # does this happen during testing?
_process_unauthenticated(env)
else
result
end
when Hash
_process_unauthenticated(env, result)
else
result
end
end
def _process_unauthenticated(env, options = {})
options[:action] ||= :unauthenticated
proxy = env['warden']
result = options[:result] || proxy.result
ret = case result
when :redirect
body = proxy.message || "You are being redirected to #{proxy.headers['Location']}"
[proxy.status, proxy.headers, [body]]
when :custom
proxy.custom_response
else
env["PATH_INFO"] = "/#{options[:action]}"
env["warden.options"] = options
Warden::Manager._run_callbacks(:before_failure, env, options)
status, headers, response = Devise.warden_config[:failure_app].call(env).to_a
@controller.send :render, :status => status, :text => response.body,
:content_type => headers["Content-Type"], :location => headers["Location"]
nil # causes process return @response
end
# ensure that the controller response is set up. In production, this is
# not necessary since warden returns the results to rack. However, at
# testing time, we want the response to be available to the testing
# framework to verify what would be returned to rack.
if ret.is_a?(Array)
# ensure the controller response is set to our response.
@controller.response ||= @response
@response.status = ret.first
@response.headers = ret.second
@response.body = ret.third
end
ret
end
end
end

View File

@@ -0,0 +1,14 @@
require "active_support/core_ext/module/delegation"
module Devise
class TimeInflector
include ActionView::Helpers::DateHelper
class << self
attr_reader :instance
delegate :time_ago_in_words, :to => :instance
end
@instance = new
end
end

View File

@@ -1,3 +1,3 @@
module Devise
VERSION = "1.5.2".freeze
VERSION = "2.2.8".freeze
end

View File

@@ -1,7 +1,6 @@
require 'rails/generators/active_record'
require 'generators/devise/orm_helpers'
module ActiveRecord
module Generators
class DeviseGenerator < ActiveRecord::Generators::Base
@@ -21,12 +20,59 @@ module ActiveRecord
def generate_model
invoke "active_record:model", [name], :migration => false unless model_exists? && behavior == :invoke
end
def inject_devise_content
inject_into_class(model_path, class_name, model_contents + <<CONTENT) if model_exists?
content = model_contents + <<CONTENT
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me
CONTENT
class_path = if namespaced?
class_name.to_s.split("::")
else
[class_name]
end
indent_depth = class_path.size - 1
content = content.split("\n").map { |line| " " * indent_depth + line } .join("\n") << "\n"
inject_into_class(model_path, class_path.last, content) if model_exists?
end
def migration_data
<<RUBY
## Database authenticatable
t.string :email, :null => false, :default => ""
t.string :encrypted_password, :null => false, :default => ""
## Recoverable
t.string :reset_password_token
t.datetime :reset_password_sent_at
## Rememberable
t.datetime :remember_created_at
## Trackable
t.integer :sign_in_count, :default => 0
t.datetime :current_sign_in_at
t.datetime :last_sign_in_at
t.string :current_sign_in_ip
t.string :last_sign_in_ip
## Confirmable
# t.string :confirmation_token
# t.datetime :confirmed_at
# t.datetime :confirmation_sent_at
# t.string :unconfirmed_email # Only if using reconfirmable
## Lockable
# t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts
# t.string :unlock_token # Only if unlock strategy is :email or :both
# t.datetime :locked_at
## Token authenticatable
# t.string :authentication_token
RUBY
end
end
end

View File

@@ -1,19 +1,7 @@
class DeviseCreate<%= table_name.camelize %> < ActiveRecord::Migration
<% if ::Rails::VERSION::MAJOR == 3 && ::Rails::VERSION::MINOR >= 1 -%>
def change
<% else -%>
def self.up
<% end -%>
create_table(:<%= table_name %>) do |t|
t.database_authenticatable :null => false
t.recoverable
t.rememberable
t.trackable
# t.encryptable
# t.confirmable
# t.lockable :lock_strategy => :<%= Devise.lock_strategy %>, :unlock_strategy => :<%= Devise.unlock_strategy %>
# t.token_authenticatable
<%= migration_data -%>
<% attributes.each do |attribute| -%>
t.<%= attribute.type %> :<%= attribute.name %>
@@ -28,10 +16,4 @@ class DeviseCreate<%= table_name.camelize %> < ActiveRecord::Migration
# add_index :<%= table_name %>, :unlock_token, :unique => true
# add_index :<%= table_name %>, :authentication_token, :unique => true
end
<% unless ::Rails::VERSION::MAJOR == 3 && ::Rails::VERSION::MINOR >= 1 -%>
def self.down
drop_table :<%= table_name %>
end
<% end -%>
end

View File

@@ -1,15 +1,7 @@
class AddDeviseTo<%= table_name.camelize %> < ActiveRecord::Migration
def self.up
change_table(:<%= table_name %>) do |t|
t.database_authenticatable :null => false
t.recoverable
t.rememberable
t.trackable
# t.encryptable
# t.confirmable
# t.lockable :lock_strategy => :<%= Devise.lock_strategy %>, :unlock_strategy => :<%= Devise.unlock_strategy %>
# t.token_authenticatable
<%= migration_data -%>
<% attributes.each do |attribute| -%>
t.<%= attribute.type %> :<%= attribute.name %>

View File

@@ -1,6 +1,8 @@
module Devise
module Generators
class DeviseGenerator < Rails::Generators::NamedBase
include Rails::Generators::ResourceHelpers
namespace "devise"
source_root File.expand_path("../templates", __FILE__)

View File

@@ -4,7 +4,8 @@ module Devise
def model_contents
<<-CONTENT
# Include default devise modules. Others available are:
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable

View File

@@ -10,9 +10,21 @@ module Devise
argument :scope, :required => false, :default => nil,
:desc => "The scope to copy views to"
# Le sigh, ensure Thor won't handle opts as args
# It should be fixed in future Rails releases
class_option :form_builder, :aliases => "-b"
class_option :markerb
public_task :copy_views
end
# TODO: Add this to Rails itself
module ClassMethods
def hide!
Rails::Generators.hide_namespace self.namespace
end
end
def copy_views
view_directory :confirmations
view_directory :passwords
@@ -24,7 +36,13 @@ module Devise
protected
def view_directory(name, _target_path = nil)
directory name.to_s, _target_path || "#{target_path}/#{name}"
directory name.to_s, _target_path || "#{target_path}/#{name}" do |content|
if scope
content.gsub "devise/shared/links", "#{scope}/shared/links"
else
content
end
end
end
def target_path
@@ -36,6 +54,7 @@ module Devise
include ViewPathTemplates
source_root File.expand_path("../../../../app/views/devise", __FILE__)
desc "Copies shared Devise views to your application."
hide!
# Override copy_views to just copy mailer and shared.
def copy_views
@@ -47,18 +66,21 @@ module Devise
include ViewPathTemplates
source_root File.expand_path("../../../../app/views/devise", __FILE__)
desc "Copies default Devise views to your application."
hide!
end
class SimpleFormForGenerator < Rails::Generators::Base #:nodoc:
include ViewPathTemplates
source_root File.expand_path("../../templates/simple_form_for", __FILE__)
desc "Copies simple form enabled views to your application."
hide!
end
class ErbGenerator < Rails::Generators::Base #:nodoc:
include ViewPathTemplates
source_root File.expand_path("../../../../app/views/devise", __FILE__)
desc "Copies Devise mail erb views to your application."
hide!
def copy_views
view_directory :mailer
@@ -69,6 +91,7 @@ module Devise
include ViewPathTemplates
source_root File.expand_path("../../templates", __FILE__)
desc "Copies Devise mail markerb views to your application."
hide!
def copy_views
view_directory :markerb, target_path
@@ -86,6 +109,7 @@ module Devise
:desc => "The scope to copy views to"
invoke SharedViewsGenerator
hook_for :form_builder, :aliases => "-b",
:desc => "Form builder to be used",
:default => defined?(SimpleForm) ? "simple_form_for" : "form_for"

View File

@@ -9,9 +9,49 @@ module Mongoid
invoke "mongoid:model", [name] unless model_exists? && behavior == :invoke
end
def inject_field_types
inject_into_file model_path, migration_data, :after => "include Mongoid::Document\n" if model_exists?
end
def inject_devise_content
inject_into_file model_path, model_contents, :after => "include Mongoid::Document\n" if model_exists?
end
def migration_data
<<RUBY
## Database authenticatable
field :email, :type => String, :default => ""
field :encrypted_password, :type => String, :default => ""
## Recoverable
field :reset_password_token, :type => String
field :reset_password_sent_at, :type => Time
## Rememberable
field :remember_created_at, :type => Time
## Trackable
field :sign_in_count, :type => Integer, :default => 0
field :current_sign_in_at, :type => Time
field :last_sign_in_at, :type => Time
field :current_sign_in_ip, :type => String
field :last_sign_in_ip, :type => String
## Confirmable
# field :confirmation_token, :type => String
# field :confirmed_at, :type => Time
# field :confirmation_sent_at, :type => Time
# field :unconfirmed_email, :type => String # Only if using reconfirmable
## Lockable
# field :failed_attempts, :type => Integer, :default => 0 # Only if lock strategy is :failed_attempts
# field :unlock_token, :type => String # Only if unlock strategy is :email or :both
# field :locked_at, :type => Time
## Token authenticatable
# field :authentication_token, :type => String
RUBY
end
end
end
end

View File

@@ -1,15 +1,14 @@
===============================================================================
Some setup you must do manually if you haven't yet:
1. Setup default url options for your specific environment. Here is an
example of development environment:
1. Ensure you have defined default url options in your environments files. Here
is an example of default_url_options appropriate for a development environment
in config/environments/development.rb:
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
This is a required Rails configuration. In production it must be the
actual host of your application
In production, :host should be set to the actual host of your application.
2. Ensure you have defined root_url to *something* in your config/routes.rb.
For example:
@@ -22,11 +21,15 @@ Some setup you must do manually if you haven't yet:
<p class="notice"><%= notice %></p>
<p class="alert"><%= alert %></p>
4. If you are deploying Rails 3.1 on Heroku, you may want to set:
4. If you are deploying Rails 3.1+ on Heroku, you may want to set:
config.assets.initialize_on_precompile = false
On config/application.rb forcing your application to not access the DB
or load models when precompiling your assets.
5. You can copy Devise views (for customization) to your app by running:
rails g devise:views
===============================================================================

View File

@@ -43,9 +43,19 @@ Devise.setup do |config|
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
# given strategies, for example, `config.params_authenticatable = [:database]` will
# enable it only for database (email + password) authentication.
# config.params_authenticatable = true
# Tell if authentication through HTTP Basic Auth is enabled. False by default.
# Tell if authentication through HTTP Auth is enabled. False by default.
# It can be set to an array that will enable http authentication only for the
# given strategies, for example, `config.http_authenticatable = [:token]` will
# enable it only for token authentication. The supported strategies are:
# :database = Support basic authentication with authentication key + password
# :token = Support basic authentication with token authentication key
# :token_options = Support token authentication with options as defined in
# http://api.rubyonrails.org/classes/ActionController/HttpAuthentication/Token.html
# config.http_authenticatable = false
# If http headers should be returned for AJAX requests. True by default.
@@ -59,6 +69,19 @@ Devise.setup do |config|
# Does not affect registerable.
# config.paranoid = true
# By default Devise will store the user in session. You can skip storage for
# :http_auth and :token_auth by adding those symbols to the array below.
# Notice that if you are skipping storage for all authentication paths, you
# may want to disable generating routes to Devise's sessions controller by
# passing :skip => :sessions to `devise_for` in your config/routes.rb
config.skip_session_storage = [:http_auth]
# By default, Devise cleans up the CSRF token on authentication to
# avoid CSRF token fixation attacks. This means that, when using AJAX
# requests for sign in and sign up, you need to get a new CSRF token
# from the server. You can disable this option at your own risk.
# config.clean_up_csrf_token_on_authentication = true
# ==> Configuration for :database_authenticatable
# For bcrypt, this is the cost for hashing the password and defaults to 10. If
# using other encryptors, it sets how many times you want the password re-encrypted.
@@ -77,7 +100,21 @@ Devise.setup do |config|
# able to access the website for two days without confirming his account,
# access will be blocked just in the third day. Default is 0.days, meaning
# the user cannot access the website without confirming his account.
# config.confirm_within = 2.days
# config.allow_unconfirmed_access_for = 2.days
# A period that the user is allowed to confirm their account before their
# token becomes invalid. For example, if set to 3.days, the user can confirm
# their account within 3 days after the mail was sent, but on the fourth day
# their account can't be confirmed with the token any more.
# Default is nil, meaning there is no restriction on how long a user can take
# before confirming their account.
# config.confirm_within = 3.days
# If true, requires any email changes to be confirmed (exactly the same way as
# initial account confirmation) to be applied. Requires additional unconfirmed_email
# db field (see migrations). Until confirmed new email is stored in
# unconfirmed email column, and copied to email column on successful confirmation.
config.reconfirmable = true
# Defines which key will be used when confirming an account
# config.confirmation_keys = [ :email ]
@@ -86,26 +123,19 @@ Devise.setup do |config|
# The time the user will be remembered without asking for credentials again.
# config.remember_for = 2.weeks
# If true, a valid remember token can be re-used between multiple browsers.
# config.remember_across_browsers = true
# If true, extends the user's remember period when remembered via cookie.
# config.extend_remember_period = false
# If true, uses the password salt as remember token. This should be turned
# to false if you are not using database authenticatable.
config.use_salt_as_remember_token = true
# Options to be passed to the created cookie. For instance, you can set
# :secure => true in order to force SSL only cookies.
# config.cookie_options = {}
# config.rememberable_options = {}
# ==> Configuration for :validatable
# Range for password length. Default is 6..128.
# config.password_length = 6..128
# Range for password length. Default is 8..128.
config.password_length = 8..128
# Email regex used to validate email formats. It simply asserts that
# an one (and only one) @ exists in the given string. This is mainly
# one (and only one) @ exists in the given string. This is mainly
# to give user feedback and not to assert the e-mail validity.
# config.email_regexp = /\A[^@]+@[^@]+\z/
@@ -114,6 +144,9 @@ 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.
@@ -145,24 +178,22 @@ Devise.setup do |config|
# 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 = 2.hours
config.reset_password_within = 6.hours
# ==> Configuration for :encryptable
# Allow you to use another encryption algorithm besides bcrypt (default). You can use
# :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
# :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
# and :restful_authentication_sha1 (then you should set stretches to 10, and copy
# REST_AUTH_SITE_KEY to pepper)
# REST_AUTH_SITE_KEY to pepper).
#
# Require the `devise-encryptable` gem when using anything other than bcrypt
# config.encryptor = :sha512
# ==> Configuration for :token_authenticatable
# Defines name of the authentication token params key
# config.token_authentication_key = :auth_token
# If true, authentication through token does not store user in session and needs
# to be supplied on each request. Useful if you are using the token as API token.
# config.stateless_token = false
# ==> Scopes configuration
# Turn scoped views on. Before rendering "sessions/new", it will first check for
# "users/sessions/new". It's turned off by default because it's slower if you
@@ -173,9 +204,8 @@ Devise.setup do |config|
# devise role declared in your routes (usually :user).
# config.default_scope = :user
# Configure sign_out behavior.
# Sign_out action can be scoped (i.e. /users/sign_out affects only :user scope).
# The default is true, which means any logout action will sign out all active scopes.
# Set this configuration to false if you want /users/sign_out to sign out
# only the current scope. By default, Devise signs out all scopes.
# config.sign_out_all_scopes = true
# ==> Navigation configuration
@@ -186,9 +216,8 @@ Devise.setup do |config|
# If you have any extra navigational formats, like :iphone or :mobile, you
# should add them to the navigational formats lists.
#
# The :"*/*" and "*/*" formats below is required to match Internet
# Explorer requests.
# config.navigational_formats = [:"*/*", "*/*", :html]
# The "*/*" below is required to match Internet Explorer requests.
# config.navigational_formats = ["*/*", :html]
# The default HTTP method used to sign out a resource. Default is :delete.
config.sign_out_via = :delete
@@ -206,4 +235,18 @@ Devise.setup do |config|
# manager.intercept_401 = false
# manager.default_strategies(:scope => :user).unshift :some_external_strategy
# end
# ==> Mountable engine configurations
# When using Devise inside an engine, let's call it `MyEngine`, and this engine
# is mountable, there are some extra configurations to be taken into account.
# The following options are available, assuming the engine is mounted as:
#
# mount MyEngine, at: "/my_engine"
#
# 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,
# 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

@@ -1,4 +1,4 @@
Welcome <%= @resource.email %>!
Welcome <%= @email %>!
You can confirm your account through the link below:

View File

@@ -1,6 +1,6 @@
Hello <%= @resource.email %>!
Your account has been locked due to an excessive amount of unsuccessful sign in attempts.
Your account has been locked due to an excessive number of unsuccessful sign in attempts.
Click the link below to unlock your account:

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