diff --git a/internal/web/auth.go b/internal/web/auth.go index 9bc8d58..9861d8c 100644 --- a/internal/web/auth.go +++ b/internal/web/auth.go @@ -26,6 +26,7 @@ var title = cases.Title(language.English) func register(ctx echo.Context) error { setData(ctx, "title", "New account") setData(ctx, "htmlTitle", "New account") + setData(ctx, "disableForm", getData(ctx, "DisableLoginForm")) return html(ctx, "auth_form.html") } @@ -34,6 +35,10 @@ func processRegister(ctx echo.Context) error { return errorRes(403, "Signing up is disabled", nil) } + if getData(ctx, "DisableLoginForm") == true { + return errorRes(403, "Signing up via registration form is disabled", nil) + } + setData(ctx, "title", "New account") setData(ctx, "htmlTitle", "New account") @@ -81,10 +86,15 @@ func processRegister(ctx echo.Context) error { func login(ctx echo.Context) error { setData(ctx, "title", "Login") setData(ctx, "htmlTitle", "Login") + setData(ctx, "disableForm", getData(ctx, "DisableLoginForm")) return html(ctx, "auth_form.html") } func processLogin(ctx echo.Context) error { + if getData(ctx, "DisableLoginForm") == true { + return errorRes(403, "Logging in via login form is disabled", nil) + } + var err error sess := getSession(ctx) diff --git a/public/admin.ts b/public/admin.ts index d980530..4dffe80 100644 --- a/public/admin.ts +++ b/public/admin.ts @@ -1,6 +1,7 @@ document.addEventListener('DOMContentLoaded', () => { registerDomSetting(document.getElementById('disable-signup') as HTMLInputElement); registerDomSetting(document.getElementById('require-login') as HTMLInputElement); + registerDomSetting(document.getElementById('disable-login-form') as HTMLInputElement); }); const setSetting = (key: string, value: string) => { diff --git a/templates/pages/admin_index.html b/templates/pages/admin_index.html index c8fe35c..d59e0d9 100644 --- a/templates/pages/admin_index.html +++ b/templates/pages/admin_index.html @@ -84,9 +84,13 @@