From 8cb2c95899e586e0e575919d7f9ffae7b1b26edf Mon Sep 17 00:00:00 2001 From: zhendi Date: Thu, 26 Sep 2024 20:44:12 +0800 Subject: [PATCH] check user exists when visit dataset and space detail --- internal/middleware/auth_middleware.go | 2 +- internal/routes/spaces.go | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/middleware/auth_middleware.go b/internal/middleware/auth_middleware.go index 4ee765715..957cdb2c9 100644 --- a/internal/middleware/auth_middleware.go +++ b/internal/middleware/auth_middleware.go @@ -32,7 +32,7 @@ func CheckCurrentUser() gin.HandlerFunc { return func(ctx *gin.Context) { currentUser := jwt.GetCurrentUser(ctx) if currentUser == nil { - ctx.Redirect(http.StatusFound, "/errors/unauthorized") + ctx.Redirect(http.StatusFound, "/login") ctx.Abort() return } diff --git a/internal/routes/spaces.go b/internal/routes/spaces.go index fcd56cb4e..d07518444 100644 --- a/internal/routes/spaces.go +++ b/internal/routes/spaces.go @@ -11,12 +11,6 @@ func registerSpaceRoutes(engine *gin.Engine, handlers *HandlersRegistry) { spaceRoutes := engine.Group("/spaces") { spaceRoutes.GET("", spaceHandler.List) - spaceRoutes.GET("/:namespace/:space_name", spaceHandler.Detail) - spaceRoutes.GET("/:namespace/:space_name/files/:branch/*path", spaceHandler.Files) - spaceRoutes.GET("/:namespace/:space_name/blob/:branch/*path", spaceHandler.Blob) - spaceRoutes.GET("/:namespace/:space_name/commits", spaceHandler.Commits) - spaceRoutes.GET("/:namespace/:space_name/commit/:commit_id", spaceHandler.Commit) - spaceRoutes.GET("/:namespace/:space_name/community", spaceHandler.Community) } authenticatedRoutes := spaceRoutes.Group("") @@ -28,5 +22,11 @@ func registerSpaceRoutes(engine *gin.Engine, handlers *HandlersRegistry) { authenticatedRoutes.GET("/:namespace/:space_name/edit/:branch/:path", spaceHandler.EditFile) authenticatedRoutes.GET("/:namespace/:space_name/settings", spaceHandler.Settings) authenticatedRoutes.GET("/:namespace/:space_name/billing", spaceHandler.Billing) + authenticatedRoutes.GET("/:namespace/:space_name", spaceHandler.Detail) + authenticatedRoutes.GET("/:namespace/:space_name/files/:branch/*path", spaceHandler.Files) + authenticatedRoutes.GET("/:namespace/:space_name/blob/:branch/*path", spaceHandler.Blob) + authenticatedRoutes.GET("/:namespace/:space_name/commits", spaceHandler.Commits) + authenticatedRoutes.GET("/:namespace/:space_name/commit/:commit_id", spaceHandler.Commit) + authenticatedRoutes.GET("/:namespace/:space_name/community", spaceHandler.Community) } }