From 88461ea03db309d36c6bce1fb0cc05de0eaa1349 Mon Sep 17 00:00:00 2001 From: perp Date: Mon, 3 Jun 2024 14:51:42 +0100 Subject: [PATCH] Fixed incorrect types --- cmd/config.toml | 2 +- internal/jwt/encode.go | 2 +- internal/jwt/jwt.go | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/config.toml b/cmd/config.toml index ed04d5c..aeaad51 100644 --- a/cmd/config.toml +++ b/cmd/config.toml @@ -1,6 +1,6 @@ [auth] # JWT secret -secret = "a key" +secret = "a secret" # Disable registration disabled = false # bcrypt cost diff --git a/internal/jwt/encode.go b/internal/jwt/encode.go index 4013cde..26ed741 100644 --- a/internal/jwt/encode.go +++ b/internal/jwt/encode.go @@ -9,7 +9,7 @@ import ( ) // Encode a token -func Encode(id int) (string, error) { +func Encode(id int64) (string, error) { // Get time now := time.Now() diff --git a/internal/jwt/jwt.go b/internal/jwt/jwt.go index dd2f6f2..f584e21 100644 --- a/internal/jwt/jwt.go +++ b/internal/jwt/jwt.go @@ -3,15 +3,15 @@ package jwt import "github.com/golang-jwt/jwt" // JWT secret -var secret string +var secret []byte // JWT claims type Claims struct { jwt.StandardClaims - ID int `json:"id"` // User ID + ID int64 `json:"id"` // User ID } // Set the JWT secret func New(sec string) { - secret = sec + secret = []byte(sec) }