feature add (#270)

This commit is contained in:
xiaowu 2023-11-09 22:41:46 +08:00 committed by GitHub
parent ae087f2b38
commit cfa346fe6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 11 deletions

View File

@ -107,6 +107,8 @@ ldap:
group-name-modify: false
# 是否允许更改用户DN
user-name-modify: false
# 默认邮箱后缀
default-email-suffix: "eryajf.net"
# 📢 即便用不到如下三段配置信息,也不要删除,否则会有一些奇怪的错误出现
dingtalk:
# 配置获取详细文档参考: http://ldapdoc.eryajf.net/pages/94f43a/

View File

@ -149,6 +149,7 @@ type LdapConfig struct {
UserInitPassword string `mapstructure:"user-init-password" json:"userInitPassword"`
GroupNameModify bool `mapstructure:"group-name-modify" json:"groupNameModify"`
UserNameModify bool `mapstructure:"user-name-modify" json:"userNameModify"`
DefaultEmailSuffix string `mapstructure:"default-email-suffix" json:"defaultEmailSuffix"`
}
type EmailConfig struct {
Host string `mapstructure:"host" json:"host"`

View File

@ -96,8 +96,13 @@ func CommonAddUser(user *model.User, groups []*model.Group) error {
user.Introduction = user.Nickname
}
if user.Mail == "" {
// 兼容
if len(config.Conf.Ldap.DefaultEmailSuffix) > 0 {
user.Mail = user.Username + "@" + config.Conf.Ldap.DefaultEmailSuffix
} else {
user.Mail = user.Username + "@eryajf.net"
}
}
if user.JobNumber == "" {
user.JobNumber = "0000"
}