features/client-side-settings #3
9
domain/consts.go
Normal file
9
domain/consts.go
Normal file
@ -0,0 +1,9 @@
|
||||
package domain
|
||||
|
||||
const (
|
||||
CookieToken = "token"
|
||||
CookieRefreshToken = "refresh"
|
||||
CookieUser = "user"
|
||||
|
||||
CookieSettingsDarkMode = "darkmode"
|
||||
)
|
@ -3,6 +3,7 @@ package handlers
|
||||
import (
|
||||
"errors"
|
||||
"templ-test/client"
|
||||
"templ-test/domain"
|
||||
"templ-test/models"
|
||||
"templ-test/services"
|
||||
"time"
|
||||
@ -13,12 +14,6 @@ import (
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
const (
|
||||
CookieToken = "token"
|
||||
CookieRefreshToken = "refresh"
|
||||
CookieUser = "user"
|
||||
)
|
||||
|
||||
type Handlers struct {
|
||||
api client.ApiClient
|
||||
cfg services.EnvConfig
|
||||
@ -91,17 +86,17 @@ func ValidateJwt(ctx echo.Context, sharedSecret, issuer string) (jwtToken, error
|
||||
func GetCookieValues(ctx echo.Context) models.AllCookies {
|
||||
m := models.AllCookies{}
|
||||
|
||||
token, err := ctx.Cookie(CookieToken)
|
||||
token, err := ctx.Cookie(domain.CookieToken)
|
||||
if err == nil {
|
||||
m.Token = token.Value
|
||||
}
|
||||
|
||||
user, err := ctx.Cookie(CookieUser)
|
||||
user, err := ctx.Cookie(domain.CookieUser)
|
||||
if err == nil {
|
||||
m.Username = user.Value
|
||||
}
|
||||
|
||||
refresh, err := ctx.Cookie(CookieRefreshToken)
|
||||
refresh, err := ctx.Cookie(domain.CookieRefreshToken)
|
||||
if err == nil {
|
||||
m.RefreshToken = refresh.Value
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user