Browse Source

feat: use proper session cache :)))

pull/48/head
Inhji Y. 1 year ago
parent
commit
48a7331fcf
  1. 1
      .env.example
  2. 4
      .gitignore
  3. 4
      apps/tomie_web/lib/tomie_web/application.ex
  4. 3
      apps/tomie_web/lib/tomie_web/endpoint.ex
  5. 5
      config/config.exs
  6. 11
      config/releases.exs

1
.env.example

@ -4,3 +4,4 @@ HOST=
PORT=
SECRET_KEY_BASE=
UPLOAD_DIR=
CACHE_DIR=

4
.gitignore

@ -22,4 +22,8 @@ erl_crash.dump
# Ignore environment file
.env
# Ignore Uploads dir
/uploads/
# Ignore Cache dir
/cache/

4
apps/tomie_web/lib/tomie_web/application.ex

@ -11,7 +11,9 @@ defmodule TomieWeb.Application do
# Start the endpoint when the application starts
TomieWeb.Endpoint,
# Starts a worker by calling: TomieWeb.Worker.start_link(arg)
{Phoenix.PubSub, name: TomieWeb.PubSub}
{Phoenix.PubSub, name: TomieWeb.PubSub},
# Starts Mnesia Store for Pow
Pow.Store.Backend.MnesiaCache
]
# See https://hexdocs.pm/elixir/Supervisor.html

3
apps/tomie_web/lib/tomie_web/endpoint.ex

@ -7,7 +7,8 @@ defmodule TomieWeb.Endpoint do
@session_options [
store: :cookie,
key: "_tomie_web_key",
signing_salt: "bnetjq+s"
signing_salt: "bnetjq+s",
max_age: 1_209_600
]
socket "/live", Phoenix.LiveView.Socket,

5
config/config.exs

@ -44,7 +44,10 @@ config :tomie_web, TomieWeb.Endpoint,
config :tomie_web, :pow,
user: Users.User,
repo: Db.Repo,
web_module: TomieWeb
web_module: TomieWeb,
cache_store_backend: Pow.Store.Backend.MnesiaCache
config :mnesia, dir: 'cache'
# Configures Elixir's Logger
config :logger, :console,

11
config/releases.exs

@ -41,6 +41,17 @@ upload_dir =
config :waffle,
storage_dir_prefix: upload_dir
mnesia_dir =
System.get_env("CACHE_DIR") ||
raise """
environment variable CACHE_DIR is missing.
for example: /opt/tomie/cache
"""
config :tomie_web, :pow, cache_store_backend: Pow.Store.Backend.MnesiaCache
config :mnesia, dir: mnesia_dir
# ## Using releases (Elixir v1.9+)
#
# If you are doing OTP releases, you need to instruct Phoenix

Loading…
Cancel
Save