fix
This commit is contained in:
parent
48f63db5eb
commit
b21a2beff8
|
@ -3,6 +3,8 @@ package logic
|
|||
import (
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"fusenapi/utils/ldap_lib"
|
||||
"strings"
|
||||
|
||||
"context"
|
||||
|
||||
|
@ -31,10 +33,19 @@ func NewDeleteLdapUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *De
|
|||
// }
|
||||
|
||||
func (l *DeleteLdapUserLogic) DeleteLdapUser(req *types.DeleteLdapUserReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
||||
// userinfo 传入值时, 一定不为null
|
||||
|
||||
return resp.SetStatus(basic.CodeOK)
|
||||
req.UserDN = strings.Trim(req.UserDN, " ")
|
||||
if len(req.UserDN) <= 3 || req.UserDN[:3] != "cn=" {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "无效的用户DN")
|
||||
}
|
||||
ldapServer := ldap_lib.NewLdap(l.svcCtx.Ldap, l.svcCtx.Config.Ldap.BaseDN, l.svcCtx.Config.Ldap.RootDN)
|
||||
err := ldapServer.Update(req.UserDN, map[string][]string{
|
||||
"postalCode": {"0"},
|
||||
})
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "删除用户失败,", err.Error())
|
||||
}
|
||||
return resp.SetStatusWithMessage(basic.CodeOK, "删除用户成功")
|
||||
}
|
||||
|
||||
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
|
||||
|
|
|
@ -107,9 +107,11 @@ type UpdateLdapUserReq struct {
|
|||
}
|
||||
|
||||
type DeleteLdapUserReq struct {
|
||||
UserDN string `json:"user_dn"` //用户dn
|
||||
}
|
||||
|
||||
type GetLdapUserInfoReq struct {
|
||||
UserDN string `json:"user_dn"` //用户dn
|
||||
}
|
||||
|
||||
type Request struct {
|
||||
|
|
|
@ -156,7 +156,9 @@ type UpdateLdapUserReq {
|
|||
}
|
||||
//删除ldap用户
|
||||
type DeleteLdapUserReq {
|
||||
UserDN string `json:"user_dn"` //用户dn
|
||||
}
|
||||
//获取ldap用户信息
|
||||
type GetLdapUserInfoReq {
|
||||
UserDN string `json:"user_dn"` //用户dn
|
||||
}
|
Loading…
Reference in New Issue
Block a user