I am sending a verification link via email after saving it to my database. I want the link to have a timeout, i.e., it would be rendered invalid after a certain duration. How do I do so using Timex? I don’t want to use other authentication packages like Coherence.
Why do you want to use Timex for this? I think I would do it using the standard library.
# extract timestamp from the link link_datetime = extract_date_time_from_link(link) # diff with utc now diff = DateTime.diff(DateTime.utc_now(), link_datetime) # compare the diff with max age case diff do diff when diff > @max_age -> :stale _ -> :ok end
Thanks a lot! This really helped me.