From c9eefd96e9731fcc99dce2c801f56faf702415d8 Mon Sep 17 00:00:00 2001 From: Stojan Dimitrovski Date: Mon, 2 Sep 2024 10:58:18 +0200 Subject: [PATCH] feat: add option to disable magic links --- internal/api/magic_link.go | 4 ++++ internal/conf/configuration.go | 2 ++ 2 files changed, 6 insertions(+) diff --git a/internal/api/magic_link.go b/internal/api/magic_link.go index d7e941b79..e3fc0315b 100644 --- a/internal/api/magic_link.go +++ b/internal/api/magic_link.go @@ -46,6 +46,10 @@ func (a *API) MagicLink(w http.ResponseWriter, r *http.Request) error { return unprocessableEntityError(ErrorCodeEmailProviderDisabled, "Email logins are disabled") } + if !config.External.Email.MagicLinkEnabled { + return unprocessableEntityError(ErrorCodeEmailProviderDisabled, "Login with magic link is disabled") + } + params := &MagicLinkParams{} jsonDecoder := json.NewDecoder(r.Body) err := jsonDecoder.Decode(params) diff --git a/internal/conf/configuration.go b/internal/conf/configuration.go index 55d7a8fab..18b5c3ff9 100644 --- a/internal/conf/configuration.go +++ b/internal/conf/configuration.go @@ -71,6 +71,8 @@ type AnonymousProviderConfiguration struct { type EmailProviderConfiguration struct { Enabled bool `json:"enabled" default:"true"` + + MagicLinkEnabled bool `json:"magic_link_enabled" default:"true" split_words:"true"` } // DBConfiguration holds all the database related configuration.