mirror of
https://github.com/netbirdio/netbird.git
synced 2025-04-27 04:48:29 +02:00
last_used can be nil
This commit is contained in:
parent
0ca3d27a80
commit
3bab745142
@ -316,7 +316,6 @@ components:
|
|||||||
- expiration_date
|
- expiration_date
|
||||||
- created_by
|
- created_by
|
||||||
- created_at
|
- created_at
|
||||||
- last_used
|
|
||||||
PersonalAccessTokenGenerated:
|
PersonalAccessTokenGenerated:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
|
@ -394,7 +394,7 @@ type PersonalAccessToken struct {
|
|||||||
Id string `json:"id"`
|
Id string `json:"id"`
|
||||||
|
|
||||||
// LastUsed Date the token was last used
|
// LastUsed Date the token was last used
|
||||||
LastUsed time.Time `json:"last_used"`
|
LastUsed *time.Time `json:"last_used,omitempty"`
|
||||||
|
|
||||||
// Name Name of the token
|
// Name Name of the token
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
@ -3,6 +3,7 @@ package http
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
|
|
||||||
@ -187,13 +188,17 @@ func (h *PATHandler) DeleteToken(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func toPATResponse(pat *server.PersonalAccessToken) *api.PersonalAccessToken {
|
func toPATResponse(pat *server.PersonalAccessToken) *api.PersonalAccessToken {
|
||||||
|
var lastUsed *time.Time
|
||||||
|
if !pat.LastUsed.IsZero() {
|
||||||
|
lastUsed = &pat.LastUsed
|
||||||
|
}
|
||||||
return &api.PersonalAccessToken{
|
return &api.PersonalAccessToken{
|
||||||
CreatedAt: pat.CreatedAt,
|
CreatedAt: pat.CreatedAt,
|
||||||
CreatedBy: pat.CreatedBy,
|
CreatedBy: pat.CreatedBy,
|
||||||
Name: pat.Name,
|
Name: pat.Name,
|
||||||
ExpirationDate: pat.ExpirationDate,
|
ExpirationDate: pat.ExpirationDate,
|
||||||
Id: pat.ID,
|
Id: pat.ID,
|
||||||
LastUsed: pat.LastUsed,
|
LastUsed: lastUsed,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ func CreateNewPAT(name string, expirationInDays int, createdBy string) (*Persona
|
|||||||
ExpirationDate: currentTime.AddDate(0, 0, expirationInDays),
|
ExpirationDate: currentTime.AddDate(0, 0, expirationInDays),
|
||||||
CreatedBy: createdBy,
|
CreatedBy: createdBy,
|
||||||
CreatedAt: currentTime,
|
CreatedAt: currentTime,
|
||||||
LastUsed: currentTime,
|
LastUsed: time.Time{},
|
||||||
},
|
},
|
||||||
PlainToken: plainToken,
|
PlainToken: plainToken,
|
||||||
}, nil
|
}, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user