imports, comments and formatting

This commit is contained in:
2022-02-20 20:58:48 +00:00
parent 75a6ce1577
commit 91b8cc06b2
5 changed files with 39 additions and 40 deletions

View File

@ -10,10 +10,10 @@ import (
"github.com/google/uuid"
)
// TokenVerifier verifies Tokens
// TokenVerifier verifies Tokens.
type TokenVerifier struct{}
// Token contains everything to authenticate a user
// Token contains everything to authenticate a user.
type Token struct {
username string
name string
@ -26,7 +26,7 @@ const (
secret = "uditapbzuditagscwxuqdflgzpbu´ßiaefnlmzeßtrubiadern"
)
// CreateToken creates a new token from username and name
// CreateToken creates a new token from username and name.
func (tv *TokenVerifier) CreateToken(user *postgres.User) (string, error) {
token := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims{
"usr": user.Email,
@ -50,7 +50,7 @@ var (
ErrTokenExpired = fmt.Errorf("token has expired")
)
// VerifyToken verifys a given string-token
// VerifyToken verifys a given string-token.
func (tv *TokenVerifier) VerifyToken(tokenString string) (budgeteer.Token, error) {
token, err := jwt.Parse(tokenString, func(token *jwt.Token) (interface{}, error) {
if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok {