make jwt expiration consistent with cookies

This commit is contained in:
grumbulon 2023-01-20 10:10:27 -05:00
parent 002787c1fc
commit 1e5ba290c4

View file

@ -2,6 +2,7 @@ package api
import (
"fmt"
"time"
"git.freecumextremist.com/grumbulon/pomme/internal"
"github.com/go-chi/jwtauth/v5"
@ -16,7 +17,11 @@ func init() {
}
func makeToken(username string) (tokenString string, err error) {
if _, tokenString, err = tokenAuth.Encode(map[string]interface{}{"username": username, "admin": "false"}); err == nil {
claim := map[string]interface{}{"username": username, "admin": false}
jwtauth.SetExpiry(claim, time.Now().Add(time.Hour))
if _, tokenString, err = tokenAuth.Encode(claim); err == nil {
return
}