feature: extend setup key logic

This commit is contained in:
braginini
2021-08-19 21:12:21 +02:00
parent c68d9dff4a
commit 02cc6a30f5
3 changed files with 87 additions and 20 deletions

View File

@@ -19,6 +19,7 @@ type SetupKeyResponse struct {
Name string
Expires time.Time
Type string
Valid bool
}
func NewSetupKeysHandler(accountManager *server.AccountManager) *SetupKeys {
@@ -45,9 +46,10 @@ func (h *SetupKeys) ServeHTTP(w http.ResponseWriter, r *http.Request) {
for _, key := range account.SetupKeys {
respBody = append(respBody, &SetupKeyResponse{
Key: key.Key,
Name: key.Key,
Expires: time.Now().Add(30 * (time.Second * 60 * 60 * 24)),
Type: "reusable",
Name: key.Name,
Expires: key.ExpiresAt,
Type: string(key.Type),
Valid: key.IsValid(),
})
}