devise

https://github.com/plataformatec/devise

Ruby

Flexible authentication solution for Rails with Warden.

Devise::Models::Confirmable#confirmation_period_valid?

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.
allow_unconfirmed_access_for is a model configuration, must always be an integer value.

Example:

  # allow_unconfirmed_access_for = 1.day and confirmation_sent_at = today
  confirmation_period_valid?   # returns true

  # allow_unconfirmed_access_for = 5.days and confirmation_sent_at = 4.days.ago
  confirmation_period_valid?   # returns true

  # allow_unconfirmed_access_for = 5.days and confirmation_sent_at = 5.days.ago
  confirmation_period_valid?   # returns false

  # allow_unconfirmed_access_for = 0.days
  confirmation_period_valid?   # will always return false

  # allow_unconfirmed_access_for = nil
  confirmation_period_valid?   # will always return true

Source | Google | Stack overflow

Edit

git clone [email protected]:plataformatec/devise.git

cd devise

open lib/devise/models/confirmable.rb

Contribute

# Make a new branch

git checkout -b -your-name--update-docs-Devise--Models--Confirmable-confirmation_period_valid--for-pr


# Commit to git

git add lib/devise/models/confirmable.rbgit commit -m "better docs for Devise::Models::Confirmable#confirmation_period_valid?"


# Open pull request

gem install hub # on a mac you can `brew install hub`

hub fork

git push <your name> -your-name--update-docs-Devise--Models--Confirmable-confirmation_period_valid--for-pr

hub pull-request


# Celebrate!