chore: fix acl

This commit is contained in:
Steven
2022-09-14 23:19:22 +08:00
parent 469c841713
commit 5c73f6dd00
2 changed files with 36 additions and 26 deletions

View File

@ -62,7 +62,7 @@ func aclMiddleware(s *Server, next echo.HandlerFunc) echo.HandlerFunc {
println("path", path) println("path", path)
if common.HasPrefixes(path, "/api/ping", "/api/status", "/api/user/:id", "/api/workspace/:workspaceName/shortcut/:shortcutName") && c.Request().Method == http.MethodGet { if common.HasPrefixes(path, "/api/ping", "/api/status", "/api/user/:id") && c.Request().Method == http.MethodGet {
return next(c) return next(c)
} }
@ -106,6 +106,10 @@ func aclMiddleware(s *Server, next echo.HandlerFunc) echo.HandlerFunc {
} }
} }
if common.HasPrefixes(path, "/api/workspace/:workspaceName/shortcut/:shortcutName") && c.Request().Method == http.MethodGet {
return next(c)
}
userID := c.Get(getUserIDContextKey()) userID := c.Get(getUserIDContextKey())
if userID == nil { if userID == nil {
return echo.NewHTTPError(http.StatusUnauthorized, "Missing user in session") return echo.NewHTTPError(http.StatusUnauthorized, "Missing user in session")

View File

@ -20,6 +20,7 @@ const Header: React.FC = () => {
Corgi Corgi
</span> </span>
<div className="relative"> <div className="relative">
{user ? (
<Dropdown <Dropdown
trigger={ trigger={
<div className="flex flex-row justify-end items-center cursor-pointer"> <div className="flex flex-row justify-end items-center cursor-pointer">
@ -45,6 +46,11 @@ const Header: React.FC = () => {
} }
actionsClassName="!w-36" actionsClassName="!w-36"
></Dropdown> ></Dropdown>
) : (
<span className="cursor-pointer" onClick={() => navigate("/auth")}>
Sign in
</span>
)}
</div> </div>
</div> </div>
</div> </div>