mirror of
https://github.com/aunefyren/wrapperr
synced 2025-01-10 08:38:43 +00:00
787b00aebc
Different components moved to packages which are imported. More proper and clean compared to previous implementation.
26 lines
568 B
Go
26 lines
568 B
Go
package modules
|
|
|
|
import (
|
|
"aunefyren/wrapperr/models"
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// NewPayload creates a new token payload with a specific username and duration
|
|
func NewPayload(username string, admin bool, authtoken string, duration time.Duration) (*models.Payload, error) {
|
|
tokenID, err := uuid.NewRandom()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
payload := &models.Payload{
|
|
ID: tokenID,
|
|
Username: username,
|
|
Admin: admin,
|
|
AuthToken: authtoken,
|
|
IssuedAt: time.Now(),
|
|
ExpiredAt: time.Now().Add(duration),
|
|
}
|
|
return payload, nil
|
|
}
|