mirror of
https://github.com/heartcombo/devise.git
synced 2026-01-10 08:08:00 -05:00
Compare commits
102 Commits
v4.0.0.rc1
...
4-1-stable
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b4b92d6658 | ||
|
|
da7c7a7200 | ||
|
|
1bc9ebd7de | ||
|
|
81869de9c5 | ||
|
|
f6301c08f6 | ||
|
|
d66d9297fb | ||
|
|
78bbf6dcc4 | ||
|
|
1ff64fbbd3 | ||
|
|
3226ab16c1 | ||
|
|
13285d7ef3 | ||
|
|
7346ce709a | ||
|
|
8ac32f14b1 | ||
|
|
91ef42dc0a | ||
|
|
1ddca80cee | ||
|
|
896521be73 | ||
|
|
6e419ce821 | ||
|
|
93df02f601 | ||
|
|
fdd9337b64 | ||
|
|
2040b021e1 | ||
|
|
d122faf410 | ||
|
|
eaa4713e22 | ||
|
|
0c1a14e8f2 | ||
|
|
357ce9c3b5 | ||
|
|
830d3e86ee | ||
|
|
209b97d86b | ||
|
|
4da955d9cd | ||
|
|
bff701758a | ||
|
|
90acc6fc23 | ||
|
|
48220f087b | ||
|
|
26b17abb01 | ||
|
|
22468f3756 | ||
|
|
9696d83e7d | ||
|
|
940ca4f2b8 | ||
|
|
f38250245f | ||
|
|
4c7c27f73e | ||
|
|
7a235849cf | ||
|
|
846ba80480 | ||
|
|
93d98b6450 | ||
|
|
7d10019d2a | ||
|
|
274f8f2f87 | ||
|
|
3360b10c2f | ||
|
|
6f9561e64f | ||
|
|
016b216d95 | ||
|
|
164134c78a | ||
|
|
4a4b5ba196 | ||
|
|
c87d8fda82 | ||
|
|
48af3e8249 | ||
|
|
57d150e535 | ||
|
|
d9f97fc9a4 | ||
|
|
9cdf7860d5 | ||
|
|
0f11c0f6b3 | ||
|
|
9914ff32ec | ||
|
|
728bf0c956 | ||
|
|
c520e93733 | ||
|
|
b397d33246 | ||
|
|
aa25e2080e | ||
|
|
2b3799e6ce | ||
|
|
2af3a83ef4 | ||
|
|
c3c2438c9c | ||
|
|
69bee06cee | ||
|
|
c70eb0a5a8 | ||
|
|
db901399f2 | ||
|
|
d0e5a1d252 | ||
|
|
ccda4692b4 | ||
|
|
e6563bc4cb | ||
|
|
1c2328bb90 | ||
|
|
9ec126bd8b | ||
|
|
b3cc3db49e | ||
|
|
5b1182460c | ||
|
|
76f76249e7 | ||
|
|
353b14f473 | ||
|
|
ec07bdb315 | ||
|
|
9ece7da447 | ||
|
|
b214333760 | ||
|
|
3423043759 | ||
|
|
8c636ef08a | ||
|
|
a9b94f5eb9 | ||
|
|
c228227bc1 | ||
|
|
0c46373c20 | ||
|
|
648ed3b412 | ||
|
|
cecb3ee45b | ||
|
|
4585281da4 | ||
|
|
014859ecff | ||
|
|
1f36946f43 | ||
|
|
9efc601c73 | ||
|
|
dc7e7d66c9 | ||
|
|
18528650c3 | ||
|
|
a371f03c51 | ||
|
|
f173040222 | ||
|
|
b74235d4a1 | ||
|
|
4b8ea5d0f0 | ||
|
|
79e861b52b | ||
|
|
c4b4411513 | ||
|
|
7b33a8ef57 | ||
|
|
1dd315ce1d | ||
|
|
7c75ebe672 | ||
|
|
d9481ff9b8 | ||
|
|
f0c39e08ca | ||
|
|
d3fa53151a | ||
|
|
f2d7b8f740 | ||
|
|
beb8cc8e0b | ||
|
|
17d6a74909 |
14
.travis.yml
14
.travis.yml
@@ -1,19 +1,19 @@
|
||||
language: ruby
|
||||
|
||||
rvm:
|
||||
- 2.1.5
|
||||
- 2.2.4
|
||||
- 2.3.0
|
||||
- 2.2.4
|
||||
- 2.1.8
|
||||
|
||||
gemfile:
|
||||
- Gemfile
|
||||
- gemfiles/Gemfile.rails-5.0-beta
|
||||
- gemfiles/Gemfile.rails-4.2-stable
|
||||
- gemfiles/Gemfile.rails-4.1-stable
|
||||
- gemfiles/Gemfile.rails-5.0-beta
|
||||
- Gemfile
|
||||
|
||||
matrix:
|
||||
exclude:
|
||||
- rvm: 2.1.5
|
||||
- rvm: 2.1.8
|
||||
gemfile: gemfiles/Gemfile.rails-5.0-beta
|
||||
- env: DEVISE_ORM=mongoid
|
||||
gemfile: gemfiles/Gemfile.rails-5.0-beta
|
||||
@@ -26,14 +26,14 @@ cache: bundler
|
||||
|
||||
env:
|
||||
matrix:
|
||||
- DEVISE_ORM=mongoid
|
||||
- DEVISE_ORM=active_record
|
||||
- DEVISE_ORM=mongoid
|
||||
|
||||
before_install: "rm ${BUNDLE_GEMFILE}.lock"
|
||||
|
||||
before_script: "bundle update"
|
||||
|
||||
script: "bundle exec rake test"
|
||||
script: "bin/test"
|
||||
|
||||
notifications:
|
||||
email: false
|
||||
|
||||
88
CHANGELOG.md
88
CHANGELOG.md
@@ -1,3 +1,91 @@
|
||||
### 4.1.1 - 2016-05-15
|
||||
|
||||
* bug fixes
|
||||
* Fix overwriting the remember_token when a valid one already exists (by @ralinchimev).
|
||||
|
||||
### 4.1.0
|
||||
|
||||
* bug fixes
|
||||
* Fix race condition of sending the confirmation instructions e-mail using background jobs.
|
||||
Using the previous `after_create` callback, the e-mail can be sent before
|
||||
the record be committed on database, generating a `ActiveRecord::NotFound` error.
|
||||
Now the confirmation e-mail will be only sent after the database commit,
|
||||
using the `after_commit` callback.
|
||||
It may break your test suite on Rails 4 if you are testing the sent e-mails
|
||||
or enqueued jobs using transactional fixtures enabled or `DatabaseCleaner` with `transaction` strategy.
|
||||
You can easily fix your test suite using the gem
|
||||
[test_after_commit](https://github.com/grosser/test_after_commit). For example, put in your Gemfile:
|
||||
|
||||
```ruby
|
||||
gem 'test_after_commit', :group => :test
|
||||
```
|
||||
|
||||
On Rails 5 `after_commit` callbacks are triggered even using transactional
|
||||
fixtures, then this fix will not break your test suite. If you are using `DatabaseCleaner` with the `deletion` or `truncation` strategies it may not break your tests. (by @allenwq)
|
||||
* Fix strategy checking in `Lockable#unlock_strategy_enabled?` for `:none` and
|
||||
`:undefined` strategies. (by @f3ndot)
|
||||
* features
|
||||
* Humanize authentication keys in failure flash message (by @byzg)
|
||||
When you are configuring the translations of `devise.failure.invalid`, the
|
||||
`authentication_keys` is translated now.
|
||||
* deprecations
|
||||
* Remove code supporting old session serialization format (by @fphilipe).
|
||||
* Now the `email_regexp` default uses a more permissive regex:
|
||||
`/\A[^@\s]+@[^@\s]+\z/` (by @kimgb)
|
||||
* Now the `strip_whitespace_keys` default is `[:email]` (by @ulissesalmeida)
|
||||
* Now the `reconfirmable` default is `true` (by @ulissesalmeida)
|
||||
* Now the `skip_session_storage` default is `[:http_auth]` (by @ulissesalmeida)
|
||||
* Now the `sign_out_via` default is `:delete` (by @ulissesalmeida)
|
||||
* improvements
|
||||
* Avoids extra computation of friendly token for confirmation token (by @sbc100)
|
||||
|
||||
### 4.0.2 - 2016-05-02
|
||||
|
||||
* bug fixes
|
||||
* Fix strategy checking in `Lockable#unlock_strategy_enabled?` for `:none`
|
||||
and `:undefined` strategies. (by @f3ndot)
|
||||
|
||||
### 4.0.1 - 2016-04-25
|
||||
|
||||
* bug fixes
|
||||
* Fix the e-mail confirmation instructions send when a user updates the email
|
||||
address from nil. (by @lmduc)
|
||||
* Remove unnecessary `attribute_will_change!` call. (by @cadejscroggins)
|
||||
* Consistent `permit!` check. (by @ulissesalmeida)
|
||||
|
||||
### 4.0.0 - 2016-04-18
|
||||
|
||||
* bug fixes
|
||||
* Fix the `extend_remember_period` configuration. When set to `false` it does
|
||||
not update the cookie expiration anymore.(by @ulissesalmeida)
|
||||
|
||||
* deprecations
|
||||
* Added a warning of default value change in Devise 4.1 for users that uses
|
||||
the the default configuration of the following configurations: (by @ulissesalmeida)
|
||||
* `strip_whitespace_keys` - The default will be `[:email]`.
|
||||
* `skip_session_storage` - The default will be `[:http_auth]`.
|
||||
* `sign_out_via` - The default will be `:delete`.
|
||||
* `reconfirmable` - The default will be `true`.
|
||||
* `email_regexp` - The default will be `/\A[^@\s]+@[^@\s]+\z/`.
|
||||
* Removed deprecated argument of `Devise::Models::Rememberable#remember_me!` (by @ulissesalmeida)
|
||||
* Removed deprecated private method Devise::Controllers::Helpers#expire_session_data_after_sign_in!
|
||||
(by @bogdanvlviv)
|
||||
|
||||
### 4.0.0.rc2 - 2016-03-09
|
||||
|
||||
* enhancements
|
||||
* Introduced `DeviseController#set_flash_message!` for conditional flash
|
||||
messages setting to reduce complexity.
|
||||
* `rails g devise:install` will fail if the app does not have a ORM configured
|
||||
(by @arjunsharma)
|
||||
* Support to Rails 5 versioned migrations added.
|
||||
|
||||
* deprecations
|
||||
* omniauth routes are no longer defined with a wildcard `:provider` parameter,
|
||||
and provider specific routes are defined instead, so route helpers like `user_omniauth_authorize_path(:github)` are deprecated in favor of `user_github_authorize_path`.
|
||||
You can still use `omniauth_authorize_path(:user, :github)` if you need to
|
||||
call the helpers dynamically.
|
||||
|
||||
### 4.0.0.rc1 - 2016-01-02
|
||||
|
||||
* Support added to Rails 5 (by @twalpole).
|
||||
|
||||
9
Gemfile
9
Gemfile
@@ -2,9 +2,9 @@ source "https://rubygems.org"
|
||||
|
||||
gemspec
|
||||
|
||||
gem "rails", "4.2.2"
|
||||
gem "omniauth", "~> 1.2.0"
|
||||
gem "omniauth-oauth2", "~> 1.1.0"
|
||||
gem "rails", "~> 4.2.6"
|
||||
gem "omniauth", "~> 1.3"
|
||||
gem "omniauth-oauth2", "~> 1.4"
|
||||
gem "rdoc"
|
||||
|
||||
group :test do
|
||||
@@ -12,6 +12,7 @@ group :test do
|
||||
gem "omniauth-openid", "~> 1.0.1"
|
||||
gem "webrat", "0.7.3", require: false
|
||||
gem "mocha", "~> 1.1", require: false
|
||||
gem 'test_after_commit', require: false
|
||||
end
|
||||
|
||||
platforms :jruby do
|
||||
@@ -25,5 +26,5 @@ platforms :ruby do
|
||||
end
|
||||
|
||||
group :mongoid do
|
||||
gem "mongoid", "~> 4.0"
|
||||
gem "mongoid", "~> 5.0"
|
||||
end
|
||||
|
||||
128
Gemfile.lock
128
Gemfile.lock
@@ -1,7 +1,7 @@
|
||||
PATH
|
||||
remote: .
|
||||
specs:
|
||||
devise (4.0.0.rc1)
|
||||
devise (4.1.1)
|
||||
bcrypt (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
railties (>= 4.1.0, < 5.1)
|
||||
@@ -11,47 +11,46 @@ PATH
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
actionmailer (4.2.2)
|
||||
actionpack (= 4.2.2)
|
||||
actionview (= 4.2.2)
|
||||
activejob (= 4.2.2)
|
||||
actionmailer (4.2.6)
|
||||
actionpack (= 4.2.6)
|
||||
actionview (= 4.2.6)
|
||||
activejob (= 4.2.6)
|
||||
mail (~> 2.5, >= 2.5.4)
|
||||
rails-dom-testing (~> 1.0, >= 1.0.5)
|
||||
actionpack (4.2.2)
|
||||
actionview (= 4.2.2)
|
||||
activesupport (= 4.2.2)
|
||||
actionpack (4.2.6)
|
||||
actionview (= 4.2.6)
|
||||
activesupport (= 4.2.6)
|
||||
rack (~> 1.6)
|
||||
rack-test (~> 0.6.2)
|
||||
rails-dom-testing (~> 1.0, >= 1.0.5)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.1)
|
||||
actionview (4.2.2)
|
||||
activesupport (= 4.2.2)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||
actionview (4.2.6)
|
||||
activesupport (= 4.2.6)
|
||||
builder (~> 3.1)
|
||||
erubis (~> 2.7.0)
|
||||
rails-dom-testing (~> 1.0, >= 1.0.5)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.1)
|
||||
activejob (4.2.2)
|
||||
activesupport (= 4.2.2)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||
activejob (4.2.6)
|
||||
activesupport (= 4.2.6)
|
||||
globalid (>= 0.3.0)
|
||||
activemodel (4.2.2)
|
||||
activesupport (= 4.2.2)
|
||||
activemodel (4.2.6)
|
||||
activesupport (= 4.2.6)
|
||||
builder (~> 3.1)
|
||||
activerecord (4.2.2)
|
||||
activemodel (= 4.2.2)
|
||||
activesupport (= 4.2.2)
|
||||
activerecord (4.2.6)
|
||||
activemodel (= 4.2.6)
|
||||
activesupport (= 4.2.6)
|
||||
arel (~> 6.0)
|
||||
activesupport (4.2.2)
|
||||
activesupport (4.2.6)
|
||||
i18n (~> 0.7)
|
||||
json (~> 1.7, >= 1.7.7)
|
||||
minitest (~> 5.1)
|
||||
thread_safe (~> 0.3, >= 0.3.4)
|
||||
tzinfo (~> 1.1)
|
||||
arel (6.0.3)
|
||||
bcrypt (3.1.10)
|
||||
bson (3.2.6)
|
||||
bcrypt (3.1.11)
|
||||
bson (4.0.0)
|
||||
builder (3.2.2)
|
||||
concurrent-ruby (1.0.0)
|
||||
connection_pool (2.2.0)
|
||||
concurrent-ruby (1.0.1)
|
||||
erubis (2.7.0)
|
||||
faraday (0.9.2)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
@@ -60,51 +59,46 @@ GEM
|
||||
hashie (3.4.3)
|
||||
i18n (0.7.0)
|
||||
json (1.8.3)
|
||||
jwt (1.5.2)
|
||||
jwt (1.5.1)
|
||||
loofah (2.0.3)
|
||||
nokogiri (>= 1.5.9)
|
||||
mail (2.6.3)
|
||||
mime-types (>= 1.16, < 3)
|
||||
metaclass (0.0.4)
|
||||
mime-types (2.99)
|
||||
mime-types (2.99.1)
|
||||
mini_portile2 (2.0.0)
|
||||
minitest (5.8.4)
|
||||
mocha (1.1.0)
|
||||
metaclass (~> 0.0.1)
|
||||
mongoid (4.0.2)
|
||||
mongo (2.2.0)
|
||||
bson (~> 4.0)
|
||||
mongoid (5.0.1)
|
||||
activemodel (~> 4.0)
|
||||
moped (~> 2.0.0)
|
||||
mongo (~> 2.1)
|
||||
origin (~> 2.1)
|
||||
tzinfo (>= 0.3.37)
|
||||
moped (2.0.7)
|
||||
bson (~> 3.0)
|
||||
connection_pool (~> 2.0)
|
||||
optionable (~> 0.2.0)
|
||||
multi_json (1.11.2)
|
||||
multi_xml (0.5.5)
|
||||
multipart-post (2.0.0)
|
||||
nokogiri (1.6.7.2)
|
||||
mini_portile2 (~> 2.0.0.rc2)
|
||||
oauth2 (0.9.4)
|
||||
oauth2 (1.1.0)
|
||||
faraday (>= 0.8, < 0.10)
|
||||
jwt (~> 1.0)
|
||||
jwt (~> 1.0, < 1.5.2)
|
||||
multi_json (~> 1.3)
|
||||
multi_xml (~> 0.5)
|
||||
rack (~> 1.2)
|
||||
omniauth (1.2.2)
|
||||
rack (>= 1.2, < 3)
|
||||
omniauth (1.3.1)
|
||||
hashie (>= 1.2, < 4)
|
||||
rack (~> 1.0)
|
||||
omniauth-facebook (1.6.0)
|
||||
omniauth-oauth2 (~> 1.1)
|
||||
omniauth-oauth2 (1.1.2)
|
||||
faraday (>= 0.8, < 0.10)
|
||||
multi_json (~> 1.3)
|
||||
oauth2 (~> 0.9.3)
|
||||
rack (>= 1.0, < 3)
|
||||
omniauth-facebook (3.0.0)
|
||||
omniauth-oauth2 (~> 1.2)
|
||||
omniauth-oauth2 (1.4.0)
|
||||
oauth2 (~> 1.0)
|
||||
omniauth (~> 1.2)
|
||||
omniauth-openid (1.0.1)
|
||||
omniauth (~> 1.0)
|
||||
rack-openid (~> 1.3.1)
|
||||
optionable (0.2.0)
|
||||
origin (2.2.0)
|
||||
orm_adapter (0.5.0)
|
||||
rack (1.6.4)
|
||||
@@ -113,16 +107,16 @@ GEM
|
||||
ruby-openid (>= 2.1.8)
|
||||
rack-test (0.6.3)
|
||||
rack (>= 1.0)
|
||||
rails (4.2.2)
|
||||
actionmailer (= 4.2.2)
|
||||
actionpack (= 4.2.2)
|
||||
actionview (= 4.2.2)
|
||||
activejob (= 4.2.2)
|
||||
activemodel (= 4.2.2)
|
||||
activerecord (= 4.2.2)
|
||||
activesupport (= 4.2.2)
|
||||
rails (4.2.6)
|
||||
actionmailer (= 4.2.6)
|
||||
actionpack (= 4.2.6)
|
||||
actionview (= 4.2.6)
|
||||
activejob (= 4.2.6)
|
||||
activemodel (= 4.2.6)
|
||||
activerecord (= 4.2.6)
|
||||
activesupport (= 4.2.6)
|
||||
bundler (>= 1.3.0, < 2.0)
|
||||
railties (= 4.2.2)
|
||||
railties (= 4.2.6)
|
||||
sprockets-rails
|
||||
rails-deprecated_sanitizer (1.0.3)
|
||||
activesupport (>= 4.2.0.alpha)
|
||||
@@ -132,24 +126,27 @@ GEM
|
||||
rails-deprecated_sanitizer (>= 1.0.1)
|
||||
rails-html-sanitizer (1.0.3)
|
||||
loofah (~> 2.0)
|
||||
railties (4.2.2)
|
||||
actionpack (= 4.2.2)
|
||||
activesupport (= 4.2.2)
|
||||
railties (4.2.6)
|
||||
actionpack (= 4.2.6)
|
||||
activesupport (= 4.2.6)
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.18.1, < 2.0)
|
||||
rake (10.5.0)
|
||||
rdoc (4.2.1)
|
||||
responders (2.1.1)
|
||||
rake (11.0.1)
|
||||
rdoc (4.2.2)
|
||||
json (~> 1.4)
|
||||
responders (2.2.0)
|
||||
railties (>= 4.2.0, < 5.1)
|
||||
ruby-openid (2.7.0)
|
||||
sprockets (3.5.2)
|
||||
concurrent-ruby (~> 1.0)
|
||||
rack (> 1, < 3)
|
||||
sprockets-rails (3.0.0)
|
||||
sprockets-rails (3.0.4)
|
||||
actionpack (>= 4.0)
|
||||
activesupport (>= 4.0)
|
||||
sprockets (>= 3.0.0)
|
||||
sqlite3 (1.3.11)
|
||||
test_after_commit (1.0.0)
|
||||
activerecord (>= 3.2)
|
||||
thor (0.19.1)
|
||||
thread_safe (0.3.5)
|
||||
tzinfo (1.2.2)
|
||||
@@ -170,15 +167,16 @@ DEPENDENCIES
|
||||
devise!
|
||||
jruby-openssl
|
||||
mocha (~> 1.1)
|
||||
mongoid (~> 4.0)
|
||||
omniauth (~> 1.2.0)
|
||||
mongoid (~> 5.0)
|
||||
omniauth (~> 1.3)
|
||||
omniauth-facebook
|
||||
omniauth-oauth2 (~> 1.1.0)
|
||||
omniauth-oauth2 (~> 1.4)
|
||||
omniauth-openid (~> 1.0.1)
|
||||
rails (= 4.2.2)
|
||||
rails (~> 4.2.6)
|
||||
rdoc
|
||||
sqlite3
|
||||
test_after_commit
|
||||
webrat (= 0.7.3)
|
||||
|
||||
BUNDLED WITH
|
||||
1.11.2
|
||||
1.12.3
|
||||
|
||||
15
README.md
15
README.md
@@ -4,7 +4,6 @@ By [Plataformatec](http://plataformatec.com.br/).
|
||||
|
||||
[](http://travis-ci.org/plataformatec/devise)
|
||||
[](https://codeclimate.com/github/plataformatec/devise)
|
||||
[](https://hakiri.io/github/plataformatec/devise/master)
|
||||
|
||||
This README is [also available in a friendly navigable format](http://devise.plataformatec.com.br/).
|
||||
|
||||
@@ -17,7 +16,7 @@ Devise is a flexible authentication solution for Rails based on Warden. It:
|
||||
|
||||
It's composed of 10 modules:
|
||||
|
||||
* [Database Authenticatable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/DatabaseAuthenticatable): encrypts and stores a password in the database to validate the authenticity of a user while signing in. The authentication can be done both through POST requests or HTTP Basic Authentication.
|
||||
* [Database Authenticatable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/DatabaseAuthenticatable): hashes and stores a password in the database to validate the authenticity of a user while signing in. The authentication can be done both through POST requests or HTTP Basic Authentication.
|
||||
* [Omniauthable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Omniauthable): adds OmniAuth (https://github.com/intridea/omniauth) support.
|
||||
* [Confirmable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Confirmable): sends emails with confirmation instructions and verifies whether an account is already confirmed during sign in.
|
||||
* [Recoverable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Recoverable): resets the user password and sends reset instructions.
|
||||
@@ -28,8 +27,6 @@ It's composed of 10 modules:
|
||||
* [Validatable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Validatable): provides validations of email and password. It's optional and can be customized, so you're able to define your own validations.
|
||||
* [Lockable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Lockable): locks an account after a specified number of failed sign-in attempts. Can unlock via email or after a specified time period.
|
||||
|
||||
Devise is guaranteed to be thread-safe on YARV. Thread-safety support on JRuby is in progress.
|
||||
|
||||
## Information
|
||||
|
||||
### The Devise wiki
|
||||
@@ -112,7 +109,7 @@ The generator will install an initializer which describes ALL of Devise's config
|
||||
rails generate devise MODEL
|
||||
```
|
||||
|
||||
Replace MODEL with the class name used for the application’s 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. The generator also configures your `config/routes.rb` file to point to the Devise controller.
|
||||
Replace MODEL with the class name used for the application’s users (it’s frequently `User` but could also be `Admin`). This will create a model (if one does not exist) and configure it with the default Devise modules. The generator also configures your `config/routes.rb` file to point to the Devise controller.
|
||||
|
||||
Next, check the MODEL for any additional configuration options you might want to add, such as confirmable or lockable. If you add an option, be sure to inspect the migration file (created by the generator if your ORM supports them) and uncomment the appropriate section. For example, if you add the confirmable option in the model, you'll need to uncomment the Confirmable section in the migration. Then run `rake db:migrate`
|
||||
|
||||
@@ -132,6 +129,8 @@ Devise will create some helpers to use inside your controllers and views. To set
|
||||
before_action :authenticate_user!
|
||||
```
|
||||
|
||||
For Rails 5, note that `protect_from_forgery` is no longer prepended to the `before_action` chain, so if you have set `authenticate_user` before `protect_from_forgery`, your request will result in "Can't verify CSRF token authenticity." To resolve this, either change the order in which you call them, or use `protect_from_forgery prepend: true`.
|
||||
|
||||
If your devise model is something other than User, replace "_user" with "_yourmodel". The same logic applies to the instructions below.
|
||||
|
||||
To verify if a user is signed in, use the following helper:
|
||||
@@ -174,7 +173,7 @@ member_session
|
||||
|
||||
### Configuring Models
|
||||
|
||||
The Devise method in your models also accepts some options to configure its modules. For example, you can choose the cost of the encryption algorithm with:
|
||||
The Devise method in your models also accepts some options to configure its modules. For example, you can choose the cost of the hashing algorithm with:
|
||||
|
||||
```ruby
|
||||
devise :database_authenticatable, :registerable, :confirmable, :recoverable, stretches: 20
|
||||
@@ -190,7 +189,7 @@ Besides `:stretches`, you can define `:pepper`, `:encryptor`, `:confirm_within`,
|
||||
|
||||
When you customize your own views, you may end up adding new attributes to forms. Rails 4 moved the parameter sanitization from the model to the controller, causing Devise to handle this concern at the controller as well.
|
||||
|
||||
There are just three actions in Devise that allow any set of parameters to be passed down to the model, therefore requiring sanitization. Their names and the permitted parameters by default are:
|
||||
There are just three actions in Devise that allow any set of parameters to be passed down to the model, therefore requiring sanitization. Their names and default permitted parameters are:
|
||||
|
||||
* `sign_in` (`Devise::SessionsController#create`) - Permits only the authentication keys (like `email`)
|
||||
* `sign_up` (`Devise::RegistrationsController#create`) - Permits authentication keys plus `password` and `password_confirmation`
|
||||
@@ -412,7 +411,7 @@ Caution: Devise Controllers inherit from ApplicationController. If your app uses
|
||||
|
||||
### Test helpers
|
||||
|
||||
Devise includes some test helpers for functional specs. In order to use them, you need to include Devise in your functional tests by adding the following to the bottom of your `test/test_helper.rb` file:
|
||||
Devise includes some test helpers for functional specs. In order to use them, you need to include Devise in your functional tests by adding the following to the bottom of your `test/test_helper.rb` file (make sure you place it out of scope of `ActiveSupport::TestCase` which is the default class inside of `test/test_helper.rb`):
|
||||
|
||||
```ruby
|
||||
class ActionController::TestCase
|
||||
|
||||
@@ -22,7 +22,7 @@ class Devise::ConfirmationsController < DeviseController
|
||||
yield resource if block_given?
|
||||
|
||||
if resource.errors.empty?
|
||||
set_flash_message(:notice, :confirmed) if is_flashing_format?
|
||||
set_flash_message!(:notice, :confirmed)
|
||||
respond_with_navigational(resource){ redirect_to after_confirmation_path_for(resource_name, resource) }
|
||||
else
|
||||
respond_with_navigational(resource.errors, status: :unprocessable_entity){ render :new }
|
||||
|
||||
@@ -36,10 +36,10 @@ class Devise::PasswordsController < DeviseController
|
||||
resource.unlock_access! if unlockable?(resource)
|
||||
if Devise.sign_in_after_reset_password
|
||||
flash_message = resource.active_for_authentication? ? :updated : :updated_not_active
|
||||
set_flash_message(:notice, flash_message) if is_flashing_format?
|
||||
set_flash_message!(:notice, flash_message)
|
||||
sign_in(resource_name, resource)
|
||||
else
|
||||
set_flash_message(:notice, :updated_not_active) if is_flashing_format?
|
||||
set_flash_message!(:notice, :updated_not_active)
|
||||
end
|
||||
respond_with resource, location: after_resetting_password_path_for(resource)
|
||||
else
|
||||
|
||||
@@ -18,11 +18,11 @@ class Devise::RegistrationsController < DeviseController
|
||||
yield resource if block_given?
|
||||
if resource.persisted?
|
||||
if resource.active_for_authentication?
|
||||
set_flash_message :notice, :signed_up if is_flashing_format?
|
||||
set_flash_message! :notice, :signed_up
|
||||
sign_up(resource_name, resource)
|
||||
respond_with resource, location: after_sign_up_path_for(resource)
|
||||
else
|
||||
set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_flashing_format?
|
||||
set_flash_message! :notice, :"signed_up_but_#{resource.inactive_message}"
|
||||
expire_data_after_sign_in!
|
||||
respond_with resource, location: after_inactive_sign_up_path_for(resource)
|
||||
end
|
||||
@@ -65,7 +65,7 @@ class Devise::RegistrationsController < DeviseController
|
||||
def destroy
|
||||
resource.destroy
|
||||
Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name)
|
||||
set_flash_message :notice, :destroyed if is_flashing_format?
|
||||
set_flash_message! :notice, :destroyed
|
||||
yield resource if block_given?
|
||||
respond_with_navigational(resource){ redirect_to after_sign_out_path_for(resource_name) }
|
||||
end
|
||||
|
||||
@@ -15,7 +15,7 @@ class Devise::SessionsController < DeviseController
|
||||
# POST /resource/sign_in
|
||||
def create
|
||||
self.resource = warden.authenticate!(auth_options)
|
||||
set_flash_message(:notice, :signed_in) if is_flashing_format?
|
||||
set_flash_message!(:notice, :signed_in)
|
||||
sign_in(resource_name, resource)
|
||||
yield resource if block_given?
|
||||
respond_with resource, location: after_sign_in_path_for(resource)
|
||||
@@ -24,7 +24,7 @@ class Devise::SessionsController < DeviseController
|
||||
# DELETE /resource/sign_out
|
||||
def destroy
|
||||
signed_out = (Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name))
|
||||
set_flash_message :notice, :signed_out if signed_out && is_flashing_format?
|
||||
set_flash_message! :notice, :signed_out if signed_out
|
||||
yield if block_given?
|
||||
respond_to_on_destroy
|
||||
end
|
||||
@@ -58,7 +58,7 @@ class Devise::SessionsController < DeviseController
|
||||
# to the after_sign_out path.
|
||||
def verify_signed_out_user
|
||||
if all_signed_out?
|
||||
set_flash_message :notice, :already_signed_out if is_flashing_format?
|
||||
set_flash_message! :notice, :already_signed_out
|
||||
|
||||
respond_to_on_destroy
|
||||
end
|
||||
|
||||
@@ -24,7 +24,7 @@ class Devise::UnlocksController < DeviseController
|
||||
yield resource if block_given?
|
||||
|
||||
if resource.errors.empty?
|
||||
set_flash_message :notice, :unlocked if is_flashing_format?
|
||||
set_flash_message! :notice, :unlocked
|
||||
respond_with_navigational(resource){ redirect_to after_unlock_path_for(resource) }
|
||||
else
|
||||
respond_with_navigational(resource.errors, status: :unprocessable_entity){ render :new }
|
||||
|
||||
@@ -127,13 +127,13 @@ MESSAGE
|
||||
end
|
||||
|
||||
if notice
|
||||
set_flash_message :notice, notice if is_flashing_format?
|
||||
set_flash_message! :notice, notice
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
# Sets the flash message with :key, using I18n. By default you are able
|
||||
# to setup your messages using specific resource scope, and if no message is
|
||||
# to set up your messages using specific resource scope, and if no message is
|
||||
# found we look to the default scope. Set the "now" options key to a true
|
||||
# value to populate the flash.now hash in lieu of the default flash hash (so
|
||||
# the flash message will be available to the current action instead of the
|
||||
@@ -158,6 +158,13 @@ MESSAGE
|
||||
end
|
||||
end
|
||||
|
||||
# Sets flash message if is_flashing_format? equals true
|
||||
def set_flash_message!(key, kind, options = {})
|
||||
if is_flashing_format?
|
||||
set_flash_message(key, kind, options)
|
||||
end
|
||||
end
|
||||
|
||||
# Sets minimum password length to show to user
|
||||
def set_minimum_password_length
|
||||
if devise_mapping.validatable?
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :email %><br />
|
||||
<%= f.email_field :email, autofocus: true, value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %>
|
||||
<%= f.email_field :email, autofocus: true, value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %>
|
||||
</div>
|
||||
|
||||
<div class="actions">
|
||||
|
||||
13
bin/test
Executable file
13
bin/test
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env ruby
|
||||
$: << File.expand_path(File.expand_path('../../test', __FILE__))
|
||||
|
||||
require 'bundler/setup'
|
||||
begin
|
||||
require 'rails/test_unit/minitest_plugin'
|
||||
rescue LoadError
|
||||
exec 'rake'
|
||||
end
|
||||
|
||||
Rails::TestUnitReporter.executable = 'bin/test'
|
||||
|
||||
exit Minitest.run(ARGV)
|
||||
@@ -1,10 +1,10 @@
|
||||
source "https://rubygems.org"
|
||||
|
||||
gemspec path: '..'
|
||||
gemspec path: ".."
|
||||
|
||||
gem "rails", github: 'rails/rails', branch: '4-1-stable'
|
||||
gem "omniauth", "~> 1.2.0"
|
||||
gem "omniauth-oauth2", "~> 1.1.0"
|
||||
gem "rails", github: "rails/rails", branch: "4-1-stable"
|
||||
gem "omniauth", "~> 1.3"
|
||||
gem "omniauth-oauth2", "~> 1.4"
|
||||
gem "rdoc"
|
||||
|
||||
group :test do
|
||||
@@ -12,6 +12,7 @@ group :test do
|
||||
gem "omniauth-openid", "~> 1.0.1"
|
||||
gem "webrat", "0.7.3", require: false
|
||||
gem "mocha", "~> 1.1", require: false
|
||||
gem 'test_after_commit', require: false
|
||||
end
|
||||
|
||||
platforms :jruby do
|
||||
|
||||
@@ -1,54 +1,54 @@
|
||||
GIT
|
||||
remote: git://github.com/rails/rails.git
|
||||
revision: e8eda76893479a29ace8d85cf4e4cfc67cd6fd4b
|
||||
revision: 41b4d81b4fd14cbf43060c223bea0f461256d099
|
||||
branch: 4-1-stable
|
||||
specs:
|
||||
actionmailer (4.1.14.1)
|
||||
actionpack (= 4.1.14.1)
|
||||
actionview (= 4.1.14.1)
|
||||
actionmailer (4.1.15)
|
||||
actionpack (= 4.1.15)
|
||||
actionview (= 4.1.15)
|
||||
mail (~> 2.5, >= 2.5.4)
|
||||
actionpack (4.1.14.1)
|
||||
actionview (= 4.1.14.1)
|
||||
activesupport (= 4.1.14.1)
|
||||
actionpack (4.1.15)
|
||||
actionview (= 4.1.15)
|
||||
activesupport (= 4.1.15)
|
||||
rack (~> 1.5.2)
|
||||
rack-test (~> 0.6.2)
|
||||
actionview (4.1.14.1)
|
||||
activesupport (= 4.1.14.1)
|
||||
actionview (4.1.15)
|
||||
activesupport (= 4.1.15)
|
||||
builder (~> 3.1)
|
||||
erubis (~> 2.7.0)
|
||||
activemodel (4.1.14.1)
|
||||
activesupport (= 4.1.14.1)
|
||||
activemodel (4.1.15)
|
||||
activesupport (= 4.1.15)
|
||||
builder (~> 3.1)
|
||||
activerecord (4.1.14.1)
|
||||
activemodel (= 4.1.14.1)
|
||||
activesupport (= 4.1.14.1)
|
||||
activerecord (4.1.15)
|
||||
activemodel (= 4.1.15)
|
||||
activesupport (= 4.1.15)
|
||||
arel (~> 5.0.0)
|
||||
activesupport (4.1.14.1)
|
||||
activesupport (4.1.15)
|
||||
i18n (~> 0.6, >= 0.6.9)
|
||||
json (~> 1.7, >= 1.7.7)
|
||||
minitest (~> 5.1)
|
||||
thread_safe (~> 0.1)
|
||||
tzinfo (~> 1.1)
|
||||
rails (4.1.14.1)
|
||||
actionmailer (= 4.1.14.1)
|
||||
actionpack (= 4.1.14.1)
|
||||
actionview (= 4.1.14.1)
|
||||
activemodel (= 4.1.14.1)
|
||||
activerecord (= 4.1.14.1)
|
||||
activesupport (= 4.1.14.1)
|
||||
rails (4.1.15)
|
||||
actionmailer (= 4.1.15)
|
||||
actionpack (= 4.1.15)
|
||||
actionview (= 4.1.15)
|
||||
activemodel (= 4.1.15)
|
||||
activerecord (= 4.1.15)
|
||||
activesupport (= 4.1.15)
|
||||
bundler (>= 1.3.0, < 2.0)
|
||||
railties (= 4.1.14.1)
|
||||
railties (= 4.1.15)
|
||||
sprockets-rails (~> 2.0)
|
||||
railties (4.1.14.1)
|
||||
actionpack (= 4.1.14.1)
|
||||
activesupport (= 4.1.14.1)
|
||||
railties (4.1.15)
|
||||
actionpack (= 4.1.15)
|
||||
activesupport (= 4.1.15)
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.18.1, < 2.0)
|
||||
|
||||
PATH
|
||||
remote: ..
|
||||
specs:
|
||||
devise (4.0.0.rc1)
|
||||
devise (4.0.1)
|
||||
bcrypt (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
railties (>= 4.1.0, < 5.1)
|
||||
@@ -59,10 +59,10 @@ GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
arel (5.0.1.20140414130214)
|
||||
bcrypt (3.1.10)
|
||||
bcrypt (3.1.11)
|
||||
bson (3.2.6)
|
||||
builder (3.2.2)
|
||||
concurrent-ruby (1.0.0)
|
||||
concurrent-ruby (1.0.1)
|
||||
connection_pool (2.2.0)
|
||||
erubis (2.7.0)
|
||||
faraday (0.9.2)
|
||||
@@ -70,11 +70,11 @@ GEM
|
||||
hashie (3.4.3)
|
||||
i18n (0.7.0)
|
||||
json (1.8.3)
|
||||
jwt (1.5.2)
|
||||
jwt (1.5.1)
|
||||
mail (2.6.3)
|
||||
mime-types (>= 1.16, < 3)
|
||||
metaclass (0.0.4)
|
||||
mime-types (2.99)
|
||||
mime-types (2.99.1)
|
||||
mini_portile2 (2.0.0)
|
||||
minitest (5.8.4)
|
||||
mocha (1.1.0)
|
||||
@@ -93,21 +93,19 @@ GEM
|
||||
multipart-post (2.0.0)
|
||||
nokogiri (1.6.7.2)
|
||||
mini_portile2 (~> 2.0.0.rc2)
|
||||
oauth2 (0.9.4)
|
||||
oauth2 (1.1.0)
|
||||
faraday (>= 0.8, < 0.10)
|
||||
jwt (~> 1.0)
|
||||
jwt (~> 1.0, < 1.5.2)
|
||||
multi_json (~> 1.3)
|
||||
multi_xml (~> 0.5)
|
||||
rack (~> 1.2)
|
||||
omniauth (1.2.2)
|
||||
rack (>= 1.2, < 3)
|
||||
omniauth (1.3.1)
|
||||
hashie (>= 1.2, < 4)
|
||||
rack (~> 1.0)
|
||||
omniauth-facebook (1.6.0)
|
||||
omniauth-oauth2 (~> 1.1)
|
||||
omniauth-oauth2 (1.1.2)
|
||||
faraday (>= 0.8, < 0.10)
|
||||
multi_json (~> 1.3)
|
||||
oauth2 (~> 0.9.3)
|
||||
rack (>= 1.0, < 3)
|
||||
omniauth-facebook (3.0.0)
|
||||
omniauth-oauth2 (~> 1.2)
|
||||
omniauth-oauth2 (1.4.0)
|
||||
oauth2 (~> 1.0)
|
||||
omniauth (~> 1.2)
|
||||
omniauth-openid (1.0.1)
|
||||
omniauth (~> 1.0)
|
||||
@@ -121,8 +119,9 @@ GEM
|
||||
ruby-openid (>= 2.1.8)
|
||||
rack-test (0.6.3)
|
||||
rack (>= 1.0)
|
||||
rake (10.5.0)
|
||||
rdoc (4.2.1)
|
||||
rake (11.0.1)
|
||||
rdoc (4.2.2)
|
||||
json (~> 1.4)
|
||||
responders (1.1.2)
|
||||
railties (>= 3.2, < 4.2)
|
||||
ruby-openid (2.7.0)
|
||||
@@ -134,6 +133,8 @@ GEM
|
||||
activesupport (>= 3.0)
|
||||
sprockets (>= 2.8, < 4.0)
|
||||
sqlite3 (1.3.11)
|
||||
test_after_commit (1.0.0)
|
||||
activerecord (>= 3.2)
|
||||
thor (0.19.1)
|
||||
thread_safe (0.3.5)
|
||||
tzinfo (1.2.2)
|
||||
@@ -155,13 +156,14 @@ DEPENDENCIES
|
||||
jruby-openssl
|
||||
mocha (~> 1.1)
|
||||
mongoid (~> 4.0.0)
|
||||
omniauth (~> 1.2.0)
|
||||
omniauth (~> 1.3)
|
||||
omniauth-facebook
|
||||
omniauth-oauth2 (~> 1.1.0)
|
||||
omniauth-oauth2 (~> 1.4)
|
||||
omniauth-openid (~> 1.0.1)
|
||||
rails!
|
||||
rdoc
|
||||
sqlite3
|
||||
test_after_commit
|
||||
webrat (= 0.7.3)
|
||||
|
||||
BUNDLED WITH
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
source "https://rubygems.org"
|
||||
|
||||
gemspec path: '..'
|
||||
gemspec path: ".."
|
||||
|
||||
gem "rails", github: 'rails/rails', branch: '4-2-stable'
|
||||
gem "omniauth", "~> 1.2.2"
|
||||
gem "omniauth-oauth2", "~> 1.2.0"
|
||||
gem "rails", github: "rails/rails", branch: "4-2-stable"
|
||||
gem "omniauth", "~> 1.3"
|
||||
gem "omniauth-oauth2", "~> 1.4"
|
||||
gem "rdoc"
|
||||
|
||||
group :test do
|
||||
@@ -12,6 +12,7 @@ group :test do
|
||||
gem "omniauth-openid", "~> 1.0.1"
|
||||
gem "webrat", "0.7.3", require: false
|
||||
gem "mocha", "~> 1.1", require: false
|
||||
gem 'test_after_commit', require: false
|
||||
end
|
||||
|
||||
platforms :jruby do
|
||||
|
||||
@@ -1,64 +1,64 @@
|
||||
GIT
|
||||
remote: git://github.com/rails/rails.git
|
||||
revision: acf654b1c4a1ffe2a90d6ea63a0b989d656bb87d
|
||||
revision: 2aa27582c202148296bb169159b0bf9a47a7bd80
|
||||
branch: 4-2-stable
|
||||
specs:
|
||||
actionmailer (4.2.5.1)
|
||||
actionpack (= 4.2.5.1)
|
||||
actionview (= 4.2.5.1)
|
||||
activejob (= 4.2.5.1)
|
||||
actionmailer (4.2.6)
|
||||
actionpack (= 4.2.6)
|
||||
actionview (= 4.2.6)
|
||||
activejob (= 4.2.6)
|
||||
mail (~> 2.5, >= 2.5.4)
|
||||
rails-dom-testing (~> 1.0, >= 1.0.5)
|
||||
actionpack (4.2.5.1)
|
||||
actionview (= 4.2.5.1)
|
||||
activesupport (= 4.2.5.1)
|
||||
actionpack (4.2.6)
|
||||
actionview (= 4.2.6)
|
||||
activesupport (= 4.2.6)
|
||||
rack (~> 1.6)
|
||||
rack-test (~> 0.6.2)
|
||||
rails-dom-testing (~> 1.0, >= 1.0.5)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||
actionview (4.2.5.1)
|
||||
activesupport (= 4.2.5.1)
|
||||
actionview (4.2.6)
|
||||
activesupport (= 4.2.6)
|
||||
builder (~> 3.1)
|
||||
erubis (~> 2.7.0)
|
||||
rails-dom-testing (~> 1.0, >= 1.0.5)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||
activejob (4.2.5.1)
|
||||
activesupport (= 4.2.5.1)
|
||||
activejob (4.2.6)
|
||||
activesupport (= 4.2.6)
|
||||
globalid (>= 0.3.0)
|
||||
activemodel (4.2.5.1)
|
||||
activesupport (= 4.2.5.1)
|
||||
activemodel (4.2.6)
|
||||
activesupport (= 4.2.6)
|
||||
builder (~> 3.1)
|
||||
activerecord (4.2.5.1)
|
||||
activemodel (= 4.2.5.1)
|
||||
activesupport (= 4.2.5.1)
|
||||
activerecord (4.2.6)
|
||||
activemodel (= 4.2.6)
|
||||
activesupport (= 4.2.6)
|
||||
arel (~> 6.0)
|
||||
activesupport (4.2.5.1)
|
||||
activesupport (4.2.6)
|
||||
i18n (~> 0.7)
|
||||
json (~> 1.7, >= 1.7.7)
|
||||
minitest (~> 5.1)
|
||||
thread_safe (~> 0.3, >= 0.3.4)
|
||||
tzinfo (~> 1.1)
|
||||
rails (4.2.5.1)
|
||||
actionmailer (= 4.2.5.1)
|
||||
actionpack (= 4.2.5.1)
|
||||
actionview (= 4.2.5.1)
|
||||
activejob (= 4.2.5.1)
|
||||
activemodel (= 4.2.5.1)
|
||||
activerecord (= 4.2.5.1)
|
||||
activesupport (= 4.2.5.1)
|
||||
rails (4.2.6)
|
||||
actionmailer (= 4.2.6)
|
||||
actionpack (= 4.2.6)
|
||||
actionview (= 4.2.6)
|
||||
activejob (= 4.2.6)
|
||||
activemodel (= 4.2.6)
|
||||
activerecord (= 4.2.6)
|
||||
activesupport (= 4.2.6)
|
||||
bundler (>= 1.3.0, < 2.0)
|
||||
railties (= 4.2.5.1)
|
||||
railties (= 4.2.6)
|
||||
sprockets-rails
|
||||
railties (4.2.5.1)
|
||||
actionpack (= 4.2.5.1)
|
||||
activesupport (= 4.2.5.1)
|
||||
railties (4.2.6)
|
||||
actionpack (= 4.2.6)
|
||||
activesupport (= 4.2.6)
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.18.1, < 2.0)
|
||||
|
||||
PATH
|
||||
remote: ..
|
||||
specs:
|
||||
devise (4.0.0.rc1)
|
||||
devise (4.0.1)
|
||||
bcrypt (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
railties (>= 4.1.0, < 5.1)
|
||||
@@ -69,10 +69,10 @@ GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
arel (6.0.3)
|
||||
bcrypt (3.1.10)
|
||||
bcrypt (3.1.11)
|
||||
bson (3.2.6)
|
||||
builder (3.2.2)
|
||||
concurrent-ruby (1.0.0)
|
||||
concurrent-ruby (1.0.1)
|
||||
connection_pool (2.2.0)
|
||||
erubis (2.7.0)
|
||||
faraday (0.9.2)
|
||||
@@ -82,13 +82,13 @@ GEM
|
||||
hashie (3.4.3)
|
||||
i18n (0.7.0)
|
||||
json (1.8.3)
|
||||
jwt (1.5.2)
|
||||
jwt (1.5.1)
|
||||
loofah (2.0.3)
|
||||
nokogiri (>= 1.5.9)
|
||||
mail (2.6.3)
|
||||
mime-types (>= 1.16, < 3)
|
||||
metaclass (0.0.4)
|
||||
mime-types (2.99)
|
||||
mime-types (2.99.1)
|
||||
mini_portile2 (2.0.0)
|
||||
minitest (5.8.4)
|
||||
mocha (1.1.0)
|
||||
@@ -107,20 +107,18 @@ GEM
|
||||
multipart-post (2.0.0)
|
||||
nokogiri (1.6.7.2)
|
||||
mini_portile2 (~> 2.0.0.rc2)
|
||||
oauth2 (1.0.0)
|
||||
oauth2 (1.1.0)
|
||||
faraday (>= 0.8, < 0.10)
|
||||
jwt (~> 1.0)
|
||||
jwt (~> 1.0, < 1.5.2)
|
||||
multi_json (~> 1.3)
|
||||
multi_xml (~> 0.5)
|
||||
rack (~> 1.2)
|
||||
omniauth (1.2.2)
|
||||
rack (>= 1.2, < 3)
|
||||
omniauth (1.3.1)
|
||||
hashie (>= 1.2, < 4)
|
||||
rack (~> 1.0)
|
||||
rack (>= 1.0, < 3)
|
||||
omniauth-facebook (3.0.0)
|
||||
omniauth-oauth2 (~> 1.2)
|
||||
omniauth-oauth2 (1.2.0)
|
||||
faraday (>= 0.8, < 0.10)
|
||||
multi_json (~> 1.3)
|
||||
omniauth-oauth2 (1.4.0)
|
||||
oauth2 (~> 1.0)
|
||||
omniauth (~> 1.2)
|
||||
omniauth-openid (1.0.1)
|
||||
@@ -143,19 +141,22 @@ GEM
|
||||
rails-deprecated_sanitizer (>= 1.0.1)
|
||||
rails-html-sanitizer (1.0.3)
|
||||
loofah (~> 2.0)
|
||||
rake (10.5.0)
|
||||
rdoc (4.2.1)
|
||||
responders (2.1.1)
|
||||
rake (11.0.1)
|
||||
rdoc (4.2.2)
|
||||
json (~> 1.4)
|
||||
responders (2.1.2)
|
||||
railties (>= 4.2.0, < 5.1)
|
||||
ruby-openid (2.7.0)
|
||||
sprockets (3.5.2)
|
||||
concurrent-ruby (~> 1.0)
|
||||
rack (> 1, < 3)
|
||||
sprockets-rails (3.0.0)
|
||||
sprockets-rails (3.0.4)
|
||||
actionpack (>= 4.0)
|
||||
activesupport (>= 4.0)
|
||||
sprockets (>= 3.0.0)
|
||||
sqlite3 (1.3.11)
|
||||
test_after_commit (1.0.0)
|
||||
activerecord (>= 3.2)
|
||||
thor (0.19.1)
|
||||
thread_safe (0.3.5)
|
||||
tzinfo (1.2.2)
|
||||
@@ -177,13 +178,14 @@ DEPENDENCIES
|
||||
jruby-openssl
|
||||
mocha (~> 1.1)
|
||||
mongoid (~> 4.0.0)
|
||||
omniauth (~> 1.2.2)
|
||||
omniauth (~> 1.3)
|
||||
omniauth-facebook
|
||||
omniauth-oauth2 (~> 1.2.0)
|
||||
omniauth-oauth2 (~> 1.4)
|
||||
omniauth-openid (~> 1.0.1)
|
||||
rails!
|
||||
rdoc
|
||||
sqlite3
|
||||
test_after_commit
|
||||
webrat (= 0.7.3)
|
||||
|
||||
BUNDLED WITH
|
||||
|
||||
@@ -1,37 +1,37 @@
|
||||
source 'https://rubygems.org'
|
||||
source "https://rubygems.org"
|
||||
|
||||
gemspec path: '..'
|
||||
gemspec path: ".."
|
||||
|
||||
gem 'rails', '5.0.0.beta1.1'
|
||||
gem 'omniauth', '~>1.3.1'
|
||||
gem 'oauth2', github: 'intridea/oauth2', branch: 'master'
|
||||
gem 'omniauth-oauth2', '>= 1.2.0', '< 1.5.0'
|
||||
gem 'rdoc'
|
||||
gem "rails", "5.0.0.beta3"
|
||||
gem "omniauth", " ~>1.3"
|
||||
gem "oauth2"
|
||||
gem "omniauth-oauth2", ">= 1.2.0", "< 1.5.0"
|
||||
gem "rdoc"
|
||||
|
||||
gem 'activemodel-serializers-xml', github: 'rails/activemodel-serializers-xml'
|
||||
gem "activemodel-serializers-xml", github: "rails/activemodel-serializers-xml"
|
||||
|
||||
gem 'rails-controller-testing'
|
||||
gem "rails-controller-testing"
|
||||
|
||||
gem 'responders', '~>2.1.1'
|
||||
gem "responders", "~> 2.1.1"
|
||||
|
||||
group :test do
|
||||
gem 'omniauth-facebook'
|
||||
gem 'omniauth-openid', '~> 1.0.1'
|
||||
gem 'webrat', '0.7.3', require: false
|
||||
gem 'mocha', '~> 1.1', require: false
|
||||
gem "omniauth-facebook"
|
||||
gem "omniauth-openid", "~> 1.0.1"
|
||||
gem "webrat", "0.7.3", require: false
|
||||
gem "mocha", "~> 1.1", require: false
|
||||
end
|
||||
|
||||
platforms :jruby do
|
||||
gem 'activerecord-jdbc-adapter'
|
||||
gem 'activerecord-jdbcsqlite3-adapter'
|
||||
gem 'jruby-openssl'
|
||||
gem "activerecord-jdbc-adapter"
|
||||
gem "activerecord-jdbcsqlite3-adapter"
|
||||
gem "jruby-openssl"
|
||||
end
|
||||
|
||||
platforms :ruby do
|
||||
gem 'sqlite3'
|
||||
gem "sqlite3"
|
||||
end
|
||||
|
||||
# TODO:
|
||||
# group :mongoid do
|
||||
# gem 'mongoid', '~> 4.0.0'
|
||||
# gem "mongoid", "~> 4.0.0"
|
||||
# end
|
||||
|
||||
@@ -1,28 +1,17 @@
|
||||
GIT
|
||||
remote: git://github.com/intridea/oauth2.git
|
||||
revision: 43e1fdd87e95a5b02438d5cce6a67e411afb5fec
|
||||
branch: master
|
||||
specs:
|
||||
oauth2 (1.0.0)
|
||||
faraday (>= 0.8, < 0.10)
|
||||
jwt (~> 1.0, < 1.5.2)
|
||||
multi_json (~> 1.3)
|
||||
multi_xml (~> 0.5)
|
||||
rack (>= 1.2, < 3)
|
||||
|
||||
GIT
|
||||
remote: git://github.com/rails/activemodel-serializers-xml.git
|
||||
revision: 1f72d9507c91b1cda10d1d20eac2b74dd6d9d4b9
|
||||
revision: f380ea5ddefcb9a37f4fbc47606ed6fbecdb2b2a
|
||||
specs:
|
||||
activemodel-serializers-xml (0.1.0)
|
||||
activemodel
|
||||
activerecord
|
||||
activesupport
|
||||
activemodel-serializers-xml (1.0.0)
|
||||
activemodel (> 5.x)
|
||||
activerecord (> 5.x)
|
||||
activesupport (> 5.x)
|
||||
builder (~> 3.1)
|
||||
|
||||
PATH
|
||||
remote: ..
|
||||
specs:
|
||||
devise (4.0.0.rc1)
|
||||
devise (4.0.0.rc2)
|
||||
bcrypt (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
railties (>= 4.1.0, < 5.1)
|
||||
@@ -32,104 +21,65 @@ PATH
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
actioncable (5.0.0.beta1.1)
|
||||
actionpack (= 5.0.0.beta1.1)
|
||||
celluloid (~> 0.17.2)
|
||||
coffee-rails (~> 4.1.0)
|
||||
em-hiredis (~> 0.3.0)
|
||||
faye-websocket (~> 0.10.0)
|
||||
redis (~> 3.0)
|
||||
actioncable (5.0.0.beta3)
|
||||
actionpack (= 5.0.0.beta3)
|
||||
nio4r (~> 1.2)
|
||||
websocket-driver (~> 0.6.1)
|
||||
actionmailer (5.0.0.beta1.1)
|
||||
actionpack (= 5.0.0.beta1.1)
|
||||
actionview (= 5.0.0.beta1.1)
|
||||
activejob (= 5.0.0.beta1.1)
|
||||
actionmailer (5.0.0.beta3)
|
||||
actionpack (= 5.0.0.beta3)
|
||||
actionview (= 5.0.0.beta3)
|
||||
activejob (= 5.0.0.beta3)
|
||||
mail (~> 2.5, >= 2.5.4)
|
||||
rails-dom-testing (~> 1.0, >= 1.0.5)
|
||||
actionpack (5.0.0.beta1.1)
|
||||
actionview (= 5.0.0.beta1.1)
|
||||
activesupport (= 5.0.0.beta1.1)
|
||||
actionpack (5.0.0.beta3)
|
||||
actionview (= 5.0.0.beta3)
|
||||
activesupport (= 5.0.0.beta3)
|
||||
rack (~> 2.x)
|
||||
rack-test (~> 0.6.3)
|
||||
rails-dom-testing (~> 1.0, >= 1.0.5)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||
actionview (5.0.0.beta1.1)
|
||||
activesupport (= 5.0.0.beta1.1)
|
||||
actionview (5.0.0.beta3)
|
||||
activesupport (= 5.0.0.beta3)
|
||||
builder (~> 3.1)
|
||||
erubis (~> 2.7.0)
|
||||
rails-dom-testing (~> 1.0, >= 1.0.5)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||
activejob (5.0.0.beta1.1)
|
||||
activesupport (= 5.0.0.beta1.1)
|
||||
activejob (5.0.0.beta3)
|
||||
activesupport (= 5.0.0.beta3)
|
||||
globalid (>= 0.3.6)
|
||||
activemodel (5.0.0.beta1.1)
|
||||
activesupport (= 5.0.0.beta1.1)
|
||||
builder (~> 3.1)
|
||||
activerecord (5.0.0.beta1.1)
|
||||
activemodel (= 5.0.0.beta1.1)
|
||||
activesupport (= 5.0.0.beta1.1)
|
||||
activemodel (5.0.0.beta3)
|
||||
activesupport (= 5.0.0.beta3)
|
||||
activerecord (5.0.0.beta3)
|
||||
activemodel (= 5.0.0.beta3)
|
||||
activesupport (= 5.0.0.beta3)
|
||||
arel (~> 7.0)
|
||||
activesupport (5.0.0.beta1.1)
|
||||
activesupport (5.0.0.beta3)
|
||||
concurrent-ruby (~> 1.0)
|
||||
i18n (~> 0.7)
|
||||
json (~> 1.7, >= 1.7.7)
|
||||
method_source
|
||||
minitest (~> 5.1)
|
||||
tzinfo (~> 1.1)
|
||||
arel (7.0.0)
|
||||
bcrypt (3.1.10)
|
||||
bcrypt (3.1.11)
|
||||
builder (3.2.2)
|
||||
celluloid (0.17.3)
|
||||
celluloid-essentials
|
||||
celluloid-extras
|
||||
celluloid-fsm
|
||||
celluloid-pool
|
||||
celluloid-supervision
|
||||
timers (>= 4.1.1)
|
||||
celluloid-essentials (0.20.5)
|
||||
timers (>= 4.1.1)
|
||||
celluloid-extras (0.20.5)
|
||||
timers (>= 4.1.1)
|
||||
celluloid-fsm (0.20.5)
|
||||
timers (>= 4.1.1)
|
||||
celluloid-pool (0.20.5)
|
||||
timers (>= 4.1.1)
|
||||
celluloid-supervision (0.20.5)
|
||||
timers (>= 4.1.1)
|
||||
coffee-rails (4.1.1)
|
||||
coffee-script (>= 2.2.0)
|
||||
railties (>= 4.0.0, < 5.1.x)
|
||||
coffee-script (2.4.1)
|
||||
coffee-script-source
|
||||
execjs
|
||||
coffee-script-source (1.10.0)
|
||||
concurrent-ruby (1.0.0)
|
||||
em-hiredis (0.3.0)
|
||||
eventmachine (~> 1.0)
|
||||
hiredis (~> 0.5.0)
|
||||
concurrent-ruby (1.0.1)
|
||||
erubis (2.7.0)
|
||||
eventmachine (1.0.9.1)
|
||||
execjs (2.6.0)
|
||||
faraday (0.9.2)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
faye-websocket (0.10.2)
|
||||
eventmachine (>= 0.12.0)
|
||||
websocket-driver (>= 0.5.1)
|
||||
globalid (0.3.6)
|
||||
activesupport (>= 4.1.0)
|
||||
hashie (3.4.3)
|
||||
hiredis (0.5.2)
|
||||
hitimes (1.2.3)
|
||||
i18n (0.7.0)
|
||||
json (1.8.3)
|
||||
jwt (1.5.1)
|
||||
loofah (2.0.3)
|
||||
nokogiri (>= 1.5.9)
|
||||
mail (2.6.3)
|
||||
mime-types (>= 1.16, < 3)
|
||||
mail (2.6.4)
|
||||
mime-types (>= 1.16, < 4)
|
||||
metaclass (0.0.4)
|
||||
method_source (0.8.2)
|
||||
mime-types (2.99)
|
||||
mime-types (3.0)
|
||||
mime-types-data (~> 3.2015)
|
||||
mime-types-data (3.2016.0221)
|
||||
mini_portile2 (2.0.0)
|
||||
minitest (5.8.4)
|
||||
mocha (1.1.0)
|
||||
@@ -137,8 +87,15 @@ GEM
|
||||
multi_json (1.11.2)
|
||||
multi_xml (0.5.5)
|
||||
multipart-post (2.0.0)
|
||||
nio4r (1.2.1)
|
||||
nokogiri (1.6.7.2)
|
||||
mini_portile2 (~> 2.0.0.rc2)
|
||||
oauth2 (1.1.0)
|
||||
faraday (>= 0.8, < 0.10)
|
||||
jwt (~> 1.0, < 1.5.2)
|
||||
multi_json (~> 1.3)
|
||||
multi_xml (~> 0.5)
|
||||
rack (>= 1.2, < 3)
|
||||
omniauth (1.3.1)
|
||||
hashie (>= 1.2, < 4)
|
||||
rack (>= 1.0, < 3)
|
||||
@@ -158,20 +115,22 @@ GEM
|
||||
ruby-openid (>= 2.1.8)
|
||||
rack-test (0.6.3)
|
||||
rack (>= 1.0)
|
||||
rails (5.0.0.beta1.1)
|
||||
actioncable (= 5.0.0.beta1.1)
|
||||
actionmailer (= 5.0.0.beta1.1)
|
||||
actionpack (= 5.0.0.beta1.1)
|
||||
actionview (= 5.0.0.beta1.1)
|
||||
activejob (= 5.0.0.beta1.1)
|
||||
activemodel (= 5.0.0.beta1.1)
|
||||
activerecord (= 5.0.0.beta1.1)
|
||||
activesupport (= 5.0.0.beta1.1)
|
||||
rails (5.0.0.beta3)
|
||||
actioncable (= 5.0.0.beta3)
|
||||
actionmailer (= 5.0.0.beta3)
|
||||
actionpack (= 5.0.0.beta3)
|
||||
actionview (= 5.0.0.beta3)
|
||||
activejob (= 5.0.0.beta3)
|
||||
activemodel (= 5.0.0.beta3)
|
||||
activerecord (= 5.0.0.beta3)
|
||||
activesupport (= 5.0.0.beta3)
|
||||
bundler (>= 1.3.0, < 2.0)
|
||||
railties (= 5.0.0.beta1.1)
|
||||
railties (= 5.0.0.beta3)
|
||||
sprockets-rails (>= 2.0.0)
|
||||
rails-controller-testing (0.0.3)
|
||||
rails (>= 4.2)
|
||||
rails-controller-testing (0.1.1)
|
||||
actionpack (~> 5.x)
|
||||
actionview (~> 5.x)
|
||||
activesupport (~> 5.x)
|
||||
rails-deprecated_sanitizer (1.0.3)
|
||||
activesupport (>= 4.2.0.alpha)
|
||||
rails-dom-testing (1.0.7)
|
||||
@@ -180,30 +139,28 @@ GEM
|
||||
rails-deprecated_sanitizer (>= 1.0.1)
|
||||
rails-html-sanitizer (1.0.3)
|
||||
loofah (~> 2.0)
|
||||
railties (5.0.0.beta1.1)
|
||||
actionpack (= 5.0.0.beta1.1)
|
||||
activesupport (= 5.0.0.beta1.1)
|
||||
railties (5.0.0.beta3)
|
||||
actionpack (= 5.0.0.beta3)
|
||||
activesupport (= 5.0.0.beta3)
|
||||
method_source
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.18.1, < 2.0)
|
||||
rake (10.5.0)
|
||||
rdoc (4.2.1)
|
||||
redis (3.2.2)
|
||||
responders (2.1.1)
|
||||
rake (11.1.2)
|
||||
rdoc (4.2.2)
|
||||
json (~> 1.4)
|
||||
responders (2.1.2)
|
||||
railties (>= 4.2.0, < 5.1)
|
||||
ruby-openid (2.7.0)
|
||||
sprockets (3.5.2)
|
||||
sprockets (3.6.0)
|
||||
concurrent-ruby (~> 1.0)
|
||||
rack (> 1, < 3)
|
||||
sprockets-rails (3.0.0)
|
||||
sprockets-rails (3.0.4)
|
||||
actionpack (>= 4.0)
|
||||
activesupport (>= 4.0)
|
||||
sprockets (>= 3.0.0)
|
||||
sqlite3 (1.3.11)
|
||||
thor (0.19.1)
|
||||
thread_safe (0.3.5)
|
||||
timers (4.1.1)
|
||||
hitimes
|
||||
tzinfo (1.2.2)
|
||||
thread_safe (~> 0.1)
|
||||
warden (1.2.6)
|
||||
@@ -226,12 +183,12 @@ DEPENDENCIES
|
||||
devise!
|
||||
jruby-openssl
|
||||
mocha (~> 1.1)
|
||||
oauth2!
|
||||
omniauth (~> 1.3.1)
|
||||
oauth2
|
||||
omniauth (~> 1.3)
|
||||
omniauth-facebook
|
||||
omniauth-oauth2 (>= 1.2.0, < 1.5.0)
|
||||
omniauth-openid (~> 1.0.1)
|
||||
rails (= 5.0.0.beta1.1)
|
||||
rails (= 5.0.0.beta3)
|
||||
rails-controller-testing
|
||||
rdoc
|
||||
responders (~> 2.1.1)
|
||||
|
||||
31
lib/devise.rb
Normal file → Executable file
31
lib/devise.rb
Normal file → Executable file
@@ -61,9 +61,9 @@ module Devise
|
||||
mattr_accessor :rememberable_options
|
||||
@@rememberable_options = {}
|
||||
|
||||
# The number of times to encrypt password.
|
||||
# The number of times to hash the password.
|
||||
mattr_accessor :stretches
|
||||
@@stretches = 10
|
||||
@@stretches = 11
|
||||
|
||||
# The default key used when authenticating over http auth.
|
||||
mattr_accessor :http_authentication_key
|
||||
@@ -83,7 +83,7 @@ module Devise
|
||||
|
||||
# Keys that should have whitespace stripped.
|
||||
mattr_accessor :strip_whitespace_keys
|
||||
@@strip_whitespace_keys = []
|
||||
@@strip_whitespace_keys = [:email]
|
||||
|
||||
# If http authentication is enabled by default.
|
||||
mattr_accessor :http_authenticatable
|
||||
@@ -101,11 +101,11 @@ module Devise
|
||||
mattr_accessor :http_authentication_realm
|
||||
@@http_authentication_realm = "Application"
|
||||
|
||||
# Email regex used to validate email formats. It simply asserts that
|
||||
# an one (and only one) @ exists in the given string. This is mainly
|
||||
# to give user feedback and not to assert the e-mail validity.
|
||||
# Email regex used to validate email formats. It asserts that there are no
|
||||
# @ symbols or whitespaces in either the localpart or the domain, and that
|
||||
# there is a single @ symbol separating the localpart and the domain.
|
||||
mattr_accessor :email_regexp
|
||||
@@email_regexp = /\A[^@\s]+@([^@\s]+\.)+[^@\W]+\z/
|
||||
@@email_regexp = /\A[^@\s]+@[^@\s]+\z/
|
||||
|
||||
# Range validation for password length
|
||||
mattr_accessor :password_length
|
||||
@@ -115,7 +115,6 @@ module Devise
|
||||
mattr_accessor :remember_for
|
||||
@@remember_for = 2.weeks
|
||||
|
||||
# TODO: extend_remember_period is no longer used
|
||||
# If true, extends the user's remember period when remembered via cookie.
|
||||
mattr_accessor :extend_remember_period
|
||||
@@extend_remember_period = false
|
||||
@@ -138,15 +137,14 @@ module Devise
|
||||
@@confirmation_keys = [:email]
|
||||
|
||||
# Defines if email should be reconfirmable.
|
||||
# False by default for backwards compatibility.
|
||||
mattr_accessor :reconfirmable
|
||||
@@reconfirmable = false
|
||||
@@reconfirmable = true
|
||||
|
||||
# Time interval to timeout the user session without activity.
|
||||
mattr_accessor :timeout_in
|
||||
@@timeout_in = 30.minutes
|
||||
|
||||
# Used to encrypt password. Please generate one with rake secret.
|
||||
# Used to hash the password. Please generate one with rake secret.
|
||||
mattr_accessor :pepper
|
||||
@@pepper = nil
|
||||
|
||||
@@ -203,7 +201,7 @@ module Devise
|
||||
|
||||
# Skip session storage for the following strategies
|
||||
mattr_accessor :skip_session_storage
|
||||
@@skip_session_storage = []
|
||||
@@skip_session_storage = [:http_auth]
|
||||
|
||||
# Which formats should be treated as navigational.
|
||||
mattr_accessor :navigational_formats
|
||||
@@ -215,7 +213,7 @@ module Devise
|
||||
|
||||
# The default method used while signing out
|
||||
mattr_accessor :sign_out_via
|
||||
@@sign_out_via = :get
|
||||
@@sign_out_via = :delete
|
||||
|
||||
# The parent controller all Devise controllers inherits from.
|
||||
# Defaults to ApplicationController. This should be set early
|
||||
@@ -276,7 +274,7 @@ module Devise
|
||||
mattr_accessor :token_generator
|
||||
@@token_generator = nil
|
||||
|
||||
# Default way to setup Devise. Run rails generate devise_install to create
|
||||
# Default way to set up Devise. Run rails generate devise_install to create
|
||||
# a fresh initializer with all configuration values.
|
||||
def self.setup
|
||||
yield self
|
||||
@@ -457,10 +455,7 @@ module Devise
|
||||
mapping.to.serialize_into_session(record)
|
||||
end
|
||||
|
||||
warden_config.serialize_from_session(mapping.name) do |key|
|
||||
# Previous versions contained an additional entry at the beginning of
|
||||
# key with the record's class name.
|
||||
args = key[-2, 2]
|
||||
warden_config.serialize_from_session(mapping.name) do |args|
|
||||
mapping.to.serialize_from_session(*args)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -150,7 +150,7 @@ module Devise
|
||||
is_a?(::DeviseController)
|
||||
end
|
||||
|
||||
# Setup a param sanitizer to filter parameters using strong_parameters. See
|
||||
# Set up a param sanitizer to filter parameters using strong_parameters. See
|
||||
# lib/devise/parameter_sanitizer.rb for more info. Override this
|
||||
# method in your application controller to use your own parameter sanitizer.
|
||||
def devise_parameter_sanitizer
|
||||
@@ -271,12 +271,6 @@ module Devise
|
||||
|
||||
private
|
||||
|
||||
def expire_session_data_after_sign_in!
|
||||
ActiveSupport::Deprecation.warn "expire_session_data_after_sign_in! is deprecated " \
|
||||
"in favor of expire_data_after_sign_in!"
|
||||
expire_data_after_sign_in!
|
||||
end
|
||||
|
||||
def expire_data_after_sign_out!
|
||||
Devise.mappings.each { |_,m| instance_variable_set("@current_#{m.name}", nil) }
|
||||
super
|
||||
|
||||
@@ -9,14 +9,14 @@ module Devise
|
||||
::BCrypt::Password.create(password, cost: klass.stretches).to_s
|
||||
end
|
||||
|
||||
def self.compare(klass, encrypted_password, password)
|
||||
return false if encrypted_password.blank?
|
||||
bcrypt = ::BCrypt::Password.new(encrypted_password)
|
||||
def self.compare(klass, hashed_password, password)
|
||||
return false if hashed_password.blank?
|
||||
bcrypt = ::BCrypt::Password.new(hashed_password)
|
||||
if klass.pepper.present?
|
||||
password = "#{password}#{klass.pepper}"
|
||||
end
|
||||
password = ::BCrypt::Engine.hash_secret(password, bcrypt.salt)
|
||||
Devise.secure_compare(password, encrypted_password)
|
||||
Devise.secure_compare(password, hashed_password)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -103,7 +103,7 @@ module Devise
|
||||
options[:scope] = "devise.failure"
|
||||
options[:default] = [message]
|
||||
auth_keys = scope_class.authentication_keys
|
||||
keys = auth_keys.respond_to?(:keys) ? auth_keys.keys : auth_keys
|
||||
keys = (auth_keys.respond_to?(:keys) ? auth_keys.keys : auth_keys).map { |key| scope_class.human_attribute_name(key) }
|
||||
options[:authentication_keys] = keys.join(I18n.translate(:"support.array.words_connector"))
|
||||
options = i18n_options(options)
|
||||
|
||||
@@ -140,11 +140,10 @@ module Devise
|
||||
|
||||
config = Rails.application.config
|
||||
|
||||
# Rails 4.2 goes into an infinite loop if opts[:script_name] is unset
|
||||
if (Rails::VERSION::MAJOR >= 4) && (Rails::VERSION::MINOR >= 2)
|
||||
opts[:script_name] = (config.relative_url_root if config.respond_to?(:relative_url_root))
|
||||
else
|
||||
if config.respond_to?(:relative_url_root) && config.relative_url_root.present?
|
||||
if config.respond_to?(:relative_url_root)
|
||||
# Rails 4.2 goes into an infinite loop if opts[:script_name] is unset
|
||||
rails_4_2 = (Rails::VERSION::MAJOR >= 4) && (Rails::VERSION::MINOR >= 2)
|
||||
if config.relative_url_root.present? || rails_4_2
|
||||
opts[:script_name] = config.relative_url_root
|
||||
end
|
||||
end
|
||||
|
||||
@@ -64,7 +64,7 @@ module Devise
|
||||
template_path
|
||||
end
|
||||
|
||||
# Setup a subject doing an I18n lookup. At first, it attempts to set a subject
|
||||
# Set up a subject doing an I18n lookup. At first, it attempts to set a subject
|
||||
# based on the current mapping:
|
||||
#
|
||||
# en:
|
||||
|
||||
@@ -253,7 +253,7 @@ module Devise
|
||||
|
||||
# Find or initialize a record with group of attributes based on a list of required attributes.
|
||||
def find_or_initialize_with_errors(required_attributes, attributes, error=:invalid) #:nodoc:
|
||||
attributes = if attributes.respond_to? :permit
|
||||
attributes = if attributes.respond_to? :permit!
|
||||
attributes.slice(*required_attributes).permit!.to_h.with_indifferent_access
|
||||
else
|
||||
attributes.with_indifferent_access.slice(*required_attributes)
|
||||
|
||||
@@ -24,7 +24,7 @@ module Devise
|
||||
# By default allow_unconfirmed_access_for is zero, it means users always have to confirm to sign in.
|
||||
# * +reconfirmable+: requires any email changes to be confirmed (exactly the same way as
|
||||
# initial account confirmation) to be applied. Requires additional unconfirmed_email
|
||||
# db field to be setup (t.reconfirmable in migrations). Until confirmed, new email is
|
||||
# db field to be set up (t.reconfirmable in migrations). Until confirmed, new email is
|
||||
# stored in unconfirmed email column, and copied to email column on successful
|
||||
# confirmation.
|
||||
# * +confirm_within+: the time before a sent confirmation token becomes invalid.
|
||||
@@ -43,9 +43,15 @@ module Devise
|
||||
|
||||
included do
|
||||
before_create :generate_confirmation_token, if: :confirmation_required?
|
||||
after_create :send_on_create_confirmation_instructions, if: :send_confirmation_notification?
|
||||
after_create :skip_reconfirmation!, if: :send_confirmation_notification?
|
||||
if respond_to?(:after_commit) # ActiveRecord
|
||||
after_commit :send_on_create_confirmation_instructions, on: :create, if: :send_confirmation_notification?
|
||||
after_commit :send_reconfirmation_instructions, on: :update, if: :reconfirmation_required?
|
||||
else # Mongoid
|
||||
after_create :send_on_create_confirmation_instructions, if: :send_confirmation_notification?
|
||||
after_update :send_reconfirmation_instructions, if: :reconfirmation_required?
|
||||
end
|
||||
before_update :postpone_email_change_until_confirmation_and_regenerate_confirmation_token, if: :postpone_email_change?
|
||||
after_update :send_reconfirmation_instructions, if: :reconfirmation_required?
|
||||
end
|
||||
|
||||
def initialize(*args, &block)
|
||||
@@ -75,7 +81,7 @@ module Devise
|
||||
|
||||
self.confirmed_at = Time.now.utc
|
||||
|
||||
saved = if self.class.reconfirmable && unconfirmed_email.present?
|
||||
saved = if pending_reconfirmation?
|
||||
skip_reconfirmation!
|
||||
self.email = unconfirmed_email
|
||||
self.unconfirmed_email = nil
|
||||
@@ -179,7 +185,7 @@ module Devise
|
||||
# Checks if the confirmation for the user is within the limit time.
|
||||
# We do this by calculating if the difference between today and the
|
||||
# confirmation sent date does not exceed the confirm in time configured.
|
||||
# Confirm_within is a model configuration, must always be an integer value.
|
||||
# allow_unconfirmed_access_for is a model configuration, must always be an integer value.
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
@@ -234,8 +240,7 @@ module Devise
|
||||
if self.confirmation_token && !confirmation_period_expired?
|
||||
@raw_confirmation_token = self.confirmation_token
|
||||
else
|
||||
raw, _ = Devise.token_generator.generate(self.class, :confirmation_token)
|
||||
self.confirmation_token = @raw_confirmation_token = raw
|
||||
self.confirmation_token = @raw_confirmation_token = Devise.friendly_token
|
||||
self.confirmation_sent_at = Time.now.utc
|
||||
end
|
||||
end
|
||||
@@ -253,13 +258,13 @@ module Devise
|
||||
end
|
||||
|
||||
def postpone_email_change?
|
||||
postpone = self.class.reconfirmable && email_changed? && email_was.present? && !@bypass_confirmation_postpone && self.email.present?
|
||||
postpone = self.class.reconfirmable && email_changed? && !@bypass_confirmation_postpone && self.email.present?
|
||||
@bypass_confirmation_postpone = false
|
||||
postpone
|
||||
end
|
||||
|
||||
def reconfirmation_required?
|
||||
self.class.reconfirmable && @reconfirmation_required && self.email.present?
|
||||
self.class.reconfirmable && @reconfirmation_required && (self.email.present? || self.unconfirmed_email.present?)
|
||||
end
|
||||
|
||||
def send_confirmation_notification?
|
||||
|
||||
@@ -7,8 +7,8 @@ module Devise
|
||||
end
|
||||
|
||||
module Models
|
||||
# Authenticatable Module, responsible for encrypting password and validating
|
||||
# authenticity of a user while signing in.
|
||||
# Authenticatable Module, responsible for hashing the password and
|
||||
# validating the authenticity of a user while signing in.
|
||||
#
|
||||
# == Options
|
||||
#
|
||||
@@ -37,9 +37,10 @@ module Devise
|
||||
[:encrypted_password] + klass.authentication_keys
|
||||
end
|
||||
|
||||
# Generates password encryption based on the given value.
|
||||
# Generates a hashed password based on the given value.
|
||||
# For legacy reasons, we use `encrypted_password` to store
|
||||
# the hashed password.
|
||||
def password=(new_password)
|
||||
attribute_will_change! 'password'
|
||||
@password = new_password
|
||||
self.encrypted_password = password_digest(@password) if @password.present?
|
||||
end
|
||||
@@ -142,11 +143,11 @@ module Devise
|
||||
|
||||
protected
|
||||
|
||||
# Digests the password using bcrypt. Custom encryption should override
|
||||
# Hashes the password using bcrypt. Custom hash functions should override
|
||||
# this method to apply their own algorithm.
|
||||
#
|
||||
# See https://github.com/plataformatec/devise-encryptable for examples
|
||||
# of other encryption engines.
|
||||
# of other hashing engines.
|
||||
def password_digest(password)
|
||||
Devise::Encryptor.digest(self.class, password)
|
||||
end
|
||||
|
||||
@@ -7,7 +7,7 @@ module Devise
|
||||
# blocked: email and time. The former will send an email to the user when
|
||||
# the lock happens, containing a link to unlock its account. The second
|
||||
# will unlock the user automatically after some configured time (ie 2.hours).
|
||||
# It's also possible to setup lockable to use both email and time strategies.
|
||||
# It's also possible to set up lockable to use both email and time strategies.
|
||||
#
|
||||
# == Options
|
||||
#
|
||||
@@ -64,7 +64,7 @@ module Devise
|
||||
def send_unlock_instructions
|
||||
raw, enc = Devise.token_generator.generate(self.class, :unlock_token)
|
||||
self.unlock_token = enc
|
||||
self.save(validate: false)
|
||||
save(validate: false)
|
||||
send_devise_notification(:unlock_instructions, raw, {})
|
||||
raw
|
||||
end
|
||||
@@ -155,6 +155,9 @@ module Devise
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
# List of strategies that are enabled/supported if :both is used.
|
||||
BOTH_STRATEGIES = [:time, :email]
|
||||
|
||||
# Attempt to find a user by its unlock keys. If a record is found, send new
|
||||
# unlock instructions to it. If not user is found, returns a new user
|
||||
# with an email not found error.
|
||||
@@ -181,7 +184,8 @@ module Devise
|
||||
|
||||
# Is the unlock enabled for the given unlock strategy?
|
||||
def unlock_strategy_enabled?(strategy)
|
||||
[:both, strategy].include?(self.unlock_strategy)
|
||||
self.unlock_strategy == strategy ||
|
||||
(self.unlock_strategy == :both && BOTH_STRATEGIES.include?(strategy))
|
||||
end
|
||||
|
||||
# Is the lock enabled for the given lock strategy?
|
||||
|
||||
@@ -99,7 +99,7 @@ module Devise
|
||||
|
||||
self.reset_password_token = enc
|
||||
self.reset_password_sent_at = Time.now.utc
|
||||
self.save(validate: false)
|
||||
save(validate: false)
|
||||
raw
|
||||
end
|
||||
|
||||
|
||||
@@ -39,16 +39,14 @@ module Devise
|
||||
module Rememberable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
attr_accessor :remember_me, :extend_remember_period
|
||||
attr_accessor :remember_me
|
||||
|
||||
def self.required_fields(klass)
|
||||
[:remember_created_at]
|
||||
end
|
||||
|
||||
# TODO: We were used to receive a extend period argument but we no longer do.
|
||||
# Remove this for Devise 4.0.
|
||||
def remember_me!(*)
|
||||
self.remember_token = self.class.remember_token if respond_to?(:remember_token)
|
||||
def remember_me!
|
||||
self.remember_token ||= self.class.remember_token if respond_to?(:remember_token)
|
||||
self.remember_created_at ||= Time.now.utc
|
||||
save(validate: false) if self.changed?
|
||||
end
|
||||
@@ -66,6 +64,10 @@ module Devise
|
||||
self.class.remember_for.from_now
|
||||
end
|
||||
|
||||
def extend_remember_period
|
||||
self.class.extend_remember_period
|
||||
end
|
||||
|
||||
def rememberable_value
|
||||
if respond_to?(:remember_token)
|
||||
remember_token
|
||||
@@ -147,9 +149,6 @@ module Devise
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# TODO: extend_remember_period is no longer used
|
||||
Devise::Models.config(self, :remember_for, :extend_remember_period, :rememberable_options, :expire_all_remember_me_on_sign_out)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,16 +2,74 @@ module Devise
|
||||
module OmniAuth
|
||||
module UrlHelpers
|
||||
def self.define_helpers(mapping)
|
||||
return unless mapping.omniauthable?
|
||||
|
||||
mapping = mapping.name
|
||||
|
||||
class_eval do
|
||||
define_method("#{mapping}_omniauth_authorize_path") do |provider, *args|
|
||||
ActiveSupport::Deprecation.warn(<<-DEPRECATION.strip_heredoc)
|
||||
[Devise] #{mapping}_omniauth_authorize_path(#{provider.inspect}) is deprecated and it will be removed from Devise 4.2.
|
||||
|
||||
Please use #{mapping}_#{provider}_omniauth_authorize_path instead.
|
||||
DEPRECATION
|
||||
send("#{mapping}_#{provider}_omniauth_authorize_path", *args)
|
||||
end
|
||||
|
||||
define_method("#{mapping}_omniauth_authorize_url") do |provider, *args|
|
||||
ActiveSupport::Deprecation.warn(<<-DEPRECATION.strip_heredoc)
|
||||
[Devise] #{mapping}_omniauth_authorize_url(#{provider.inspect}) is deprecated and it will be removed from Devise 4.2.
|
||||
|
||||
Please use #{mapping}_#{provider}_omniauth_authorize_url instead.
|
||||
DEPRECATION
|
||||
send("#{mapping}_#{provider}_omniauth_authorize_url", *args)
|
||||
end
|
||||
|
||||
define_method("#{mapping}_omniauth_callback_path") do |provider, *args|
|
||||
ActiveSupport::Deprecation.warn(<<-DEPRECATION.strip_heredoc)
|
||||
[Devise] #{mapping}_omniauth_callback_path(#{provider.inspect}) is deprecated and it will be removed from Devise 4.2.
|
||||
|
||||
Please use #{mapping}_#{provider}_omniauth_callback_path instead.
|
||||
DEPRECATION
|
||||
send("#{mapping}_#{provider}_omniauth_callback_path", *args)
|
||||
end
|
||||
|
||||
define_method("#{mapping}_omniauth_callback_url") do |provider, *args|
|
||||
ActiveSupport::Deprecation.warn(<<-DEPRECATION.strip_heredoc)
|
||||
[Devise] #{mapping}_omniauth_callback_url(#{provider.inspect}) is deprecated and it will be removed from Devise 4.2.
|
||||
|
||||
Please use #{mapping}_#{provider}_omniauth_callback_url instead.
|
||||
DEPRECATION
|
||||
send("#{mapping}_#{provider}_omniauth_callback_url", *args)
|
||||
end
|
||||
end
|
||||
|
||||
ActiveSupport.on_load(:action_controller) do
|
||||
if respond_to?(:helper_method)
|
||||
helper_method "#{mapping}_omniauth_authorize_path", "#{mapping}_omniauth_authorize_url"
|
||||
helper_method "#{mapping}_omniauth_callback_path", "#{mapping}_omniauth_callback_url"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def omniauth_authorize_path(resource_or_scope, *args)
|
||||
def omniauth_authorize_path(resource_or_scope, provider, *args)
|
||||
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
||||
_devise_route_context.send("#{scope}_omniauth_authorize_path", *args)
|
||||
_devise_route_context.send("#{scope}_#{provider}_omniauth_authorize_path", *args)
|
||||
end
|
||||
|
||||
def omniauth_callback_path(resource_or_scope, *args)
|
||||
def omniauth_authorize_url(resource_or_scope, provider, *args)
|
||||
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
||||
_devise_route_context.send("#{scope}_omniauth_callback_path", *args)
|
||||
_devise_route_context.send("#{scope}_#{provider}_omniauth_authorize_url", *args)
|
||||
end
|
||||
|
||||
def omniauth_callback_path(resource_or_scope, provider, *args)
|
||||
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
||||
_devise_route_context.send("#{scope}_#{provider}_omniauth_callback_path", *args)
|
||||
end
|
||||
|
||||
def omniauth_callback_url(resource_or_scope, provider, *args)
|
||||
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
||||
_devise_route_context.send("#{scope}_#{provider}_omniauth_callback_url", *args)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -68,7 +68,7 @@ module Devise
|
||||
def sanitize(action)
|
||||
permissions = @permitted[action]
|
||||
|
||||
# DEPRECATED: Remove this branch on Devise 4.1.
|
||||
# DEPRECATED: Remove this branch on Devise 4.2.
|
||||
if respond_to?(action, true)
|
||||
deprecate_instance_method_sanitization(action)
|
||||
return cast_to_hash send(action)
|
||||
@@ -127,7 +127,7 @@ module Devise
|
||||
end
|
||||
end
|
||||
|
||||
# DEPRECATED: Remove this method on Devise 4.1.
|
||||
# DEPRECATED: Remove this method on Devise 4.2.
|
||||
def for(action, &block) # :nodoc:
|
||||
if block_given?
|
||||
deprecate_for_with_block(action)
|
||||
@@ -169,13 +169,13 @@ module Devise
|
||||
If you want to define a new set of parameters to be sanitized use the
|
||||
`permit` method first:
|
||||
|
||||
devise_parameter_sanitizer.permit(:#{action}, keys: [:param1, param2, param3])
|
||||
devise_parameter_sanitizer.permit(:#{action}, keys: [:param1, :param2, :param3])
|
||||
MESSAGE
|
||||
end
|
||||
|
||||
def deprecate_for_with_block(action)
|
||||
ActiveSupport::Deprecation.warn(<<-MESSAGE.strip_heredoc)
|
||||
[Devise] Changing the sanitized parameters through "#{self.class.name}#for(#{action}) is deprecated and it will be removed from Devise 4.1.
|
||||
[Devise] Changing the sanitized parameters through "#{self.class.name}#for(#{action}) is deprecated and it will be removed from Devise 4.2.
|
||||
Please use the `permit` method:
|
||||
|
||||
devise_parameter_sanitizer.permit(:#{action}) do |user|
|
||||
@@ -186,7 +186,7 @@ module Devise
|
||||
|
||||
def deprecate_for_without_block(action)
|
||||
ActiveSupport::Deprecation.warn(<<-MESSAGE.strip_heredoc)
|
||||
[Devise] Changing the sanitized parameters through "#{self.class.name}#for(#{action}) is deprecated and it will be removed from Devise 4.1.
|
||||
[Devise] Changing the sanitized parameters through "#{self.class.name}#for(#{action}) is deprecated and it will be removed from Devise 4.2.
|
||||
Please use the `permit` method to add or remove any key:
|
||||
|
||||
To add any new key, use the `keys` keyword argument:
|
||||
@@ -199,7 +199,7 @@ module Devise
|
||||
|
||||
def deprecate_instance_method_sanitization(action)
|
||||
ActiveSupport::Deprecation.warn(<<-MESSAGE.strip_heredoc)
|
||||
[Devise] Parameter sanitization through a "#{self.class.name}##{action}" method is deprecated and it will be removed from Devise 4.1.
|
||||
[Devise] Parameter sanitization through a "#{self.class.name}##{action}" method is deprecated and it will be removed from Devise 4.2.
|
||||
Please use the `permit` method on your sanitizer `initialize` method.
|
||||
|
||||
class #{self.class.name} < Devise::ParameterSanitizer
|
||||
|
||||
@@ -87,17 +87,17 @@ module ActionDispatch::Routing
|
||||
#
|
||||
# You can configure your routes with some options:
|
||||
#
|
||||
# * class_name: setup a different class to be looked up by devise, if it cannot be
|
||||
# * class_name: set up a different class to be looked up by devise, if it cannot be
|
||||
# properly found by the route name.
|
||||
#
|
||||
# devise_for :users, class_name: 'Account'
|
||||
#
|
||||
# * path: allows you to setup path name that will be used, as rails routes does.
|
||||
# The following route configuration would setup your route as /accounts instead of /users:
|
||||
# * path: allows you to set up path name that will be used, as rails routes does.
|
||||
# The following route configuration would set up your route as /accounts instead of /users:
|
||||
#
|
||||
# devise_for :users, path: 'accounts'
|
||||
#
|
||||
# * singular: setup the singular name for the given resource. This is used as the helper methods
|
||||
# * singular: set up the singular name for the given resource. This is used as the helper methods
|
||||
# names in controller ("authenticate_#{singular}!", "#{singular}_signed_in?", "current_#{singular}"
|
||||
# and "#{singular}_session"), as the scope name in routes and as the scope given to warden.
|
||||
#
|
||||
@@ -441,19 +441,17 @@ ERROR
|
||||
|
||||
set_omniauth_path_prefix!(path_prefix)
|
||||
|
||||
providers = Regexp.union(mapping.to.omniauth_providers.map(&:to_s))
|
||||
mapping.to.omniauth_providers.each do |provider|
|
||||
match "#{path_prefix}/#{provider}",
|
||||
to: "#{controllers[:omniauth_callbacks]}#passthru",
|
||||
as: "#{provider}_omniauth_authorize",
|
||||
via: [:get, :post]
|
||||
|
||||
match "#{path_prefix}/:provider",
|
||||
constraints: { provider: providers },
|
||||
to: "#{controllers[:omniauth_callbacks]}#passthru",
|
||||
as: :omniauth_authorize,
|
||||
via: [:get, :post]
|
||||
|
||||
match "#{path_prefix}/:action/callback",
|
||||
constraints: { action: providers },
|
||||
to: "#{controllers[:omniauth_callbacks]}#:action",
|
||||
as: :omniauth_callback,
|
||||
via: [:get, :post]
|
||||
match "#{path_prefix}/#{provider}/callback",
|
||||
to: "#{controllers[:omniauth_callbacks]}##{provider}",
|
||||
as: "#{provider}_omniauth_callback",
|
||||
via: [:get, :post]
|
||||
end
|
||||
ensure
|
||||
@scope = current_scope
|
||||
end
|
||||
|
||||
@@ -6,15 +6,15 @@ module Devise
|
||||
class DatabaseAuthenticatable < Authenticatable
|
||||
def authenticate!
|
||||
resource = password.present? && mapping.to.find_for_database_authentication(authentication_hash)
|
||||
encrypted = false
|
||||
hashed = false
|
||||
|
||||
if validate(resource){ encrypted = true; resource.valid_password?(password) }
|
||||
if validate(resource){ hashed = true; resource.valid_password?(password) }
|
||||
remember_me(resource)
|
||||
resource.after_database_authentication
|
||||
success!(resource)
|
||||
end
|
||||
|
||||
mapping.to.new.password = password if !encrypted && Devise.paranoid
|
||||
mapping.to.new.password = password if !hashed && Devise.paranoid
|
||||
fail(:not_found_in_database) unless resource
|
||||
end
|
||||
end
|
||||
|
||||
@@ -25,8 +25,7 @@ module Devise
|
||||
end
|
||||
|
||||
if validate(resource)
|
||||
remember_me(resource)
|
||||
extend_remember_me_period(resource)
|
||||
remember_me(resource) if extend_remember_me?(resource)
|
||||
resource.after_remembered
|
||||
success!(resource)
|
||||
end
|
||||
@@ -43,10 +42,8 @@ module Devise
|
||||
|
||||
private
|
||||
|
||||
def extend_remember_me_period(resource)
|
||||
if resource.respond_to?(:extend_remember_period=)
|
||||
resource.extend_remember_period = mapping.to.extend_remember_period
|
||||
end
|
||||
def extend_remember_me?(resource)
|
||||
resource.respond_to?(:extend_remember_period) && resource.extend_remember_period
|
||||
end
|
||||
|
||||
def remember_me?
|
||||
|
||||
@@ -22,7 +22,7 @@ module Devise
|
||||
@response
|
||||
end
|
||||
|
||||
# We need to setup the environment variables and the response in the controller.
|
||||
# We need to set up the environment variables and the response in the controller.
|
||||
def setup_controller_for_warden #:nodoc:
|
||||
@request.env['action_controller.instance'] = @controller
|
||||
end
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
module Devise
|
||||
VERSION = "4.0.0.rc1".freeze
|
||||
VERSION = "4.1.1".freeze
|
||||
end
|
||||
|
||||
@@ -11,9 +11,9 @@ module ActiveRecord
|
||||
|
||||
def copy_devise_migration
|
||||
if (behavior == :invoke && model_exists?) || (behavior == :revoke && migration_exists?(table_name))
|
||||
migration_template "migration_existing.rb", "db/migrate/add_devise_to_#{table_name}.rb"
|
||||
migration_template "migration_existing.rb", "db/migrate/add_devise_to_#{table_name}.rb", migration_version: migration_version
|
||||
else
|
||||
migration_template "migration.rb", "db/migrate/devise_create_#{table_name}.rb"
|
||||
migration_template "migration.rb", "db/migrate/devise_create_#{table_name}.rb", migration_version: migration_version
|
||||
end
|
||||
end
|
||||
|
||||
@@ -86,6 +86,12 @@ RUBY
|
||||
config = ActiveRecord::Base.configurations[Rails.env]
|
||||
config && config['adapter'] == 'postgresql'
|
||||
end
|
||||
|
||||
def migration_version
|
||||
if rails5?
|
||||
"[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class DeviseCreate<%= table_name.camelize %> < ActiveRecord::Migration
|
||||
class DeviseCreate<%= table_name.camelize %> < ActiveRecord::Migration<%= migration_version %>
|
||||
def change
|
||||
create_table :<%= table_name %> do |t|
|
||||
<%= migration_data -%>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class AddDeviseTo<%= table_name.camelize %> < ActiveRecord::Migration
|
||||
class AddDeviseTo<%= table_name.camelize %> < ActiveRecord::Migration<%= migration_version %>
|
||||
def self.up
|
||||
change_table :<%= table_name %> do |t|
|
||||
<%= migration_data -%>
|
||||
|
||||
@@ -3,6 +3,8 @@ require 'securerandom'
|
||||
|
||||
module Devise
|
||||
module Generators
|
||||
MissingORMError = Class.new(Thor::Error)
|
||||
|
||||
class InstallGenerator < Rails::Generators::Base
|
||||
source_root File.expand_path("../../templates", __FILE__)
|
||||
|
||||
@@ -10,6 +12,19 @@ module Devise
|
||||
class_option :orm
|
||||
|
||||
def copy_initializer
|
||||
unless options[:orm]
|
||||
raise MissingORMError, <<-ERROR.strip_heredoc
|
||||
An ORM must be set to install Devise in your application.
|
||||
|
||||
Be sure to have an ORM like Active Record or Mongoid loaded in your
|
||||
app or configure your own at `config/application.rb`.
|
||||
|
||||
config.generators do |g|
|
||||
g.orm :your_orm_gem
|
||||
end
|
||||
ERROR
|
||||
end
|
||||
|
||||
template "devise.rb", "config/initializers/devise.rb"
|
||||
end
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ CONTENT
|
||||
private
|
||||
|
||||
def model_exists?
|
||||
File.exists?(File.join(destination_root, model_path))
|
||||
File.exist?(File.join(destination_root, model_path))
|
||||
end
|
||||
|
||||
def migration_exists?(table_name)
|
||||
|
||||
24
lib/generators/templates/devise.rb
Normal file → Executable file
24
lib/generators/templates/devise.rb
Normal file → Executable file
@@ -91,17 +91,17 @@ Devise.setup do |config|
|
||||
# config.clean_up_csrf_token_on_authentication = true
|
||||
|
||||
# ==> Configuration for :database_authenticatable
|
||||
# For bcrypt, this is the cost for hashing the password and defaults to 10. If
|
||||
# using other encryptors, it sets how many times you want the password re-encrypted.
|
||||
# For bcrypt, this is the cost for hashing the password and defaults to 11. If
|
||||
# using other algorithms, it sets how many times you want the password to be hashed.
|
||||
#
|
||||
# Limiting the stretches to just one in testing will increase the performance of
|
||||
# your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
|
||||
# a value less than 10 in other environments. Note that, for bcrypt (the default
|
||||
# encryptor), the cost increases exponentially with the number of stretches (e.g.
|
||||
# algorithm), the cost increases exponentially with the number of stretches (e.g.
|
||||
# a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
|
||||
config.stretches = Rails.env.test? ? 1 : 10
|
||||
config.stretches = Rails.env.test? ? 1 : 11
|
||||
|
||||
# Setup a pepper to generate the encrypted password.
|
||||
# Set up a pepper to generate the hashed password.
|
||||
# config.pepper = '<%= SecureRandom.hex(64) %>'
|
||||
|
||||
# Send a notification email when the user's password is changed
|
||||
@@ -148,12 +148,12 @@ Devise.setup do |config|
|
||||
|
||||
# ==> Configuration for :validatable
|
||||
# Range for password length.
|
||||
config.password_length = 8..72
|
||||
config.password_length = 6..128
|
||||
|
||||
# Email regex used to validate email formats. It simply asserts that
|
||||
# one (and only one) @ exists in the given string. This is mainly
|
||||
# to give user feedback and not to assert the e-mail validity.
|
||||
# config.email_regexp = /\A[^@]+@[^@]+\z/
|
||||
config.email_regexp = /\A[^@\s]+@[^@\s]+\z/
|
||||
|
||||
# ==> Configuration for :timeoutable
|
||||
# The time you want to timeout the user session without activity. After this
|
||||
@@ -201,11 +201,11 @@ Devise.setup do |config|
|
||||
# config.sign_in_after_reset_password = true
|
||||
|
||||
# ==> Configuration for :encryptable
|
||||
# Allow you to use another encryption algorithm besides bcrypt (default). You can use
|
||||
# :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
|
||||
# :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
|
||||
# and :restful_authentication_sha1 (then you should set stretches to 10, and copy
|
||||
# REST_AUTH_SITE_KEY to pepper).
|
||||
# Allow you to use another hashing or encryption algorithm besides bcrypt (default).
|
||||
# You can use :sha1, :sha512 or algorithms from others authentication tools as
|
||||
# :clearance_sha1, :authlogic_sha512 (then you should set stretches above to 20
|
||||
# for default behavior) and :restful_authentication_sha1 (then you should set
|
||||
# stretches to 10, and copy REST_AUTH_SITE_KEY to pepper).
|
||||
#
|
||||
# Require the `devise-encryptable` gem when using anything other than bcrypt
|
||||
# config.encryptor = :sha512
|
||||
|
||||
@@ -6,7 +6,7 @@ class SessionsControllerTest < Devise::ControllerTestCase
|
||||
|
||||
test "#create doesn't raise unpermitted params when sign in fails" do
|
||||
begin
|
||||
subscriber = ActiveSupport::Notifications.subscribe /unpermitted_parameters/ do |name, start, finish, id, payload|
|
||||
subscriber = ActiveSupport::Notifications.subscribe %r{unpermitted_parameters} do |name, start, finish, id, payload|
|
||||
flunk "Unpermitted params: #{payload}"
|
||||
end
|
||||
request.env["devise.mapping"] = Devise.mappings[:user]
|
||||
|
||||
4
test/devise_test.rb
Normal file → Executable file
4
test/devise_test.rb
Normal file → Executable file
@@ -94,8 +94,8 @@ class DeviseTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
test 'Devise.email_regexp should match valid email addresses' do
|
||||
valid_emails = ["test@example.com", "jo@jo.co", "f4$_m@you.com", "testing.example@example.com.ua"]
|
||||
non_valid_emails = ["rex", "test@go,com", "test user@example.com", "test_user@example server.com", "test_user@example.com."]
|
||||
valid_emails = ["test@example.com", "jo@jo.co", "f4$_m@you.com", "testing.example@example.com.ua", "test@tt", "test@valid---domain.com"]
|
||||
non_valid_emails = ["rex", "test user@example.com", "test_user@example server.com"]
|
||||
|
||||
valid_emails.each do |email|
|
||||
assert_match Devise.email_regexp, email
|
||||
|
||||
@@ -133,14 +133,14 @@ class FailureTest < ActiveSupport::TestCase
|
||||
|
||||
test 'uses the proxy failure message as symbol' do
|
||||
call_failure('warden' => OpenStruct.new(message: :invalid))
|
||||
assert_equal 'Invalid email or password.', @request.flash[:alert]
|
||||
assert_equal 'Invalid Email or password.', @request.flash[:alert]
|
||||
assert_equal 'http://test.host/users/sign_in', @response.second["Location"]
|
||||
end
|
||||
|
||||
test 'supports authentication_keys as a Hash for the flash message' do
|
||||
swap Devise, authentication_keys: { email: true, login: true } do
|
||||
call_failure('warden' => OpenStruct.new(message: :invalid))
|
||||
assert_equal 'Invalid email, login or password.', @request.flash[:alert]
|
||||
assert_equal 'Invalid Email, Login or password.', @request.flash[:alert]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -160,7 +160,7 @@ class FailureTest < ActiveSupport::TestCase
|
||||
assert_equal 'text/html; charset=utf-8', @response.second['Content-Type']
|
||||
end
|
||||
|
||||
test 'setup a default message' do
|
||||
test 'set up a default message' do
|
||||
call_failure
|
||||
assert_match(/You are being/, @response.last.body)
|
||||
assert_match(/redirected/, @response.last.body)
|
||||
@@ -226,7 +226,7 @@ class FailureTest < ActiveSupport::TestCase
|
||||
|
||||
test 'uses the failure message as response body' do
|
||||
call_failure('formats' => Mime[:xml], 'warden' => OpenStruct.new(message: :invalid))
|
||||
assert_match '<error>Invalid email or password.</error>', @response.third.body
|
||||
assert_match '<error>Invalid Email or password.</error>', @response.third.body
|
||||
end
|
||||
|
||||
context 'on ajax call' do
|
||||
@@ -275,7 +275,7 @@ class FailureTest < ActiveSupport::TestCase
|
||||
}
|
||||
call_failure(env)
|
||||
assert @response.third.body.include?('<h2>Log in</h2>')
|
||||
assert @response.third.body.include?('Invalid email or password.')
|
||||
assert @response.third.body.include?('Invalid Email or password.')
|
||||
end
|
||||
|
||||
test 'calls the original controller if not confirmed email' do
|
||||
@@ -310,7 +310,7 @@ class FailureTest < ActiveSupport::TestCase
|
||||
}
|
||||
call_failure(env)
|
||||
assert @response.third.body.include?('<h2>Log in</h2>')
|
||||
assert @response.third.body.include?('Invalid email or password.')
|
||||
assert @response.third.body.include?('Invalid Email or password.')
|
||||
assert_equal @request.env["SCRIPT_NAME"], '/sample'
|
||||
assert_equal @request.env["PATH_INFO"], '/users/sign_in'
|
||||
end
|
||||
|
||||
@@ -74,7 +74,7 @@ if DEVISE_ORM == :active_record
|
||||
|
||||
assert_file "app/models/rails_engine/monster.rb", /devise/
|
||||
assert_file "app/models/rails_engine/monster.rb" do |content|
|
||||
assert_no_match /attr_accessible :email/, content
|
||||
assert_no_match %r{attr_accessible :email}, content
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,9 +5,20 @@ class InstallGeneratorTest < Rails::Generators::TestCase
|
||||
destination File.expand_path("../../tmp", __FILE__)
|
||||
setup :prepare_destination
|
||||
|
||||
test "Assert all files are properly created" do
|
||||
run_generator
|
||||
assert_file "config/initializers/devise.rb"
|
||||
test "assert all files are properly created" do
|
||||
run_generator(["--orm=active_record"])
|
||||
assert_file "config/initializers/devise.rb", /devise\/orm\/active_record/
|
||||
assert_file "config/locales/devise.en.yml"
|
||||
end
|
||||
|
||||
test "fails if no ORM is specified" do
|
||||
stderr = capture(:stderr) do
|
||||
run_generator
|
||||
end
|
||||
|
||||
assert_match %r{An ORM must be set to install Devise}, stderr
|
||||
|
||||
assert_no_file "config/initializers/devise.rb"
|
||||
assert_no_file "config/locales/devise.en.yml"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -30,7 +30,7 @@ class AuthenticationSanityTest < Devise::IntegrationTest
|
||||
swap Devise, sign_out_all_scopes: false do
|
||||
sign_in_as_user
|
||||
sign_in_as_admin
|
||||
get destroy_user_session_path
|
||||
delete destroy_user_session_path
|
||||
assert_not warden.authenticated?(:user)
|
||||
assert warden.authenticated?(:admin)
|
||||
end
|
||||
@@ -41,7 +41,7 @@ class AuthenticationSanityTest < Devise::IntegrationTest
|
||||
sign_in_as_user
|
||||
sign_in_as_admin
|
||||
|
||||
get destroy_admin_session_path
|
||||
delete destroy_admin_session_path
|
||||
assert_not warden.authenticated?(:admin)
|
||||
assert warden.authenticated?(:user)
|
||||
end
|
||||
@@ -52,7 +52,7 @@ class AuthenticationSanityTest < Devise::IntegrationTest
|
||||
sign_in_as_user
|
||||
sign_in_as_admin
|
||||
|
||||
get destroy_user_session_path
|
||||
delete destroy_user_session_path
|
||||
assert_not warden.authenticated?(:user)
|
||||
assert_not warden.authenticated?(:admin)
|
||||
end
|
||||
@@ -63,7 +63,7 @@ class AuthenticationSanityTest < Devise::IntegrationTest
|
||||
sign_in_as_user
|
||||
sign_in_as_admin
|
||||
|
||||
get destroy_admin_session_path
|
||||
delete destroy_admin_session_path
|
||||
assert_not warden.authenticated?(:admin)
|
||||
assert_not warden.authenticated?(:user)
|
||||
end
|
||||
@@ -109,7 +109,7 @@ class AuthenticationSanityTest < Devise::IntegrationTest
|
||||
sign_in_as_admin
|
||||
assert warden.authenticated?(:admin)
|
||||
|
||||
get destroy_admin_session_path
|
||||
delete destroy_admin_session_path
|
||||
assert_response :redirect
|
||||
assert_redirected_to root_path
|
||||
|
||||
@@ -119,7 +119,7 @@ class AuthenticationSanityTest < Devise::IntegrationTest
|
||||
end
|
||||
|
||||
test 'unauthenticated admin set message on sign out' do
|
||||
get destroy_admin_session_path
|
||||
delete destroy_admin_session_path
|
||||
assert_response :redirect
|
||||
assert_redirected_to root_path
|
||||
|
||||
@@ -347,37 +347,6 @@ class AuthenticationSessionTest < Devise::IntegrationTest
|
||||
assert_equal "Cart", @controller.user_session[:cart]
|
||||
end
|
||||
|
||||
test 'does not explode when class name is still stored in session' do
|
||||
# In order to test that old sessions do not break with the new scoped
|
||||
# deserialization, we need to serialize the session the old way. This is
|
||||
# done by removing the newly used scoped serialization method
|
||||
# (#user_serialize) and bringing back the old uncsoped #serialize method
|
||||
# that includes the record's class name in the serialization.
|
||||
begin
|
||||
Warden::SessionSerializer.class_eval do
|
||||
alias_method :original_serialize, :serialize
|
||||
alias_method :original_user_serialize, :user_serialize
|
||||
remove_method :user_serialize
|
||||
|
||||
def serialize(record)
|
||||
klass = record.class
|
||||
array = klass.serialize_into_session(record)
|
||||
array.unshift(klass.name)
|
||||
end
|
||||
end
|
||||
|
||||
sign_in_as_user
|
||||
assert warden.authenticated?(:user)
|
||||
ensure
|
||||
Warden::SessionSerializer.class_eval do
|
||||
alias_method :serialize, :original_serialize
|
||||
remove_method :original_serialize
|
||||
alias_method :user_serialize, :original_user_serialize
|
||||
remove_method :original_user_serialize
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
test 'session id is changed on sign in' do
|
||||
get '/users'
|
||||
session_id = request.session["session_id"]
|
||||
@@ -396,7 +365,7 @@ class AuthenticationWithScopedViewsTest < Devise::IntegrationTest
|
||||
assert_raise Webrat::NotFoundError do
|
||||
sign_in_as_user
|
||||
end
|
||||
assert_match /Special user view/, response.body
|
||||
assert_match %r{Special user view}, response.body
|
||||
end
|
||||
end
|
||||
|
||||
@@ -407,7 +376,7 @@ class AuthenticationWithScopedViewsTest < Devise::IntegrationTest
|
||||
sign_in_as_user
|
||||
end
|
||||
|
||||
assert_match /Special user view/, response.body
|
||||
assert_match %r{Special user view}, response.body
|
||||
assert !Devise::PasswordsController.scoped_views?
|
||||
ensure
|
||||
Devise::SessionsController.send :remove_instance_variable, :@scoped_views
|
||||
@@ -480,7 +449,7 @@ class AuthenticationOthersTest < Devise::IntegrationTest
|
||||
test 'sign in stub in xml format' do
|
||||
get new_user_session_path(format: 'xml')
|
||||
assert_match '<?xml version="1.0" encoding="UTF-8"?>', response.body
|
||||
assert_match /<user>.*<\/user>/m, response.body
|
||||
assert_match %r{<user>.*</user>}m, response.body
|
||||
assert_match '<email></email>', response.body
|
||||
assert_match '<password nil="true"', response.body
|
||||
end
|
||||
@@ -532,34 +501,34 @@ class AuthenticationOthersTest < Devise::IntegrationTest
|
||||
|
||||
test 'sign out with html redirects' do
|
||||
sign_in_as_user
|
||||
get destroy_user_session_path
|
||||
delete destroy_user_session_path
|
||||
assert_response :redirect
|
||||
assert_current_url '/'
|
||||
|
||||
sign_in_as_user
|
||||
get destroy_user_session_path(format: 'html')
|
||||
delete destroy_user_session_path(format: 'html')
|
||||
assert_response :redirect
|
||||
assert_current_url '/'
|
||||
end
|
||||
|
||||
test 'sign out with xml format returns no content' do
|
||||
sign_in_as_user
|
||||
get destroy_user_session_path(format: 'xml')
|
||||
delete destroy_user_session_path(format: 'xml')
|
||||
assert_response :no_content
|
||||
assert_not warden.authenticated?(:user)
|
||||
end
|
||||
|
||||
test 'sign out with json format returns no content' do
|
||||
sign_in_as_user
|
||||
get destroy_user_session_path(format: 'json')
|
||||
delete destroy_user_session_path(format: 'json')
|
||||
assert_response :no_content
|
||||
assert_not warden.authenticated?(:user)
|
||||
end
|
||||
|
||||
test 'sign out with non-navigational format via XHR does not redirect' do
|
||||
swap Devise, navigational_formats: ['*/*', :html] do
|
||||
sign_in_as_user
|
||||
get destroy_user_session_path, xhr: true, headers: { "HTTP_ACCEPT" => "application/json,text/javascript,*/*" } # NOTE: Bug is triggered by combination of XHR and */*.
|
||||
sign_in_as_admin
|
||||
get destroy_sign_out_via_get_session_path, xhr: true, headers: { "HTTP_ACCEPT" => "application/json,text/javascript,*/*" } # NOTE: Bug is triggered by combination of XHR and */*.
|
||||
assert_response :no_content
|
||||
assert_not warden.authenticated?(:user)
|
||||
end
|
||||
@@ -569,7 +538,7 @@ class AuthenticationOthersTest < Devise::IntegrationTest
|
||||
test 'sign out with navigational format via XHR does redirect' do
|
||||
swap Devise, navigational_formats: ['*/*', :html] do
|
||||
sign_in_as_user
|
||||
get destroy_user_session_path, xhr: true, headers: { "HTTP_ACCEPT" => "text/html,*/*" }
|
||||
delete destroy_user_session_path, xhr: true, headers: { "HTTP_ACCEPT" => "text/html,*/*" }
|
||||
assert_response :redirect
|
||||
assert_not warden.authenticated?(:user)
|
||||
end
|
||||
@@ -580,7 +549,7 @@ class AuthenticationKeysTest < Devise::IntegrationTest
|
||||
test 'missing authentication keys cause authentication to abort' do
|
||||
swap Devise, authentication_keys: [:subdomain] do
|
||||
sign_in_as_user
|
||||
assert_contain "Invalid subdomain or password."
|
||||
assert_contain "Invalid Subdomain or password."
|
||||
assert_not warden.authenticated?(:user)
|
||||
end
|
||||
end
|
||||
@@ -619,7 +588,7 @@ class AuthenticationRequestKeysTest < Devise::IntegrationTest
|
||||
|
||||
swap Devise, request_keys: [:subdomain] do
|
||||
sign_in_as_user
|
||||
assert_contain "Invalid email or password."
|
||||
assert_contain "Invalid Email or password."
|
||||
assert_not warden.authenticated?(:user)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -35,7 +35,7 @@ class ConfirmationTest < Devise::IntegrationTest
|
||||
test 'user with invalid confirmation token should not be able to confirm an account' do
|
||||
visit_user_confirmation_with_token('invalid_confirmation')
|
||||
assert_have_selector '#error_explanation'
|
||||
assert_contain /Confirmation token(.*)invalid/
|
||||
assert_contain %r{Confirmation token(.*)invalid}
|
||||
end
|
||||
|
||||
test 'user with valid confirmation token should not be able to confirm an account after the token has expired' do
|
||||
@@ -45,7 +45,7 @@ class ConfirmationTest < Devise::IntegrationTest
|
||||
visit_user_confirmation_with_token(user.raw_confirmation_token)
|
||||
|
||||
assert_have_selector '#error_explanation'
|
||||
assert_contain /needs to be confirmed within 3 days/
|
||||
assert_contain %r{needs to be confirmed within 3 days}
|
||||
assert_not user.reload.confirmed?
|
||||
assert_current_url "/users/confirmation?confirmation_token=#{user.raw_confirmation_token}"
|
||||
end
|
||||
@@ -140,7 +140,7 @@ class ConfirmationTest < Devise::IntegrationTest
|
||||
fill_in 'password', with: 'invalid'
|
||||
end
|
||||
|
||||
assert_contain 'Invalid email or password'
|
||||
assert_contain 'Invalid Email or password'
|
||||
assert_not warden.authenticated?(:user)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -68,7 +68,7 @@ class DatabaseAuthenticationTest < Devise::IntegrationTest
|
||||
fill_in 'password', with: 'abcdef'
|
||||
end
|
||||
|
||||
assert_contain 'Invalid email or password'
|
||||
assert_contain 'Invalid Email or password'
|
||||
assert_not warden.authenticated?(:admin)
|
||||
end
|
||||
|
||||
|
||||
@@ -11,13 +11,15 @@ class HttpAuthenticationTest < Devise::IntegrationTest
|
||||
end
|
||||
|
||||
test 'sign in should authenticate with http' do
|
||||
sign_in_as_new_user_with_http
|
||||
assert_response 200
|
||||
assert_match '<email>user@test.com</email>', response.body
|
||||
assert warden.authenticated?(:user)
|
||||
swap Devise, skip_session_storage: [] do
|
||||
sign_in_as_new_user_with_http
|
||||
assert_response 200
|
||||
assert_match '<email>user@test.com</email>', response.body
|
||||
assert warden.authenticated?(:user)
|
||||
|
||||
get users_path(format: :xml)
|
||||
assert_response 200
|
||||
get users_path(format: :xml)
|
||||
assert_response 200
|
||||
end
|
||||
end
|
||||
|
||||
test 'sign in should authenticate with http but not emit a cookie if skipping session storage' do
|
||||
@@ -42,7 +44,7 @@ class HttpAuthenticationTest < Devise::IntegrationTest
|
||||
sign_in_as_new_user_with_http("unknown")
|
||||
assert_equal 401, status
|
||||
assert_equal "application/xml; charset=utf-8", headers["Content-Type"]
|
||||
assert_match "<error>Invalid email or password.</error>", response.body
|
||||
assert_match "<error>Invalid Email or password.</error>", response.body
|
||||
end
|
||||
|
||||
test 'returns a custom response with www-authenticate and chosen realm' do
|
||||
|
||||
@@ -75,7 +75,7 @@ class LockTest < Devise::IntegrationTest
|
||||
assert_response :success
|
||||
assert_current_url '/users/unlock?unlock_token=invalid_token'
|
||||
assert_have_selector '#error_explanation'
|
||||
assert_contain /Unlock token(.*)invalid/
|
||||
assert_contain %r{Unlock token(.*)invalid}
|
||||
end
|
||||
|
||||
test "locked user should be able to unlock account" do
|
||||
|
||||
@@ -146,7 +146,7 @@ class PasswordTest < Devise::IntegrationTest
|
||||
assert_response :success
|
||||
assert_current_url '/users/password'
|
||||
assert_have_selector '#error_explanation'
|
||||
assert_contain /Reset password token(.*)invalid/
|
||||
assert_contain %r{Reset password token(.*)invalid}
|
||||
assert_not user.reload.valid_password?('987654321')
|
||||
end
|
||||
|
||||
@@ -212,7 +212,7 @@ class PasswordTest < Devise::IntegrationTest
|
||||
test 'does not sign in user automatically after changing its password if it\'s locked and unlock strategy is :none or :time' do
|
||||
[:none, :time].each do |strategy|
|
||||
swap Devise, unlock_strategy: strategy do
|
||||
user = create_user(locked: true)
|
||||
create_user(locked: true)
|
||||
request_forgot_password
|
||||
reset_password
|
||||
|
||||
|
||||
@@ -94,7 +94,6 @@ class RememberMeTest < Devise::IntegrationTest
|
||||
assert_response :success
|
||||
assert warden.authenticated?(:user)
|
||||
assert warden.user(:user) == user
|
||||
assert_match /remember_user_token[^\n]*HttpOnly/, response.headers["Set-Cookie"], "Expected Set-Cookie header in response to set HttpOnly flag on remember_user_token cookie."
|
||||
end
|
||||
|
||||
test 'remember the user before sign up and redirect them to their home' do
|
||||
@@ -120,6 +119,40 @@ class RememberMeTest < Devise::IntegrationTest
|
||||
end
|
||||
end
|
||||
|
||||
test 'extends remember period when extend remember period config is true' do
|
||||
swap Devise, extend_remember_period: true, remember_for: 1.year do
|
||||
create_user_and_remember
|
||||
old_remember_token = nil
|
||||
|
||||
travel_to 1.day.ago do
|
||||
get root_path
|
||||
old_remember_token = request.cookies['remember_user_token']
|
||||
end
|
||||
|
||||
get root_path
|
||||
current_remember_token = request.cookies['remember_user_token']
|
||||
|
||||
refute_equal old_remember_token, current_remember_token
|
||||
end
|
||||
end
|
||||
|
||||
test 'does not extend remember period when extend period config is false' do
|
||||
swap Devise, extend_remember_period: false, remember_for: 1.year do
|
||||
create_user_and_remember
|
||||
old_remember_token = nil
|
||||
|
||||
travel_to 1.day.ago do
|
||||
get root_path
|
||||
old_remember_token = request.cookies['remember_user_token']
|
||||
end
|
||||
|
||||
get root_path
|
||||
current_remember_token = request.cookies['remember_user_token']
|
||||
|
||||
assert_equal old_remember_token, current_remember_token
|
||||
end
|
||||
end
|
||||
|
||||
test 'do not remember other scopes' do
|
||||
create_user_and_remember
|
||||
get root_path
|
||||
@@ -149,7 +182,7 @@ class RememberMeTest < Devise::IntegrationTest
|
||||
get users_path
|
||||
assert warden.authenticated?(:user)
|
||||
|
||||
get destroy_user_session_path
|
||||
delete destroy_user_session_path
|
||||
assert_not warden.authenticated?(:user)
|
||||
assert_nil warden.cookies['remember_user_token']
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ class SessionTimeoutTest < Devise::IntegrationTest
|
||||
user = sign_in_as_user
|
||||
get expire_user_path(user)
|
||||
|
||||
get destroy_user_session_path
|
||||
delete destroy_user_session_path
|
||||
|
||||
assert_response :redirect
|
||||
assert_redirected_to root_path
|
||||
|
||||
@@ -16,7 +16,7 @@ class TrackableHooksTest < Devise::IntegrationTest
|
||||
assert_equal user.current_sign_in_at, user.last_sign_in_at
|
||||
assert user.current_sign_in_at >= user.created_at
|
||||
|
||||
visit destroy_user_session_path
|
||||
delete destroy_user_session_path
|
||||
new_time = 2.seconds.from_now
|
||||
Time.stubs(:now).returns(new_time)
|
||||
|
||||
@@ -56,7 +56,7 @@ class TrackableHooksTest < Devise::IntegrationTest
|
||||
user.reload
|
||||
assert_equal 1, user.sign_in_count
|
||||
|
||||
visit destroy_user_session_path
|
||||
delete destroy_user_session_path
|
||||
sign_in_as_user
|
||||
user.reload
|
||||
assert_equal 2, user.sign_in_count
|
||||
@@ -80,7 +80,7 @@ class TrackableHooksTest < Devise::IntegrationTest
|
||||
end
|
||||
user.reload
|
||||
assert_equal 0, user.sign_in_count
|
||||
visit destroy_user_session_path
|
||||
delete destroy_user_session_path
|
||||
|
||||
sign_in_as_user do
|
||||
header 'devise.skip_trackable', false
|
||||
|
||||
@@ -37,16 +37,16 @@ class ConfirmationInstructionsTest < ActionMailer::TestCase
|
||||
assert_equal [user.email], mail.to
|
||||
end
|
||||
|
||||
test 'setup sender from configuration' do
|
||||
test 'set up sender from configuration' do
|
||||
assert_equal ['test@example.com'], mail.from
|
||||
end
|
||||
|
||||
test 'setup sender from custom mailer defaults' do
|
||||
test 'set up sender from custom mailer defaults' do
|
||||
Devise.mailer = 'Users::Mailer'
|
||||
assert_equal ['custom@example.com'], mail.from
|
||||
end
|
||||
|
||||
test 'setup sender from custom mailer defaults with proc' do
|
||||
test 'set up sender from custom mailer defaults with proc' do
|
||||
Devise.mailer = 'Users::FromProcMailer'
|
||||
assert_equal ['custom@example.com'], mail.from
|
||||
end
|
||||
@@ -56,17 +56,17 @@ class ConfirmationInstructionsTest < ActionMailer::TestCase
|
||||
assert_present mail.body.encoded
|
||||
end
|
||||
|
||||
test 'setup reply to as copy from sender' do
|
||||
test 'set up reply to as copy from sender' do
|
||||
assert_equal ['test@example.com'], mail.reply_to
|
||||
end
|
||||
|
||||
test 'setup reply to as different if set in defaults' do
|
||||
test 'set up reply to as different if set in defaults' do
|
||||
Devise.mailer = 'Users::ReplyToMailer'
|
||||
assert_equal ['custom@example.com'], mail.from
|
||||
assert_equal ['custom_reply_to@example.com'], mail.reply_to
|
||||
end
|
||||
|
||||
test 'setup subject from I18n' do
|
||||
test 'set up subject from I18n' do
|
||||
store_translations :en, devise: { mailer: { confirmation_instructions: { subject: 'Account Confirmation' } } } do
|
||||
assert_equal 'Account Confirmation', mail.subject
|
||||
end
|
||||
|
||||
@@ -39,16 +39,16 @@ class ResetPasswordInstructionsTest < ActionMailer::TestCase
|
||||
assert_equal [user.email], mail.to
|
||||
end
|
||||
|
||||
test 'setup sender from configuration' do
|
||||
test 'set up sender from configuration' do
|
||||
assert_equal ['test@example.com'], mail.from
|
||||
end
|
||||
|
||||
test 'setup sender from custom mailer defaults' do
|
||||
test 'set up sender from custom mailer defaults' do
|
||||
Devise.mailer = 'Users::Mailer'
|
||||
assert_equal ['custom@example.com'], mail.from
|
||||
end
|
||||
|
||||
test 'setup sender from custom mailer defaults with proc' do
|
||||
test 'set up sender from custom mailer defaults with proc' do
|
||||
Devise.mailer = 'Users::FromProcMailer'
|
||||
assert_equal ['custom@example.com'], mail.from
|
||||
end
|
||||
@@ -58,11 +58,11 @@ class ResetPasswordInstructionsTest < ActionMailer::TestCase
|
||||
assert_present mail.body.encoded
|
||||
end
|
||||
|
||||
test 'setup reply to as copy from sender' do
|
||||
test 'set up reply to as copy from sender' do
|
||||
assert_equal ['test@example.com'], mail.reply_to
|
||||
end
|
||||
|
||||
test 'setup subject from I18n' do
|
||||
test 'set up subject from I18n' do
|
||||
store_translations :en, devise: { mailer: { reset_password_instructions: { subject: 'Reset instructions' } } } do
|
||||
assert_equal 'Reset instructions', mail.subject
|
||||
end
|
||||
|
||||
@@ -40,16 +40,16 @@ class UnlockInstructionsTest < ActionMailer::TestCase
|
||||
assert_equal [user.email], mail.to
|
||||
end
|
||||
|
||||
test 'setup sender from configuration' do
|
||||
test 'set up sender from configuration' do
|
||||
assert_equal ['test@example.com'], mail.from
|
||||
end
|
||||
|
||||
test 'setup sender from custom mailer defaults' do
|
||||
test 'set up sender from custom mailer defaults' do
|
||||
Devise.mailer = 'Users::Mailer'
|
||||
assert_equal ['custom@example.com'], mail.from
|
||||
end
|
||||
|
||||
test 'setup sender from custom mailer defaults with proc' do
|
||||
test 'set up sender from custom mailer defaults with proc' do
|
||||
Devise.mailer = 'Users::FromProcMailer'
|
||||
assert_equal ['custom@example.com'], mail.from
|
||||
end
|
||||
@@ -59,11 +59,11 @@ class UnlockInstructionsTest < ActionMailer::TestCase
|
||||
assert_present mail.body.encoded
|
||||
end
|
||||
|
||||
test 'setup reply to as copy from sender' do
|
||||
test 'set up reply to as copy from sender' do
|
||||
assert_equal ['test@example.com'], mail.reply_to
|
||||
end
|
||||
|
||||
test 'setup subject from I18n' do
|
||||
test 'set up subject from I18n' do
|
||||
store_translations :en, devise: { mailer: { unlock_instructions: { subject: 'Yo unlock instructions' } } } do
|
||||
assert_equal 'Yo unlock instructions', mail.subject
|
||||
end
|
||||
|
||||
@@ -35,8 +35,8 @@ class MappingTest < ActiveSupport::TestCase
|
||||
assert_equal [], Devise.mappings[:skip_admin].used_routes
|
||||
end
|
||||
|
||||
test 'sign_out_via defaults to :get' do
|
||||
assert_equal :get, Devise.mappings[:user].sign_out_via
|
||||
test 'sign_out_via defaults to :delete' do
|
||||
assert_equal :delete, Devise.mappings[:user].sign_out_via
|
||||
end
|
||||
|
||||
test 'allows custom sign_out_via to be given' do
|
||||
|
||||
@@ -114,7 +114,7 @@ class ConfirmableTest < ActiveSupport::TestCase
|
||||
|
||||
assert_email_not_sent do
|
||||
user.save!
|
||||
assert !user.confirmed?
|
||||
assert_not user.confirmed?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -188,7 +188,7 @@ class ConfirmableTest < ActiveSupport::TestCase
|
||||
|
||||
test 'confirm time should fallback to devise confirm in default configuration' do
|
||||
swap Devise, allow_unconfirmed_access_for: 1.day do
|
||||
user = new_user
|
||||
user = create_user
|
||||
user.confirmation_sent_at = 2.days.ago
|
||||
assert_not user.active_for_authentication?
|
||||
|
||||
@@ -256,7 +256,7 @@ class ConfirmableTest < ActiveSupport::TestCase
|
||||
user.instance_eval { def confirmation_required?; false end }
|
||||
user.confirmation_sent_at = nil
|
||||
user.save
|
||||
assert user.reload.confirm!
|
||||
assert user.reload.confirm
|
||||
end
|
||||
end
|
||||
|
||||
@@ -401,6 +401,14 @@ class ReconfirmableTest < ActiveSupport::TestCase
|
||||
assert_match "new_test@example.com", ActionMailer::Base.deliveries.last.body.encoded
|
||||
end
|
||||
|
||||
test 'should send confirmation instructions by email after changing email from nil' do
|
||||
admin = create_admin(email: nil)
|
||||
assert_email_sent "new_test@example.com" do
|
||||
assert admin.update_attributes(email: 'new_test@example.com')
|
||||
end
|
||||
assert_match "new_test@example.com", ActionMailer::Base.deliveries.last.body.encoded
|
||||
end
|
||||
|
||||
test 'should not send confirmation by email after changing password' do
|
||||
admin = create_admin
|
||||
assert admin.confirm
|
||||
@@ -488,8 +496,8 @@ class ReconfirmableTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
test 'should not require reconfirmation after creating a record' do
|
||||
user = create_admin
|
||||
assert !user.pending_reconfirmation?
|
||||
admin = create_admin
|
||||
assert !admin.pending_reconfirmation?
|
||||
end
|
||||
|
||||
test 'should not require reconfirmation after creating a record with #save called in callback' do
|
||||
@@ -497,7 +505,7 @@ class ReconfirmableTest < ActiveSupport::TestCase
|
||||
after_create :save
|
||||
end
|
||||
|
||||
user = Admin::WithSaveInCallback.create(valid_attributes.except(:username))
|
||||
assert !user.pending_reconfirmation?
|
||||
admin = Admin::WithSaveInCallback.create(valid_attributes.except(:username))
|
||||
assert !admin.pending_reconfirmation?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -92,28 +92,28 @@ class DatabaseAuthenticatableTest < ActiveSupport::TestCase
|
||||
assert user.respond_to?(:password_confirmation)
|
||||
end
|
||||
|
||||
test 'should generate encrypted password while setting password' do
|
||||
test 'should generate a hashed password while setting password' do
|
||||
user = new_user
|
||||
assert_present user.encrypted_password
|
||||
end
|
||||
|
||||
test 'should support custom encryption methods' do
|
||||
user = UserWithCustomEncryption.new(password: '654321')
|
||||
test 'should support custom hashing methods' do
|
||||
user = UserWithCustomHashing.new(password: '654321')
|
||||
assert_equal user.encrypted_password, '123456'
|
||||
end
|
||||
|
||||
test 'allow authenticatable_salt to work even with nil encrypted password' do
|
||||
test 'allow authenticatable_salt to work even with nil hashed password' do
|
||||
user = User.new
|
||||
user.encrypted_password = nil
|
||||
assert_nil user.authenticatable_salt
|
||||
end
|
||||
|
||||
test 'should not generate encrypted password if password is blank' do
|
||||
test 'should not generate a hashed password if password is blank' do
|
||||
assert_blank new_user(password: nil).encrypted_password
|
||||
assert_blank new_user(password: '').encrypted_password
|
||||
end
|
||||
|
||||
test 'should encrypt password again if password has changed' do
|
||||
test 'should hash password again if password has changed' do
|
||||
user = create_user
|
||||
encrypted_password = user.encrypted_password
|
||||
user.password = user.password_confirmation = 'new_password'
|
||||
|
||||
@@ -325,4 +325,26 @@ class LockableTest < ActiveSupport::TestCase
|
||||
user.lock_access!
|
||||
assert_equal :locked, user.unauthenticated_message
|
||||
end
|
||||
|
||||
test 'unlock_strategy_enabled? should return true for both, email, and time strategies if :both is used' do
|
||||
swap Devise, unlock_strategy: :both do
|
||||
user = create_user
|
||||
assert_equal true, user.unlock_strategy_enabled?(:both)
|
||||
assert_equal true, user.unlock_strategy_enabled?(:time)
|
||||
assert_equal true, user.unlock_strategy_enabled?(:email)
|
||||
assert_equal false, user.unlock_strategy_enabled?(:none)
|
||||
assert_equal false, user.unlock_strategy_enabled?(:an_undefined_strategy)
|
||||
end
|
||||
end
|
||||
|
||||
test 'unlock_strategy_enabled? should return true only for the configured strategy' do
|
||||
swap Devise, unlock_strategy: :email do
|
||||
user = create_user
|
||||
assert_equal false, user.unlock_strategy_enabled?(:both)
|
||||
assert_equal false, user.unlock_strategy_enabled?(:time)
|
||||
assert_equal true, user.unlock_strategy_enabled?(:email)
|
||||
assert_equal false, user.unlock_strategy_enabled?(:none)
|
||||
assert_equal false, user.unlock_strategy_enabled?(:an_undefined_strategy)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -16,6 +16,18 @@ class RememberableTest < ActiveSupport::TestCase
|
||||
assert user.remember_created_at
|
||||
end
|
||||
|
||||
test 'remember_me should not generate a new token if valid token exists' do
|
||||
user = create_user
|
||||
user.singleton_class.send(:attr_accessor, :remember_token)
|
||||
User.to_adapter.expects(:find_first).returns(nil)
|
||||
|
||||
user.remember_me!
|
||||
existing_token = user.remember_token
|
||||
|
||||
user.remember_me!
|
||||
assert_equal existing_token, user.remember_token
|
||||
end
|
||||
|
||||
test 'forget_me should not clear remember token if using salt' do
|
||||
user = create_user
|
||||
user.remember_me!
|
||||
|
||||
@@ -29,7 +29,7 @@ class ValidatableTest < ActiveSupport::TestCase
|
||||
assert user.invalid?
|
||||
assert_not_equal 'is invalid', user.errors[:email].join
|
||||
|
||||
%w{invalid_email_format 123 $$$ () ☃ bla@bla.}.each do |email|
|
||||
%w{invalid_email_format 123 $$$ () ☃}.each do |email|
|
||||
user.email = email
|
||||
assert user.invalid?, 'should be invalid with email ' << email
|
||||
assert_equal 'is invalid', user.errors[:email].join
|
||||
|
||||
@@ -1,23 +1,21 @@
|
||||
require 'test_helper'
|
||||
|
||||
class OmniAuthRoutesTest < ActionController::TestCase
|
||||
ExpectedUrlGeneratiorError = ActionController::UrlGenerationError
|
||||
|
||||
tests ApplicationController
|
||||
|
||||
def assert_path(action, provider, with_param=true)
|
||||
# Resource param
|
||||
assert_equal @controller.send(action, :user, provider),
|
||||
@controller.send("user_#{action}", provider)
|
||||
@controller.send("user_#{provider}_#{action}")
|
||||
|
||||
# With an object
|
||||
assert_equal @controller.send(action, User.new, provider),
|
||||
@controller.send("user_#{action}", provider)
|
||||
@controller.send("user_#{provider}_#{action}")
|
||||
|
||||
if with_param
|
||||
# Default url params
|
||||
assert_equal @controller.send(action, :user, provider, param: 123),
|
||||
@controller.send("user_#{action}", provider, param: 123)
|
||||
@controller.send("user_#{provider}_#{action}", param: 123)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -32,7 +30,7 @@ class OmniAuthRoutesTest < ActionController::TestCase
|
||||
test 'should generate authorization path' do
|
||||
assert_match "/users/auth/facebook", @controller.omniauth_authorize_path(:user, :facebook)
|
||||
|
||||
assert_raise ExpectedUrlGeneratiorError do
|
||||
assert_raise NoMethodError do
|
||||
@controller.omniauth_authorize_path(:user, :github)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,9 +5,11 @@ ActiveRecord::Base.include_root_in_json = true
|
||||
ActiveRecord::Migrator.migrate(File.expand_path("../../rails_app/db/migrate/", __FILE__))
|
||||
|
||||
class ActiveSupport::TestCase
|
||||
if Rails.version >= '5.0.0'
|
||||
if Devise.rails5?
|
||||
self.use_transactional_tests = true
|
||||
else
|
||||
# Let `after_commit` work with transactional fixtures, however this is not needed for Rails 5.
|
||||
require 'test_after_commit'
|
||||
self.use_transactional_fixtures = true
|
||||
end
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
require 'shared_user'
|
||||
require 'active_model/serializers/xml' if Devise.rails5?
|
||||
require 'active_model-serializers' if Devise.rails5?
|
||||
|
||||
class User < ActiveRecord::Base
|
||||
include Shim
|
||||
|
||||
@@ -5,8 +5,7 @@ class ApplicationController < ActionController::Base
|
||||
protect_from_forgery
|
||||
before_action :current_user, unless: :devise_controller?
|
||||
before_action :authenticate_user!, if: :devise_controller?
|
||||
respond_to *Mime::SET.map(&:to_sym)
|
||||
respond_to(*Mime::SET.map(&:to_sym))
|
||||
|
||||
devise_group :commenter, contains: [:user, :admin]
|
||||
end
|
||||
|
||||
|
||||
@@ -32,6 +32,10 @@ module RailsApp
|
||||
|
||||
config.action_mailer.default_url_options = { host: "localhost", port: 3000 }
|
||||
|
||||
if DEVISE_ORM == :active_record && (Rails::VERSION::MAJOR >= 4 && Rails::VERSION::MINOR >= 2)
|
||||
config.active_record.raise_in_transactional_callbacks = true
|
||||
end
|
||||
|
||||
# This was used to break devise in some situations
|
||||
config.to_prepare do
|
||||
Devise::SessionsController.layout "application"
|
||||
|
||||
@@ -11,4 +11,4 @@ end
|
||||
|
||||
# Set up gems listed in the Gemfile.
|
||||
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
|
||||
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
|
||||
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
||||
|
||||
@@ -135,7 +135,7 @@ Devise.setup do |config|
|
||||
# reset. Defaults to true, so a user is signed in automatically after a reset.
|
||||
# config.sign_in_after_reset_password = true
|
||||
|
||||
# Setup a pepper to generate the encrypted password.
|
||||
# Set up a pepper to generate the encrypted password.
|
||||
config.pepper = "d142367154e5beacca404b1a6a4f8bc52c6fdcfa3ccc3cf8eb49f3458a688ee6ac3b9fae488432a3bfca863b8a90008368a9f3a3dfbe5a962e64b6ab8f3a3a1a"
|
||||
|
||||
# ==> Scopes configuration
|
||||
|
||||
@@ -114,6 +114,7 @@ Rails.application.routes.draw do
|
||||
namespace :sign_out_via, module: "devise" do
|
||||
devise_for :deletes, sign_out_via: :delete, class_name: "Admin"
|
||||
devise_for :posts, sign_out_via: :post, class_name: "Admin"
|
||||
devise_for :gets, sign_out_via: :get, class_name: "Admin"
|
||||
devise_for :delete_or_posts, sign_out_via: [:delete, :post], class_name: "Admin"
|
||||
end
|
||||
|
||||
|
||||
@@ -4,7 +4,8 @@ module SharedUser
|
||||
included do
|
||||
devise :database_authenticatable, :confirmable, :lockable, :recoverable,
|
||||
:registerable, :rememberable, :timeoutable,
|
||||
:trackable, :validatable, :omniauthable, password_length: 7..72
|
||||
:trackable, :validatable, :omniauthable, password_length: 7..72,
|
||||
reconfirmable: false
|
||||
|
||||
attr_accessor :other_key
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ module SharedUserWithoutOmniauth
|
||||
included do
|
||||
devise :database_authenticatable, :confirmable, :lockable, :recoverable,
|
||||
:registerable, :rememberable, :timeoutable,
|
||||
:trackable, :validatable
|
||||
:trackable, :validatable, reconfirmable: false
|
||||
end
|
||||
|
||||
def raw_confirmation_token
|
||||
|
||||
@@ -14,7 +14,7 @@ class DefaultRoutingTest < ActionController::TestCase
|
||||
end
|
||||
|
||||
test 'map destroy user session' do
|
||||
assert_recognizes({controller: 'devise/sessions', action: 'destroy'}, {path: 'users/sign_out', method: :get})
|
||||
assert_recognizes({controller: 'devise/sessions', action: 'destroy'}, {path: 'users/sign_out', method: :delete})
|
||||
assert_named_route "/users/sign_out", :destroy_user_session_path
|
||||
end
|
||||
|
||||
@@ -96,12 +96,12 @@ class DefaultRoutingTest < ActionController::TestCase
|
||||
test 'map omniauth callbacks' do
|
||||
assert_recognizes({controller: 'users/omniauth_callbacks', action: 'facebook'}, {path: 'users/auth/facebook/callback', method: :get})
|
||||
assert_recognizes({controller: 'users/omniauth_callbacks', action: 'facebook'}, {path: 'users/auth/facebook/callback', method: :post})
|
||||
assert_named_route "/users/auth/facebook/callback", :user_omniauth_callback_path, :facebook
|
||||
assert_named_route "/users/auth/facebook/callback", :user_facebook_omniauth_callback_path
|
||||
|
||||
# named open_id
|
||||
assert_recognizes({controller: 'users/omniauth_callbacks', action: 'google'}, {path: 'users/auth/google/callback', method: :get})
|
||||
assert_recognizes({controller: 'users/omniauth_callbacks', action: 'google'}, {path: 'users/auth/google/callback', method: :post})
|
||||
assert_named_route "/users/auth/google/callback", :user_omniauth_callback_path, :google
|
||||
assert_named_route "/users/auth/google/callback", :user_google_omniauth_callback_path
|
||||
|
||||
assert_raise ExpectedRoutingError do
|
||||
assert_recognizes({controller: 'ysers/omniauth_callbacks', action: 'twitter'}, {path: 'users/auth/twitter/callback', method: :get})
|
||||
@@ -146,7 +146,7 @@ class CustomizedRoutingTest < ActionController::TestCase
|
||||
end
|
||||
|
||||
test 'map account with custom path name for session sign out' do
|
||||
assert_recognizes({controller: 'devise/sessions', action: 'destroy', locale: 'en'}, '/en/accounts/logout')
|
||||
assert_recognizes({controller: 'devise/sessions', action: 'destroy', locale: 'en'}, {path: '/en/accounts/logout', method: :delete })
|
||||
end
|
||||
|
||||
test 'map account with custom path name for password' do
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
test:
|
||||
sessions:
|
||||
<%= Mongoid::VERSION.to_i > 4 ? 'clients' : 'sessions' %>:
|
||||
default:
|
||||
database: devise-test-suite
|
||||
hosts:
|
||||
|
||||
@@ -68,13 +68,13 @@ class TestHelpersTest < Devise::ControllerTestCase
|
||||
test "respects custom failure app" do
|
||||
custom_failure_app = Class.new(Devise::FailureApp) do
|
||||
def redirect
|
||||
self.status = 306
|
||||
self.status = 300
|
||||
end
|
||||
end
|
||||
|
||||
swap Devise.warden_config, failure_app: custom_failure_app do
|
||||
get :index
|
||||
assert_response 306
|
||||
assert_response 300
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ class UserWithValidation < User
|
||||
validates_presence_of :username
|
||||
end
|
||||
|
||||
class UserWithCustomEncryption < User
|
||||
class UserWithCustomHashing < User
|
||||
protected
|
||||
def password_digest(password)
|
||||
password.reverse
|
||||
|
||||
Reference in New Issue
Block a user