From d685ca5c74b27c854a1b2214c13214d0e7bf1f99 Mon Sep 17 00:00:00 2001 From: shibao Date: Fri, 11 Feb 2022 22:24:16 -0500 Subject: [PATCH] hide register button when registration disabled --- .../templates/user_confirmation/new.html.heex | 10 ++++++---- .../templates/user_reset_password/edit.html.heex | 10 ++++++---- .../templates/user_reset_password/new.html.heex | 10 ++++++---- lib/cannery_web/templates/user_session/new.html.heex | 10 ++++++---- lib/cannery_web/views/user_confirmation_view.ex | 1 + lib/cannery_web/views/user_reset_password_view.ex | 1 + lib/cannery_web/views/user_session_view.ex | 1 + 7 files changed, 27 insertions(+), 16 deletions(-) diff --git a/lib/cannery_web/templates/user_confirmation/new.html.heex b/lib/cannery_web/templates/user_confirmation/new.html.heex index f438f90f..42b8ff62 100644 --- a/lib/cannery_web/templates/user_confirmation/new.html.heex +++ b/lib/cannery_web/templates/user_confirmation/new.html.heex @@ -17,10 +17,12 @@
- <%= link(dgettext("actions", "Register"), - to: Routes.user_registration_path(@conn, :new), - class: "btn btn-primary" - ) %> + <%= if Accounts.allow_registration?() do %> + <%= link(dgettext("actions", "Register"), + to: Routes.user_registration_path(@conn, :new), + class: "btn btn-primary" + ) %> + <% end %> <%= link(dgettext("actions", "Log in"), to: Routes.user_session_path(@conn, :new), class: "btn btn-primary" diff --git a/lib/cannery_web/templates/user_reset_password/edit.html.heex b/lib/cannery_web/templates/user_reset_password/edit.html.heex index c6c2fddc..6adebafe 100644 --- a/lib/cannery_web/templates/user_reset_password/edit.html.heex +++ b/lib/cannery_web/templates/user_reset_password/edit.html.heex @@ -32,10 +32,12 @@
- <%= link(dgettext("actions", "Register"), - to: Routes.user_registration_path(@conn, :new), - class: "btn btn-primary" - ) %> + <%= if Accounts.allow_registration?() do %> + <%= link(dgettext("actions", "Register"), + to: Routes.user_registration_path(@conn, :new), + class: "btn btn-primary" + ) %> + <% end %> <%= link(dgettext("actions", "Log in"), to: Routes.user_session_path(@conn, :new), class: "btn btn-primary" diff --git a/lib/cannery_web/templates/user_reset_password/new.html.heex b/lib/cannery_web/templates/user_reset_password/new.html.heex index 35e7d432..580525f6 100644 --- a/lib/cannery_web/templates/user_reset_password/new.html.heex +++ b/lib/cannery_web/templates/user_reset_password/new.html.heex @@ -18,10 +18,12 @@
- <%= link(dgettext("actions", "Register"), - to: Routes.user_registration_path(@conn, :new), - class: "btn btn-primary" - ) %> + <%= if Accounts.allow_registration?() do %> + <%= link(dgettext("actions", "Register"), + to: Routes.user_registration_path(@conn, :new), + class: "btn btn-primary" + ) %> + <% end %> <%= link(dgettext("actions", "Log in"), to: Routes.user_session_path(@conn, :new), class: "btn btn-primary" diff --git a/lib/cannery_web/templates/user_session/new.html.heex b/lib/cannery_web/templates/user_session/new.html.heex index c63baa9f..f0c2b810 100644 --- a/lib/cannery_web/templates/user_session/new.html.heex +++ b/lib/cannery_web/templates/user_session/new.html.heex @@ -37,10 +37,12 @@
- <%= link(dgettext("actions", "Register"), - to: Routes.user_registration_path(@conn, :new), - class: "btn btn-primary" - ) %> + <%= if Accounts.allow_registration?() do %> + <%= link(dgettext("actions", "Register"), + to: Routes.user_registration_path(@conn, :new), + class: "btn btn-primary" + ) %> + <% end %> <%= link(dgettext("actions", "Forgot your password?"), to: Routes.user_reset_password_path(@conn, :new), class: "btn btn-primary" diff --git a/lib/cannery_web/views/user_confirmation_view.ex b/lib/cannery_web/views/user_confirmation_view.ex index cca8441a..08bc492e 100644 --- a/lib/cannery_web/views/user_confirmation_view.ex +++ b/lib/cannery_web/views/user_confirmation_view.ex @@ -1,3 +1,4 @@ defmodule CanneryWeb.UserConfirmationView do use CanneryWeb, :view + alias Cannery.Accounts end diff --git a/lib/cannery_web/views/user_reset_password_view.ex b/lib/cannery_web/views/user_reset_password_view.ex index cc5e1378..aa16a365 100644 --- a/lib/cannery_web/views/user_reset_password_view.ex +++ b/lib/cannery_web/views/user_reset_password_view.ex @@ -1,3 +1,4 @@ defmodule CanneryWeb.UserResetPasswordView do use CanneryWeb, :view + alias Cannery.Accounts end diff --git a/lib/cannery_web/views/user_session_view.ex b/lib/cannery_web/views/user_session_view.ex index 2cb6390f..ef414f77 100644 --- a/lib/cannery_web/views/user_session_view.ex +++ b/lib/cannery_web/views/user_session_view.ex @@ -1,3 +1,4 @@ defmodule CanneryWeb.UserSessionView do use CanneryWeb, :view + alias Cannery.Accounts end