code refactoring, fix jwt

This commit is contained in:
2023-09-25 11:12:18 +02:00
parent 9bb5d7bb0d
commit 764c1f4729
4 changed files with 11 additions and 12 deletions

View File

@@ -15,10 +15,6 @@ import (
"github.com/marcopeocchi/yt-dlp-web-ui/server/utils"
)
const (
TOKEN_COOKIE_NAME = "jwt"
)
type DirectoryEntry struct {
Name string `json:"name"`
Path string `json:"path"`

View File

@@ -8,6 +8,7 @@ import (
"github.com/goccy/go-json"
"github.com/golang-jwt/jwt/v5"
"github.com/marcopeocchi/yt-dlp-web-ui/server/config"
"github.com/marcopeocchi/yt-dlp-web-ui/server/utils"
)
type LoginRequest struct {
@@ -44,7 +45,7 @@ func Login(w http.ResponseWriter, r *http.Request) {
}
cookie := &http.Cookie{
Name: TOKEN_COOKIE_NAME,
Name: utils.TOKEN_COOKIE_NAME,
HttpOnly: true,
Secure: false,
Expires: expiresAt, // 30 days
@@ -57,7 +58,7 @@ func Login(w http.ResponseWriter, r *http.Request) {
func Logout(w http.ResponseWriter, r *http.Request) {
cookie := &http.Cookie{
Name: TOKEN_COOKIE_NAME,
Name: utils.TOKEN_COOKIE_NAME,
HttpOnly: true,
Secure: false,
Expires: time.Now(),