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],
|
||||
generators: [timestamp_type: :utc_datetime]
|
||||
|
||||
config :exmr,
|
||||
registration_enabled: "true"
|
||||
|
||||
# Configures the endpoint
|
||||
config :exmr, ExmrWeb.Endpoint,
|
||||
url: [host: "localhost"],
|
||||
registration_enabled: "true",
|
||||
adapter: Bandit.PhoenixAdapter,
|
||||
render_errors: [
|
||||
formats: [html: ExmrWeb.ErrorHTML, json: ExmrWeb.ErrorJSON],
|
||||
|
|
|
@ -6,4 +6,8 @@ defmodule Exmr do
|
|||
Contexts are also responsible for managing your data, regardless
|
||||
if it comes from the database, an external API or others.
|
||||
"""
|
||||
|
||||
def enable_registration do
|
||||
Application.fetch_env!(:exmr, :registration_enabled)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,6 +3,8 @@ defmodule ExmrWeb.Router do
|
|||
|
||||
import ExmrWeb.UserAuth
|
||||
|
||||
# enable_registration = Application.fetch_env!(:exmr, :registration_enabled)
|
||||
|
||||
pipeline :browser do
|
||||
plug :accepts, ["html"]
|
||||
plug :fetch_session
|
||||
|
@ -52,7 +54,7 @@ defmodule ExmrWeb.Router do
|
|||
|
||||
live_session :redirect_if_user_is_authenticated,
|
||||
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
|
||||
end
|
||||
|
||||
|
@ -69,7 +71,7 @@ defmodule ExmrWeb.Router do
|
|||
|
||||
live_session :require_authenticated_user,
|
||||
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
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue