mirror of
https://github.com/pocket-id/pocket-id.git
synced 2026-08-19 11:26:25 +00:00
Sort hashes in-memory by created-at
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user