implemented login logic

This commit is contained in:
2026-03-11 19:23:58 +01:00
parent ebfe80133c
commit 744dd7f42d
6 changed files with 106 additions and 15 deletions
+3 -2
View File
@@ -3,6 +3,7 @@ package main
import (
"errors"
"fmt"
"strconv"
"time"
"github.com/golang-jwt/jwt/v5"
@@ -11,10 +12,10 @@ import (
var secretKey = []byte("replace-with-env-variable")
func GetToken(userID string) (string, error) {
func GetToken(user *User) (string, error) {
token := jwt.NewWithClaims(jwt.SigningMethodHS256,
jwt.RegisteredClaims{
Subject: userID,
Subject: strconv.Itoa(int(user.Id)),
ExpiresAt: jwt.NewNumericDate(time.Now().Add(time.Hour)),
IssuedAt: jwt.NewNumericDate(time.Now()),
},