Skip to content

Commit

Permalink
bugfix: API访问报403错误
Browse files Browse the repository at this point in the history
  • Loading branch information
ouqiang committed Dec 25, 2017
1 parent 68d569a commit 750fb49
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions routers/routers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
"",
Expand All @@ -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
Expand Down

0 comments on commit 750fb49

Please sign in to comment.