fix: warning
This commit is contained in:
parent
2e2737c6cf
commit
4dedc688cb
3 changed files with 12 additions and 2 deletions
|
@ -11,9 +11,13 @@ config :exmr,
|
||||||
ecto_repos: [Exmr.Repo],
|
ecto_repos: [Exmr.Repo],
|
||||||
generators: [timestamp_type: :utc_datetime]
|
generators: [timestamp_type: :utc_datetime]
|
||||||
|
|
||||||
|
config :exmr,
|
||||||
|
registration_enabled: "true"
|
||||||
|
|
||||||
# Configures the endpoint
|
# Configures the endpoint
|
||||||
config :exmr, ExmrWeb.Endpoint,
|
config :exmr, ExmrWeb.Endpoint,
|
||||||
url: [host: "localhost"],
|
url: [host: "localhost"],
|
||||||
|
registration_enabled: "true",
|
||||||
adapter: Bandit.PhoenixAdapter,
|
adapter: Bandit.PhoenixAdapter,
|
||||||
render_errors: [
|
render_errors: [
|
||||||
formats: [html: ExmrWeb.ErrorHTML, json: ExmrWeb.ErrorJSON],
|
formats: [html: ExmrWeb.ErrorHTML, json: ExmrWeb.ErrorJSON],
|
||||||
|
|
|
@ -6,4 +6,8 @@ defmodule Exmr do
|
||||||
Contexts are also responsible for managing your data, regardless
|
Contexts are also responsible for managing your data, regardless
|
||||||
if it comes from the database, an external API or others.
|
if it comes from the database, an external API or others.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def enable_registration do
|
||||||
|
Application.fetch_env!(:exmr, :registration_enabled)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,6 +3,8 @@ defmodule ExmrWeb.Router do
|
||||||
|
|
||||||
import ExmrWeb.UserAuth
|
import ExmrWeb.UserAuth
|
||||||
|
|
||||||
|
# enable_registration = Application.fetch_env!(:exmr, :registration_enabled)
|
||||||
|
|
||||||
pipeline :browser do
|
pipeline :browser do
|
||||||
plug :accepts, ["html"]
|
plug :accepts, ["html"]
|
||||||
plug :fetch_session
|
plug :fetch_session
|
||||||
|
@ -52,7 +54,7 @@ defmodule ExmrWeb.Router do
|
||||||
|
|
||||||
live_session :redirect_if_user_is_authenticated,
|
live_session :redirect_if_user_is_authenticated,
|
||||||
on_mount: [{ExmrWeb.UserAuth, :redirect_if_user_is_authenticated}] do
|
on_mount: [{ExmrWeb.UserAuth, :redirect_if_user_is_authenticated}] do
|
||||||
if Application.get_env(:exmr, :registration_enabled) != "false" do
|
if Exmr.enable_registration() != "false" do
|
||||||
live "/users/register", UserRegistrationLive, :new
|
live "/users/register", UserRegistrationLive, :new
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -69,7 +71,7 @@ defmodule ExmrWeb.Router do
|
||||||
|
|
||||||
live_session :require_authenticated_user,
|
live_session :require_authenticated_user,
|
||||||
on_mount: [{ExmrWeb.UserAuth, :ensure_authenticated}] do
|
on_mount: [{ExmrWeb.UserAuth, :ensure_authenticated}] do
|
||||||
if Application.get_env(:exmr, :registration_enabled) == "false" do
|
if Exmr.enable_registration() == "false" do
|
||||||
live "/users/register", UserRegistrationLive, :new
|
live "/users/register", UserRegistrationLive, :new
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue