I'm developing a login system for a web application using Guardian to handle authentication. In my Guardian config i have
ttl: {30, :days}
User's token is stored in cookies by calling:
defp login(conn, user) do
conn
|> Guardian.Plug.sign_in(user)
end
Like this, token is valid for 30 days and stays there even if browser is closed (expected behaviour for a cookie). User, however, should be able to choose if being remembered or not during login. If not, token must be deleted from cookies upon closing browser window. I've tried to set
ttl: {0, :days}
and it seems to accomplish the needed behaviour. Said that:
- Is ttl: {0, :days} a proper way to authenticate a user until browser window gets closed? If so, how to programmatically change ttl value in the pipeline before Guardian.Plug.sign_in(conn, user) is called?
- Is Guardian able to store token in cookies or in session storage based on the user selection? (cookies for selected remember me, session storage if not)