code cleanup

This commit is contained in:
Christoph Haas
2025-01-11 22:56:25 +01:00
parent 26d3257516
commit 63d85d8123
6 changed files with 31 additions and 22 deletions

View File

@@ -2,15 +2,21 @@ package users
import (
"fmt"
"strings"
"time"
"github.com/go-ldap/ldap/v3"
"github.com/h44z/wg-portal/internal"
"github.com/h44z/wg-portal/internal/config"
"github.com/h44z/wg-portal/internal/domain"
"strings"
"time"
)
func convertRawLdapUser(providerName string, rawUser map[string]any, fields *config.LdapFields, adminGroupDN *ldap.DN) (*domain.User, error) {
func convertRawLdapUser(
providerName string,
rawUser map[string]any,
fields *config.LdapFields,
adminGroupDN *ldap.DN,
) (*domain.User, error) {
now := time.Now()
isAdmin, err := internal.LdapIsMemberOf(rawUser[fields.GroupMembership].([][]byte), adminGroupDN)
@@ -20,8 +26,8 @@ func convertRawLdapUser(providerName string, rawUser map[string]any, fields *con
return &domain.User{
BaseModel: domain.BaseModel{
CreatedBy: "ldap_sync",
UpdatedBy: "ldap_sync",
CreatedBy: domain.CtxSystemLdapSyncer,
UpdatedBy: domain.CtxSystemLdapSyncer,
CreatedAt: now,
UpdatedAt: now,
},

View File

@@ -513,7 +513,7 @@ func (m Manager) updateLdapUsers(
err := m.users.SaveUser(tctx, user.Identifier, func(u *domain.User) (*domain.User, error) {
u.UpdatedAt = time.Now()
u.UpdatedBy = "ldap_sync"
u.UpdatedBy = domain.CtxSystemLdapSyncer
u.Email = user.Email
u.Firstname = user.Firstname
u.Lastname = user.Lastname