diff options
author | Jordan Bracco <href@random.sh> | 2022-12-20 00:21:54 +0000 |
---|---|---|
committer | Jordan Bracco <href@random.sh> | 2022-12-20 19:29:41 +0100 |
commit | 2d83df8b32bff7f0028923bb5b64dc0b55f20d03 (patch) | |
tree | 1207e67b5b15f540963db05e7be89f3ca950e724 /lib/lsg/token.ex | |
parent | Nola rename, the end. pt 6. Refs T77. (diff) |
Nola rename: The Big Move, Refs T77
Diffstat (limited to 'lib/lsg/token.ex')
-rw-r--r-- | lib/lsg/token.ex | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/lib/lsg/token.ex b/lib/lsg/token.ex deleted file mode 100644 index 563ac72..0000000 --- a/lib/lsg/token.ex +++ /dev/null @@ -1,38 +0,0 @@ -defmodule Nola.Token do - use GenServer - - def start_link() do - GenServer.start_link(__MODULE__, [], [name: __MODULE__]) - end - - def lookup(id) do - with \ - [{_, cred, date}] <- :ets.lookup(__MODULE__.ETS, id), - IO.inspect("cred: #{inspect cred} valid for #{inspect date} now #{inspect DateTime.utc_now()}"), - d when d > 0 <- DateTime.diff(date, DateTime.utc_now()) - do - {:ok, cred} - else - err -> {:error, err} - end - end - - def new(cred) do - GenServer.call(__MODULE__, {:new, cred}) - end - - def init(_) do - ets = :ets.new(__MODULE__.ETS, [:ordered_set, :named_table, :protected, {:read_concurrency, true}]) - {:ok, ets} - end - - def handle_call({:new, cred}, _, ets) do - id = IRC.UserTrack.Id.large_id() - expire = DateTime.utc_now() - |> DateTime.add(15*60, :second) - obj = {id, cred, expire} - :ets.insert(ets, obj) - {:reply, {:ok, id}, ets} - end - -end |