Option to validate upon #confirm!

Allow to ensure valid upon confirming.
We might want to consider confirmation status in validations. For example, maybe we want to require certain fields upon confirmation, but not at registration.
This commit is contained in:
Tim Scott 2014-11-19 12:29:08 -06:00
parent c54e9863a6
commit 4ba84eeb27
1 changed files with 2 additions and 2 deletions

View File

@ -56,7 +56,7 @@ module Devise
# Confirm a user by setting it's confirmed_at to actual time. If the user
# is already confirmed, add an error to email field. If the user is invalid
# add errors
def confirm!
def confirm!(ensure_valid=false)
pending_any_confirmation do
if confirmation_period_expired?
self.errors.add(:email, :confirmation_period_expired,
@ -75,7 +75,7 @@ module Devise
# We need to validate in such cases to enforce e-mail uniqueness
save(validate: true)
else
save(validate: false)
save(validate: ensure_valid)
end
after_confirmation if saved