From 692f2eb0e0a63b20113398d1c4d3d43bc76c5e8f Mon Sep 17 00:00:00 2001 From: valentinkolb Date: Thu, 16 May 2024 16:00:01 +0200 Subject: [PATCH] fix(ldapSync): bug fix - don't delete guests This fixes the issue where the ldap sync deleted all guest users after one day --- ldapSync/ldapSync.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ldapSync/ldapSync.go b/ldapSync/ldapSync.go index c10a023..b358ed7 100644 --- a/ldapSync/ldapSync.go +++ b/ldapSync/ldapSync.go @@ -181,13 +181,13 @@ func syncLdapUsers(app *pocketbase.PocketBase, ldapClient *ldap.Conn) SyncResult var removedCount int // remove old users - // step1: get a timeStamp one day ago - timeStamp := time.Now().AddDate(0, 0, -1) + // step1: get a timeStamp ten minutes ago + timeStamp := time.Now().Add(time.Minute * -10) // step2: get all users that have not been synced since that timeStamp records, err := app.Dao().FindRecordsByFilter( ldapUsersTableName, - "updated < {:timeStamp}", "", 0, 0, + "updated < {:timeStamp} && REALM = 'LDAP'", "", 0, 0, dbx.Params{"timeStamp": timeStamp}, )