Skip to content

Commit

Permalink
feat: add option to disable magic links
Browse files Browse the repository at this point in the history
  • Loading branch information
hf committed Sep 2, 2024
1 parent bf276ab commit 015fc95
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/api/magic_link.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions internal/conf/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ type AnonymousProviderConfiguration struct {

type EmailProviderConfiguration struct {
Enabled bool `json:"enabled" default:"true"`

MagicLinkEnabled bool `json:"enabled" default:"true" split_words:"true"`

Check failure on line 75 in internal/conf/configuration.go

View workflow job for this annotation

GitHub Actions / test (1.22.x)

struct field MagicLinkEnabled repeats json tag "enabled" also at configuration.go:73
}

// DBConfiguration holds all the database related configuration.
Expand Down

0 comments on commit 015fc95

Please sign in to comment.