rework a ton of code

This commit is contained in:
2026-04-03 18:51:27 -04:00
parent e2531e3021
commit a315161ed3
2 changed files with 67 additions and 179 deletions

View File

@@ -24,12 +24,12 @@ var (
var (
sessionManager = session.GetSessionManager()
ldapServer *ldap.LDAPServer
LDAPServer *ldap.LDAPServer
baseDN string
BaseDN string
serviceUserBindDN string
serviceUserPassword string
ServiceUserBindDN string
ServiceUserPassword string
)
func ReadBlankPhoto() {
@@ -97,8 +97,8 @@ func UploadPhotoHandler(w http.ResponseWriter, r *http.Request) {
http.Error(w, "Failed to read file", http.StatusInternalServerError)
return
}
userDN := fmt.Sprintf("uid=%s,cn=users,cn=accounts,%s", sessionData.UserID, baseDN)
ldapServer.ModifyAttribute(serviceUserBindDN, serviceUserPassword, userDN, "jpegphoto", []string{string(data)})
userDN := fmt.Sprintf("uid=%s,cn=users,cn=accounts,%s", sessionData.UserID, BaseDN)
LDAPServer.ModifyAttribute(ServiceUserBindDN, ServiceUserPassword, userDN, "jpegphoto", []string{string(data)})
CreateUserPhoto(sessionData.UserID, data)
}
@@ -124,9 +124,9 @@ func AvatarHandler(w http.ResponseWriter, r *http.Request) {
photoCreatedMutex.Unlock()
}
userSearch, err := ldapServer.SerchServer(
serviceUserBindDN, serviceUserPassword,
baseDN,
userSearch, err := LDAPServer.SerchServer(
ServiceUserBindDN, ServiceUserPassword,
BaseDN,
fmt.Sprintf("(&(objectClass=inetOrgPerson)(uid=%s))", ldap.LDAPEscapeFilter(username)),
[]string{"jpegphoto"},
)