Sort hashes in-memory by created-at

This commit is contained in:
ItalyPaleAle
2026-08-09 17:56:57 -07:00
parent b1f072463e
commit e2ff72fc48
+6
View File
@@ -3,6 +3,7 @@ package model
import (
"database/sql/driver"
"encoding/json"
"slices"
"time"
datatype "github.com/pocket-id/pocket-id/backend/internal/model/types"
@@ -151,6 +152,11 @@ func (occ OidcClientCredentials) ActiveSecrets() []OidcClientSecret {
}
}
// Sort the copy so the primary hash is always the most recently created active secret
slices.SortStableFunc(active, func(a, b OidcClientSecret) int {
return b.CreatedAt.ToTime().Compare(a.CreatedAt.ToTime())
})
return active
}