Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 邮箱后缀支持配置化自定义 #270

Merged
merged 1 commit into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down Expand Up @@ -143,4 +145,4 @@ feishu:
dept-list: # 配置要同步的部门列表,配置留空则同步所有部门,在开头加^表示不同步此部门
#- "48456726" # 需要同步的部门ID
#- "^61213417" # 不需要同步的部门ID
is-update-syncd: false # 当飞书用户的邮箱,手机号,部门等信息更新之后,是否同步更新,默认为false,如果你不了解这个字段的含义,则不建议开启
is-update-syncd: false # 当飞书用户的邮箱,手机号,部门等信息更新之后,是否同步更新,默认为false,如果你不了解这个字段的含义,则不建议开启
19 changes: 10 additions & 9 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,16 @@ type RateLimitConfig struct {
}

type LdapConfig struct {
Url string `mapstructure:"url" json:"url"`
MaxConn int `mapstructure:"max-conn" json:"maxConn"`
BaseDN string `mapstructure:"base-dn" json:"baseDN"`
AdminDN string `mapstructure:"admin-dn" json:"adminDN"`
AdminPass string `mapstructure:"admin-pass" json:"adminPass"`
UserDN string `mapstructure:"user-dn" json:"userDN"`
UserInitPassword string `mapstructure:"user-init-password" json:"userInitPassword"`
GroupNameModify bool `mapstructure:"group-name-modify" json:"groupNameModify"`
UserNameModify bool `mapstructure:"user-name-modify" json:"userNameModify"`
Url string `mapstructure:"url" json:"url"`
MaxConn int `mapstructure:"max-conn" json:"maxConn"`
BaseDN string `mapstructure:"base-dn" json:"baseDN"`
AdminDN string `mapstructure:"admin-dn" json:"adminDN"`
AdminPass string `mapstructure:"admin-pass" json:"adminPass"`
UserDN string `mapstructure:"user-dn" json:"userDN"`
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"`
Expand Down
7 changes: 6 additions & 1 deletion logic/a_logic.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,12 @@ func CommonAddUser(user *model.User, groups []*model.Group) error {
user.Introduction = user.Nickname
}
if user.Mail == "" {
user.Mail = user.Username + "@eryajf.net"
// 兼容
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"
Expand Down
Loading