1
0
mirror of https://github.com/H0llyW00dzZ/fiber2fa.git synced 2025-02-06 10:24:03 +00:00

Improve [Storage] Info 2FA Manager (#93)

- [+] refactor(storage.go): make several Info struct fields optional in JSON serialization
- [+] The `omitempty` JSON tag option is added to the `ContextKey`, `CookieValue`, `ExpirationTime`, `Identifier`, and `QRCodeData` fields of the `Info` struct. This allows omitting these fields from the JSON representation when their values are empty or zero.
This commit is contained in:
H0llyW00dzZ 2024-05-30 20:20:41 +07:00 committed by GitHub
parent a9ebae96de
commit 82159c8725
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -28,13 +28,13 @@ type InfoManager interface {
// Info represents the 2FA information stored for a user.
type Info struct {
ContextKey string `json:"contextkey"`
ContextKey string `json:"contextkey,omitempty"`
Secret string `json:"secret"`
CookieValue string `json:"cookie"`
ExpirationTime time.Time `json:"expiration"`
CookieValue string `json:"cookie,omitempty"`
ExpirationTime time.Time `json:"expiration,omitempty"`
Registered bool `json:"registered"`
Identifier string `json:"identifier"`
QRCodeData []byte `json:"qrcodedata"`
Identifier string `json:"identifier,omitempty"`
QRCodeData []byte `json:"qrcodedata,omitempty"`
}
// NewInfo creates a new empty Info struct based on the provided Config.