mirror of
https://github.com/thomiceli/opengist.git
synced 2025-07-12 19:01:50 +02:00
Add require login feature to see gists
This commit is contained in:
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user