From 750fb49a37a07affcb9df6b33fbde64ae5ce9ace Mon Sep 17 00:00:00 2001 From: ouqiang Date: Mon, 25 Dec 2017 23:55:23 +0800 Subject: [PATCH] =?UTF-8?q?bugfix:=20API=E8=AE=BF=E9=97=AE=E6=8A=A5403?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routers/routers.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/routers/routers.go b/routers/routers.go index 49c5ff3..159295e 100644 --- a/routers/routers.go +++ b/routers/routers.go @@ -230,6 +230,11 @@ func urlAuth(ctx *macaron.Context, sess session.Store) { if user.IsAdmin(sess) { return } + uri := strings.TrimSpace(ctx.Req.URL.Path) + uri = strings.TrimRight(uri, "/") + if (strings.HasPrefix(uri, "/api")) { + return + } // 普通用户允许访问的URL地址 allowPaths := []string{ "", @@ -239,10 +244,7 @@ func urlAuth(ctx *macaron.Context, sess session.Store) { "/user/login", "/user/logout", "/user/editMyPassword", - "/api", } - uri := strings.TrimSpace(ctx.Req.URL.Path) - uri = strings.TrimRight(uri, "/") for _, path := range allowPaths { if path == uri { return