Add require login feature to see gists

This commit is contained in:
Thomas Miceli
2023-04-28 20:31:10 +02:00
parent 64d0818c9f
commit 333efeacbf
12 changed files with 77 additions and 23 deletions

View File

@ -18,10 +18,8 @@ import (
"strings"
)
type providerKeyType string
type dataTypeKey string
const providerKey providerKeyType = "provider"
const dataKey dataTypeKey = "data"
func setData(ctx echo.Context, key string, value any) {
@ -110,6 +108,20 @@ func deleteCsrfCookie(ctx echo.Context) {
ctx.SetCookie(&http.Cookie{Name: "_csrf", Path: "/", MaxAge: -1})
}
func loadSettings(ctx echo.Context) error {
settings, err := models.GetSettings()
if err != nil {
return err
}
for key, value := range settings {
s := strings.ReplaceAll(key, "-", " ")
s = title.String(s)
setData(ctx, strings.ReplaceAll(s, " ", ""), value == "1")
}
return nil
}
type OpengistValidator struct {
v *validator.Validate
}