mirror of
https://github.com/go-gitea/gitea.git
synced 2026-11-05 00:09:33 +09:00
Remove the `UnmarshalHandleDoubleEncode` runtime workaround for an old xorm bug, and normalize legacy double-encoded JSON in `repo_unit.config` and `login_source.cfg` with a migration instead. - Config `FromDB` no longer fails on corrupted values. A broken auth source is deactivated, so admins can still fix it in the admin panel - Remove `ProjectsConfig.GetProjectsMode`, `FromDB` already defaults `ProjectsMode` Actually it doesn't need so many changes, just because AI thinks it should handle "corrupted database value" for auth sources. --------- Signed-off-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: silverwind <me@silverwind.io>
52 lines
1.0 KiB
Go
52 lines
1.0 KiB
Go
// Copyright 2021 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package smtp
|
|
|
|
import (
|
|
"gitea.dev/models/auth"
|
|
"gitea.dev/modules/json"
|
|
)
|
|
|
|
// Source holds configuration for the SMTP login source.
|
|
type Source struct {
|
|
auth.ConfigBase `json:"-"`
|
|
|
|
Auth string
|
|
Host string
|
|
Port int
|
|
AllowedDomains string `xorm:"TEXT"`
|
|
ForceSMTPS bool
|
|
SkipVerify bool
|
|
HeloHostname string
|
|
DisableHelo bool
|
|
}
|
|
|
|
func (source *Source) FromDB(bs []byte) error {
|
|
auth.UnmarshalAuthSourceConfig(bs, source)
|
|
return nil
|
|
}
|
|
|
|
func (source *Source) ToDB() ([]byte, error) {
|
|
return json.Marshal(source)
|
|
}
|
|
|
|
// IsSkipVerify returns if SkipVerify is set
|
|
func (source *Source) IsSkipVerify() bool {
|
|
return source.SkipVerify
|
|
}
|
|
|
|
// HasTLS returns true for SMTP
|
|
func (source *Source) HasTLS() bool {
|
|
return true
|
|
}
|
|
|
|
// UseTLS returns if TLS is set
|
|
func (source *Source) UseTLS() bool {
|
|
return source.ForceSMTPS || source.Port == 465
|
|
}
|
|
|
|
func init() {
|
|
auth.RegisterTypeConfig(auth.SMTP, &Source{})
|
|
}
|