mirror of
https://github.com/netbirdio/netbird.git
synced 2025-06-19 17:31:39 +02:00
updated PAT struct to only use user id instead of user
This commit is contained in:
parent
b3f339c753
commit
2f2d45de9e
@ -17,12 +17,12 @@ type PersonalAccessToken struct {
|
|||||||
HashedToken [32]byte
|
HashedToken [32]byte
|
||||||
ExpirationDate time.Time
|
ExpirationDate time.Time
|
||||||
// scope could be added in future
|
// scope could be added in future
|
||||||
CreatedBy User // should we add that?
|
CreatedBy string
|
||||||
CreatedAt time.Time
|
CreatedAt time.Time
|
||||||
LastUsed time.Time
|
LastUsed time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateNewPAT(description string, expirationInDays int, createdBy User) (*PersonalAccessToken, string) {
|
func CreateNewPAT(description string, expirationInDays int, createdBy string) (*PersonalAccessToken, string) {
|
||||||
hashedToken, plainToken := generateNewToken()
|
hashedToken, plainToken := generateNewToken()
|
||||||
currentTime := time.Now().UTC()
|
currentTime := time.Now().UTC()
|
||||||
return &PersonalAccessToken{
|
return &PersonalAccessToken{
|
||||||
|
@ -18,7 +18,7 @@ func TestPAT_GenerateToken_Hashing(t *testing.T) {
|
|||||||
|
|
||||||
func TestPAT_GenerateToken_Prefix(t *testing.T) {
|
func TestPAT_GenerateToken_Prefix(t *testing.T) {
|
||||||
_, plainToken := generateNewToken()
|
_, plainToken := generateNewToken()
|
||||||
fourLetterPrefix := plainToken[:4] // should be 3
|
fourLetterPrefix := plainToken[:4]
|
||||||
assert.Equal(t, "nbp_", fourLetterPrefix)
|
assert.Equal(t, "nbp_", fourLetterPrefix)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user