diff --git a/beszel/internal/hub/hub.go b/beszel/internal/hub/hub.go index fdb9125..b69c8f6 100644 --- a/beszel/internal/hub/hub.go +++ b/beszel/internal/hub/hub.go @@ -80,11 +80,18 @@ func (h *Hub) Run() { return err } // disable email auth if DISABLE_PASSWORD_AUTH env var is set - if os.Getenv("DISABLE_PASSWORD_AUTH") == "true" { - usersCollection.PasswordAuth.Enabled = false + usersCollection.PasswordAuth.Enabled = os.Getenv("DISABLE_PASSWORD_AUTH") != "true" + usersCollection.PasswordAuth.IdentityFields = []string{"email"} + // disable oauth if no providers are configured (todo: remove this in post 0.9.0 release) + if usersCollection.OAuth2.Enabled { + usersCollection.OAuth2.Enabled = len(usersCollection.OAuth2.Providers) > 0 + } + // allow oauth user creation if USER_CREATION is set + if os.Getenv("USER_CREATION") == "true" { + cr := "@request.context = 'oauth2'" + usersCollection.CreateRule = &cr } else { - usersCollection.PasswordAuth.Enabled = true - usersCollection.PasswordAuth.IdentityFields = []string{"email"} + usersCollection.CreateRule = nil } if err := h.app.Save(usersCollection); err != nil { return err diff --git a/beszel/migrations/1732489917_collections_snapshot.go b/beszel/migrations/1732489917_collections_snapshot.go index d9375a9..b32c970 100644 --- a/beszel/migrations/1732489917_collections_snapshot.go +++ b/beszel/migrations/1732489917_collections_snapshot.go @@ -317,20 +317,12 @@ func init() { }, { "authAlert": { - "emailTemplate": { - "body": "
Hello,
\nWe noticed a login to your {APP_NAME} account from a new location.
\nIf this was you, you may disregard this email.
\nIf this wasn't you, you should immediately change your {APP_NAME} account password to revoke access from all other locations.
\n\n Thanks,
\n {APP_NAME} team\n
Hello,
\nClick on the button below to confirm your new email address.
\n\n Confirm new email\n
\nIf you didn't ask to change your email address, you can ignore this email.
\n\n Thanks,
\n {APP_NAME} team\n
Hello,
\nYour one-time password is: {OTP}
\nIf you didn't ask for the one-time password, you can ignore this email.
\n\n Thanks,
\n {APP_NAME} team\n
Hello,
\nClick on the button below to reset your password.
\n\n Reset password\n
\nIf you didn't ask to reset your password, you can ignore this email.
\n\n Thanks,
\n {APP_NAME} team\n
Hello,
\nThank you for joining us at {APP_NAME}.
\nClick on the button below to verify your email address.
\n\n Verify\n
\n\n Thanks,
\n {APP_NAME} team\n
Hello,
\nWe noticed a login to your {APP_NAME} account from a new location.
\nIf this was you, you may disregard this email.
\nIf this wasn't you, you should immediately change your {APP_NAME} account password to revoke access from all other locations.
\n\n Thanks,
\n {APP_NAME} team\n
Hello,
\nClick on the button below to confirm your new email address.
\n\n Confirm new email\n
\nIf you didn't ask to change your email address, you can ignore this email.
\n\n Thanks,
\n {APP_NAME} team\n
Hello,
\nYour one-time password is: {OTP}
\nIf you didn't ask for the one-time password, you can ignore this email.
\n\n Thanks,
\n {APP_NAME} team\n
Hello,
\nClick on the button below to reset your password.
\n\n Reset password\n
\nIf you didn't ask to reset your password, you can ignore this email.
\n\n Thanks,
\n {APP_NAME} team\n
Hello,
\nThank you for joining us at {APP_NAME}.
\nClick on the button below to verify your email address.
\n\n Verify\n
\n\n Thanks,
\n {APP_NAME} team\n