feat: jwt token generation (todo: create jwt validation middleware)

This commit is contained in:
hexlocation 2025-05-05 23:04:50 +02:00
parent d8caef7e5d
commit b28b719b51
9 changed files with 86 additions and 29 deletions

View file

@ -2,8 +2,10 @@ package routes
import (
"net/http"
"time"
"github.com/gin-gonic/gin"
"stereo.cat/backend/internal/auth"
"stereo.cat/backend/internal/types"
)
@ -23,6 +25,12 @@ func RegisterAuthRoutes(cfg *types.StereoConfig, api *gin.RouterGroup) {
panic(err)
}
c.JSON(http.StatusOK, user)
jwt, err := auth.GenerateJWT(cfg.JWTSecret, user, uint64(time.Now().Add(time.Second*time.Duration(t.ExpiresIn)).Unix()))
if err != nil {
panic(err)
}
c.String(http.StatusOK, jwt)
})
}