Skip to content

Commit

Permalink
Improve [Storage] Info 2FA Manager (#93)
Browse files Browse the repository at this point in the history
- [+] 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.
  • Loading branch information
H0llyW00dzZ authored May 30, 2024
1 parent a9ebae9 commit 82159c8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 82159c8

Please sign in to comment.