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 (
|
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
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user