change kontor-gin templates
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 3s

This commit is contained in:
Thomas Peetz
2026-09-24 16:06:38 +02:00
parent ba83d70764
commit 131296c644
26 changed files with 333 additions and 419 deletions
+12 -12
View File
@@ -17,20 +17,20 @@ func LoginGetHandler(c *gin.Context) {
logger := slog.Get(c)
logger.Info("LoginGetHandler", globals.UserKey, user)
if user != nil {
c.HTML(http.StatusBadRequest, "login.html", gin.H{
c.HTML(http.StatusBadRequest, "login", gin.H{
"title": "Kontor Gin",
"version": "0.4.0",
"login": globals.LoginUrl,
"content": "Please logout first",
"message": "Please logout first",
"user": user,
})
return
}
c.HTML(http.StatusOK, "login.html", gin.H{
c.HTML(http.StatusOK, "login", gin.H{
"title": "Kontor Gin",
"version": "0.4.0",
"login": globals.LoginUrl,
"content": "",
"message": "",
"user": user,
})
}
@@ -41,11 +41,11 @@ func LoginPostHandler(c *gin.Context) {
logger := slog.Get(c)
logger.Info("LoginPostHandler", "user", user)
if user != nil {
c.HTML(http.StatusBadRequest, "login.html", gin.H{
c.HTML(http.StatusBadRequest, "login", gin.H{
"title": "Kontor Gin",
"version": "0.4.0",
"login": globals.LoginUrl,
"content": "Please logout first",
"message": "Please logout first",
})
return
}
@@ -54,30 +54,30 @@ func LoginPostHandler(c *gin.Context) {
password := c.PostForm("password")
if helpers.EmptyUserPass(username, password) {
c.HTML(http.StatusBadRequest, "login.html", gin.H{
c.HTML(http.StatusBadRequest, "login", gin.H{
"title": "Kontor Gin",
"version": "0.4.0",
"login": globals.LoginUrl,
"content": "Parameters can't be empty",
"message": "Parameters can't be empty",
})
}
if !helpers.CheckUserPass(username, password) {
c.HTML(http.StatusUnauthorized, "login.html", gin.H{
c.HTML(http.StatusUnauthorized, "login", gin.H{
"title": "Kontor Gin",
"version": "0.4.0",
"login": globals.LoginUrl,
"content": "Incorrect username or password",
"message": "Incorrect username or password",
})
}
session.Set(globals.UserKey, username)
if err := session.Save(); err != nil {
c.HTML(http.StatusInternalServerError, "login.html", gin.H{
c.HTML(http.StatusInternalServerError, "login", gin.H{
"title": "Kontor Gin",
"version": "0.4.0",
"login": globals.LoginUrl,
"content": "Failed to save session",
"message": "Failed to save session",
})
return
}