refactor to use name instead of description

This commit is contained in:
Pascal Fischer
2023-03-27 16:28:49 +02:00
parent 9e74f30d2f
commit c65a934107
5 changed files with 18 additions and 42 deletions

View File

@@ -25,7 +25,7 @@ const (
// PersonalAccessToken holds all information about a PAT including a hashed version of it for verification
type PersonalAccessToken struct {
ID string
Description string
Name string
HashedToken string
ExpirationDate time.Time
// scope could be added in future
@@ -36,7 +36,7 @@ type PersonalAccessToken struct {
// CreateNewPAT will generate a new PersonalAccessToken that can be assigned to a User.
// Additionally, it will return the token in plain text once, to give to the user and only save a hashed version
func CreateNewPAT(description string, expirationInDays int, createdBy string) (*PersonalAccessToken, string, error) {
func CreateNewPAT(name string, expirationInDays int, createdBy string) (*PersonalAccessToken, string, error) {
hashedToken, plainToken, err := generateNewToken()
if err != nil {
return nil, "", err
@@ -44,7 +44,7 @@ func CreateNewPAT(description string, expirationInDays int, createdBy string) (*
currentTime := time.Now().UTC()
return &PersonalAccessToken{
ID: xid.New().String(),
Description: description,
Name: name,
HashedToken: hashedToken,
ExpirationDate: currentTime.AddDate(0, 0, expirationInDays),
CreatedBy: createdBy,