package ldap import ( "nginx-ui/server/base" "nginx-ui/server/models" ) type UserController struct { base.Controller } func (c *UserController) Login() { req := LDAPLoginReq{} if c.ReadBody(&req) == false { return } user, err := ServiceInstance.Login(&req) if err != nil { c.ErrorJson(err) return } user.Password = "" c.SetSession("user", *user) c.PostJson(models.SuccessResp(user)) } // SyncUsers 同步用户信息 // post /ldap/user/sync func (c *UserController) SyncUsers() { current := c.RequiredUser() if current == nil { return } req := LDAPUserSyncReq{} if !c.ReadBody(&req) { return } count, err := ServiceInstance.SyncUsers(current, &req) if err != nil { c.ErrorJson(err) return } resp := make(map[string]interface{}) resp["count"] = count c.SetData(resp).Json() } // UpdateUserPassword 更新用户密码 // post /ldap/user/modifyPassword func (c *UserController) UpdateUserPassword() { } // UpdateUser 更新用户信息或者新增用户 // post /ldap/user/save func (c *UserController) UpdateUser() { } // GetUsers 获取全部用户 // get /ldap/users func (c *UserController) GetUsers() { current := c.RequiredUser() if current == nil { return } req := UserListReq{} if !c.ReadBody(&req) { return } resp, err := ServiceInstance.GetUsers(current, &req) if err != nil { c.ErrorJson(err) return } c.SetData(resp).Json() }