DEVELOPMENT ENVIRONMENT

~liljamo/tixe

ref: 08cdeb9c3b158d371dfa572be86655ebeef21beb tixe/handlers/settings.go -rw-r--r-- 996 bytes
08cdeb9cJonni Liljamo fix: update tag check in ci again 1 year, 1 month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
 * Copyright (C) 2023 Jonni Liljamo <jonni@liljamo.com>
 *
 * This file is licensed under AGPL-3.0-or-later, see NOTICE and LICENSE for
 * more information.
 */
package handlers

import (
	"net/http"
	"tixe/template"
	"tixe/types"

	"github.com/gin-contrib/sessions"
	"github.com/gin-gonic/gin"
)

type SettingsData struct {
}

func Settings(version string) gin.HandlerFunc {
	fn := func(c* gin.Context) {
		session := sessions.Default(c)
		user := session.Get("user").(types.User)

		// This now comes from the session data, but kept as reference for other things
		//var displayName string
		//_ = db.PgPool.QueryRow(context.Background(),
		//	"SELECT display_name FROM users WHERE id = $1", user.Id).Scan(&displayName)

		settingsData := SettingsData {
		}

		html := template.TmplEngine.Render("settings.tmpl", map[string]interface{}{"title": "settings", "user": user, "data": settingsData, "version": version})
		c.Data(http.StatusOK, "text/html", html)
	}

	return gin.HandlerFunc(fn)
}