I want to know how to prevent this error which I get for requesting an expired session. What could be a good way to do that? I checked Custom Errors and Error Handling but not sure how helpful they are. Error message below.
ArgumentError at GET /svr/email/verify
cannot perform Monitor.Repo.get/2 because the given value is nil
lib/ecto/repo/queryable.ex
defp query_for_get(repo, _queryable, nil) do
raise ArgumentError, "cannot perform #{inspect repo}.get/2 because the given value is nil"
end
Ecto.Repo.Queryable.query_for_get/3
-
First, a UUID is created and set in the session.
uuid = SecureRandom.uuid SessionStore.set uuid, id, ttl: 20
-
Then below URL link is sent to the user and when the user clicks, it should check if the UUID is expired in session or not.
<% verify_url = MyAppWeb.Router.Helpers.email_url(MyAppWeb.Endpoint, :verify, uuid: @uuid) %>
-
UUID is checked
def verify(conn, %{"uuid" => uuid}) do user_id = SessionStore.get(uuid) end