features/client-side-settings #3

Merged
jtom38 merged 12 commits from features/client-side-settings into main 2024-04-14 19:40:30 -07:00
2 changed files with 14 additions and 10 deletions
Showing only changes of commit 03d151f75a - Show all commits

9
domain/consts.go Normal file
View File

@ -0,0 +1,9 @@
package domain
const (
CookieToken = "token"
CookieRefreshToken = "refresh"
CookieUser = "user"
CookieSettingsDarkMode = "darkmode"
)

View File

@ -3,6 +3,7 @@ package handlers
import ( import (
"errors" "errors"
"templ-test/client" "templ-test/client"
"templ-test/domain"
"templ-test/models" "templ-test/models"
"templ-test/services" "templ-test/services"
"time" "time"
@ -13,12 +14,6 @@ import (
"github.com/labstack/echo/v4" "github.com/labstack/echo/v4"
) )
const (
CookieToken = "token"
CookieRefreshToken = "refresh"
CookieUser = "user"
)
type Handlers struct { type Handlers struct {
api client.ApiClient api client.ApiClient
cfg services.EnvConfig cfg services.EnvConfig
@ -91,17 +86,17 @@ func ValidateJwt(ctx echo.Context, sharedSecret, issuer string) (jwtToken, error
func GetCookieValues(ctx echo.Context) models.AllCookies { func GetCookieValues(ctx echo.Context) models.AllCookies {
m := models.AllCookies{} m := models.AllCookies{}
token, err := ctx.Cookie(CookieToken) token, err := ctx.Cookie(domain.CookieToken)
if err == nil { if err == nil {
m.Token = token.Value m.Token = token.Value
} }
user, err := ctx.Cookie(CookieUser) user, err := ctx.Cookie(domain.CookieUser)
if err == nil { if err == nil {
m.Username = user.Value m.Username = user.Value
} }
refresh, err := ctx.Cookie(CookieRefreshToken) refresh, err := ctx.Cookie(domain.CookieRefreshToken)
if err == nil { if err == nil {
m.RefreshToken = refresh.Value m.RefreshToken = refresh.Value
} }