Confirm Email Formatting

I have a rails 3 application that uses Devise and a confirmation module. However, preventing new users from accessing the site until they confirm their email will not cause problems with saving. Instead, we would like to immediately grant the user access and send an email with confirmation. Then we launched a background task to block a user who did not confirm his email for a fixed period of time.

Is this possible with a verifiable module? Is there a way to create an active resource (user) that has not confirmed its letter with the confirmation module? Any general guidelines for implementing this?

+5
source share
3 answers

I believe you can use confirm_within to indicate a lock restriction. You can enable this when you call devise_for.

http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Confirmable

, "" , ? . CanCan . , , ; , , , / ..

+4

. , confirm_within, , devise not devise_for.

class User
  devise :database_authenticatable, :encryptable, :confirmable, :rememberable,      :timeoutable, :lockable,
     :stretches => 15, :pepper => 'abcdef', :confirm_within => 5.days,
     :remember_for => 7.days, :timeout_in => 15.minutes, :unlock_in => 10.days
end

config/initializers/devise.rb config.confirm_within = 10.days

+2

Hmm, I think the correct flag would be allow_unconfirmed_access_for:

config.allow_unconfirmed_access_for = 5.days

confirm_within just indicates how long the token with the email can be used.

More from config/initializers/devise.rb:

# ==> Configuration for :confirmable
# A period that the user is allowed to access the website even without
# confirming his account. For instance, if set to 2.days, the user will be
# able to access the website for two days without confirming his account,
# access will be blocked just in the third day. Default is 0.days, meaning
# the user cannot access the website without confirming his account.
# config.allow_unconfirmed_access_for = 2.days

# A period that the user is allowed to confirm their account before their
# token becomes invalid. For example, if set to 3.days, the user can confirm
# their account within 3 days after the mail was sent, but on the fourth day
# their account can't be confirmed with the token any more.
# Default is nil, meaning there is no restriction on how long a user can take
# before confirming their account.
# config.confirm_within = 3.days
0
source

All Articles