lundi 18 janvier 2021

Devise: Log user out after the confirmation period ends

I have a setup for logging the user out of the application once the confirmation period ends. Also, I need the user to be only logged out at night at 2 AM.

For this, I overrode the following -

def confirmation_period_valid?
  confirmation_time = confirmation_sent_at.in_time_zone(time_zone).end_of_day + 2.hours
  unconfirmed_access_time = self.class.allow_unconfirmed_access_for.ago.in_time_zone(time_zone)
  confirmation_sent_at && confirmation_time >= unconfirmed_access_time
end

But when I check after the expiration period, I am still able to use the application. The user is not logged out.

Checking the rails console shows that the confirmation period is not valid for the user so that works.

Aucun commentaire:

Enregistrer un commentaire