Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Commit

Permalink
fix: unauthenicated middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
ImSoZRious committed Jun 29, 2023
1 parent 11dbed1 commit 8775314
Showing 1 changed file with 0 additions and 11 deletions.
11 changes: 0 additions & 11 deletions src/app/router/gin.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,20 +90,9 @@ func getMiddlewares(ro route.RouteData) []Handler {
}

func getRoleMiddleware(allowRoles map[string]struct{}) Handler {
if _, exist := allowRoles[route.Any]; exist {
return func(ctx rctx.Context) bool {
return true
}
}

return func(ctx rctx.Context) bool {
userRole := ctx.Role()

if userRole == "" {
ctx.JSON(http.StatusForbidden, dto.ResponseForbiddenErr{})
return false
}

if _, exist := allowRoles[userRole]; exist {
return true
} else {
Expand Down

0 comments on commit 8775314

Please sign in to comment.