mirror of
https://github.com/heartcombo/devise.git
synced 2026-01-09 23:58:06 -05:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b8cddc3cf3 | ||
|
|
1d57169c7b | ||
|
|
812c1de8e8 | ||
|
|
a0f266c584 | ||
|
|
ad99bfe6ef |
13
CHANGELOG.md
13
CHANGELOG.md
@@ -1,3 +1,16 @@
|
||||
### Unreleased
|
||||
|
||||
### 3.5.8 - 2016-04-25
|
||||
|
||||
* bug fixes
|
||||
* Fix the e-mail confirmation instructions send when a user updates the email address from nil
|
||||
|
||||
### 3.5.7 - 2016-04-18
|
||||
|
||||
* bug fixes
|
||||
* Fix the `extend_remember_period` configuration. When set to `false` it does
|
||||
not update the cookie expiration anymore.(by @ulissesalmeida)
|
||||
|
||||
### 3.5.6 - 2016-01-02
|
||||
|
||||
* bug fixes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
PATH
|
||||
remote: .
|
||||
specs:
|
||||
devise (3.5.6)
|
||||
devise (3.5.8)
|
||||
bcrypt (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
railties (>= 3.2.6, < 5)
|
||||
@@ -48,7 +48,7 @@ GEM
|
||||
thread_safe (~> 0.3, >= 0.3.4)
|
||||
tzinfo (~> 1.1)
|
||||
arel (6.0.0)
|
||||
bcrypt (3.1.10)
|
||||
bcrypt (3.1.11)
|
||||
bson (3.1.2)
|
||||
builder (3.2.2)
|
||||
connection_pool (2.2.0)
|
||||
@@ -139,7 +139,7 @@ GEM
|
||||
thor (>= 0.18.1, < 2.0)
|
||||
rake (10.4.2)
|
||||
rdoc (4.2.0)
|
||||
responders (2.1.1)
|
||||
responders (2.1.2)
|
||||
railties (>= 4.2.0, < 5.1)
|
||||
ruby-openid (2.7.0)
|
||||
sprockets (3.2.0)
|
||||
|
||||
@@ -116,7 +116,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
|
||||
|
||||
@@ -170,6 +170,7 @@ module Devise
|
||||
# in models to map to a nice sign up e-mail.
|
||||
def send_on_create_confirmation_instructions
|
||||
send_confirmation_instructions
|
||||
skip_reconfirmation!
|
||||
end
|
||||
|
||||
# Callback to overwrite if confirmation is required or not.
|
||||
@@ -254,13 +255,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?
|
||||
|
||||
@@ -39,7 +39,7 @@ 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]
|
||||
@@ -71,6 +71,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
|
||||
@@ -152,9 +156,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
|
||||
|
||||
@@ -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?
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
module Devise
|
||||
VERSION = "3.5.6".freeze
|
||||
VERSION = "3.5.8".freeze
|
||||
end
|
||||
|
||||
@@ -92,7 +92,6 @@ class RememberMeTest < ActionDispatch::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
|
||||
@@ -118,6 +117,40 @@ class RememberMeTest < ActionDispatch::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
|
||||
user = 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
|
||||
user = 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
|
||||
|
||||
@@ -114,7 +114,7 @@ class ConfirmableTest < ActiveSupport::TestCase
|
||||
|
||||
assert_email_not_sent do
|
||||
user.save!
|
||||
assert !user.confirmed?
|
||||
assert_not user.confirmed?
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user