Skip to content

Commit

Permalink
feature add (#270)
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-xiaowu authored Nov 9, 2023
1 parent ae087f2 commit cfa346f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
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

0 comments on commit cfa346f

Please sign in to comment.