photoprism/internal/entity/passcode_json.go
Michael Mayer f2aabb9bcd Security: Add gosec fixes with shared URL and fs validation helpers
Signed-off-by: Michael Mayer <michael@photoprism.app>
2026-03-03 16:38:41 +01:00

33 lines
965 B
Go

package entity
import (
"encoding/json"
"time"
"github.com/photoprism/photoprism/pkg/media"
)
// MarshalJSON returns the JSON encoding.
func (m *Passcode) MarshalJSON() ([]byte, error) {
return json.Marshal(&struct {
UID string `json:"UID"`
Type string `json:"Type"`
Secret string `json:"Secret"` //nolint:gosec // G117: Expected passcode secret response field.
QRCode string `json:"QRCode"`
RecoveryCode string `json:"RecoveryCode"`
CreatedAt time.Time `json:"CreatedAt"`
UpdatedAt time.Time `json:"UpdatedAt"`
VerifiedAt *time.Time `json:"VerifiedAt"`
ActivatedAt *time.Time `json:"ActivatedAt"`
}{
UID: m.UID,
Type: m.KeyType,
Secret: m.Secret(),
QRCode: media.DataUrl(m.Png(350)),
RecoveryCode: m.RecoveryCode,
CreatedAt: m.CreatedAt,
UpdatedAt: m.UpdatedAt,
VerifiedAt: m.VerifiedAt,
ActivatedAt: m.ActivatedAt,
})
}