Make name optional

This commit is contained in:
Tracker-Friendly 2024-05-06 12:55:04 +01:00
parent 85b2af8225
commit 66cd1defd8
1 changed files with 19 additions and 17 deletions

View File

@ -355,6 +355,8 @@ func main() {
}) })
router.GET("/app", func(c *gin.Context) { router.GET("/app", func(c *gin.Context) {
name := ""
if c.Request.URL.Query().Get("client_id") != "" {
conn := get_db_connection() conn := get_db_connection()
defer func(conn *sql.DB) { defer func(conn *sql.DB) {
err := conn.Close() err := conn.Close()
@ -366,7 +368,6 @@ func main() {
}(conn) }(conn)
appId := c.Request.URL.Query().Get("client_id") appId := c.Request.URL.Query().Get("client_id")
var name string
err := conn.QueryRow("SELECT name FROM oauth WHERE appId = ? LIMIT 1", appId).Scan(&name) err := conn.QueryRow("SELECT name FROM oauth WHERE appId = ? LIMIT 1", appId).Scan(&name)
if err != nil { if err != nil {
if errors.Is(err, sql.ErrNoRows) { if errors.Is(err, sql.ErrNoRows) {
@ -376,6 +377,7 @@ func main() {
} }
return return
} }
}
c.HTML(200, "main.html", gin.H{"name": name}) c.HTML(200, "main.html", gin.H{"name": name})
}) })