Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generate a confirmation_token over an empty string #5072

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/devise/models/confirmable.rb
Expand Up @@ -246,7 +246,7 @@ def pending_any_confirmation
# Generates a new random token for confirmation, and stores
# the time this token is being generated in confirmation_sent_at
def generate_confirmation_token
if self.confirmation_token && !confirmation_period_expired?
if self.confirmation_token.present? && !confirmation_period_expired?
@raw_confirmation_token = self.confirmation_token
else
self.confirmation_token = @raw_confirmation_token = Devise.friendly_token
Expand Down
6 changes: 6 additions & 0 deletions test/models/confirmable_test.rb
Expand Up @@ -33,6 +33,12 @@ def setup
end
end

test 'should generate a token over an empty string' do
user = create_user(confirmation_token: '')
assert_not_nil user.confirmation_token
assert_not_equal user.confirmation_token, ''
end

test 'should confirm a user by updating confirmed at' do
user = create_user
assert_nil user.confirmed_at
Expand Down