Added Gitea oauth to the admin dashboard and finished the oauth handling

This commit is contained in:
2025-09-15 22:24:12 +03:30
parent a84156f0a0
commit d4044b0eaf
11 changed files with 228 additions and 230 deletions
+4
View File
@@ -23,9 +23,11 @@ func SetupRouter() *gin.Engine {
r.LoadHTMLGlob("internal/web/templates/home/*")
auth.InitJwtTokenGenerator() // Must be befor initializing admin handler, otherwise 'panic: runtime error: invalid memory address or nil pointer dereference'
auth.InitGiteaOauth2Token()
handlers.InitAdminDashboardHandler()
handlers.InitApiEndpointHandler()
handlers.InitEmbedCardHandler()
handlers.InitOauthLoginHandler()
// Main page
r.GET("/", func(c *gin.Context) {
@@ -44,6 +46,8 @@ func SetupRouter() *gin.Engine {
// c.HTML(http.StatusOK, "admin/index.html", nil)
// })
r.Use(static.Serve("/admin", static.LocalFile("internal/web/templates/admin", true)))
// I dont know a better way for path handling
r.Use(static.Serve("/admin/oauth/gitea/callback", static.LocalFile("internal/web/templates/admin", true)))
adminApi := admin.Group("/api")
adminApi.POST("/login", handlers.AdminDashboardHandlerInstance.Login)