fix dpop token json serialization to db

pull/1671/head
beltram 1 year ago committed by Herman Slatman
parent 613e6cae6e
commit 03dbd91418
No known key found for this signature in database
GPG Key ID: F4D8A44EA0A75A4F

@ -11,9 +11,9 @@ import (
)
type dbDpop struct {
ID string `json:"id"`
Content map[string]interface{} `json:"content"`
CreatedAt time.Time `json:"createdAt"`
ID string `json:"id"`
Content []byte `json:"content"`
CreatedAt time.Time `json:"createdAt"`
}
// getDBDpop retrieves and unmarshals an DPoP type from the database.
@ -38,17 +38,23 @@ func (db *DB) GetDpop(ctx context.Context, orderId string) (map[string]interface
return nil, err
}
dpop := dbDpop.Content
dpop := make(map[string]interface{})
err = json.Unmarshal(dbDpop.Content, &dpop)
return dpop, nil
return dpop, err
}
// CreateDpop creates DPoP resources and saves them to the DB.
func (db *DB) CreateDpop(ctx context.Context, orderId string, dpop map[string]interface{}) error {
content, err := json.Marshal(dpop)
if err != nil {
return err
}
now := clock.Now()
dbDpop := &dbDpop{
ID: orderId,
Content: dpop,
Content: content,
CreatedAt: now,
}
if err := db.save(ctx, orderId, dbDpop, nil, "dpop", dpopTable); err != nil {

Loading…
Cancel
Save