Skip to content

Commit

Permalink
check user exists when visit dataset and space detail (#689)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhendi authored and hiveer committed Sep 30, 2024
1 parent a65463f commit 2a4fd04
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion internal/middleware/auth_middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
12 changes: 6 additions & 6 deletions internal/routes/spaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -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("")
Expand All @@ -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)
}
}

0 comments on commit 2a4fd04

Please sign in to comment.