I allow users to log in first without confirming their email address, but after 7 days, if they have not been verified, I will block access until they confirm their address.
(Note - this is achieved by setting config.allow_unconfirmed_access_for = 7.days in the Devise initializer)
If they reach the limit of "grace" (for example, they do not confirm and pass after 7 days), I want:
- send them to a page explaining what is happening (I can do this part)
- send confirmation email automatically
do # 2 I need to access a user to get an email address.
To develop, obviously, “knows” who the user is, as he knows that they have passed the validity period of the confirmation.
If the user has just tried to log in, I can get this by looking at the options. However, if the user already has an entry token in their session, then when they pass the magic week they will suddenly begin to be rejected by development. How can I access the user in this case?
#based on
This achieves goal # 1, but only achieves goal # 2, if if the failure is the result of a new registration
Is there direct access to the user when he has a live session, but has the expiration date been reached?
(current_user is unavailable, env ['warden']. user is nil)
Thank you
Rails 5.0.6 develop 4.2
edit: update for clarification with an example scenario where I need help:
Day 0: User is logged in with email / password. I let them in without confirming their email. They have a 7 day grace period to confirm their email.
day 2: they log out
day 7 (morning): they log in again
day 7 (later that day): they perform some actions. Their login token is still valid - the developer recognizes it, finds its user account and checks if they have verified their email address. They did not do this - therefore, the developer refuses to authorize the action, giving an error: unconfirmed
In this scenario, they fall into the application with an error. I redirect them to a page that says: "You have passed your 7-day grace period, you really need to confirm your email address now."
In the rejected application, I want to know what their email address is so that I can automatically send a confirmation email. How to get it?
Note. In this case, the developer refused authorization. current_user is zero. However, Devise clearly “knows” who the user is because he was able to find his entry in the database and verify that they went through the grace period for unconfirmed email addresses. How to access the same "knowledge"