Browse Source

如果没有开启匿名访问,屏蔽搜索

Minho 8 years ago
parent
commit
096eb8edd1
1 changed files with 6 additions and 0 deletions
  1. 6 0
      controllers/search.go

+ 6 - 0
controllers/search.go

@@ -18,6 +18,12 @@ func (c *SearchController) Index()  {
 	c.Prepare()
 	c.TplName = "search/index.tpl"
 
+	//如果没有开启你们访问则跳转到登录
+	if !c.EnableAnonymous && c.Member == nil {
+		c.Redirect(beego.URLFor("AccountController.Login"),302)
+		return
+	}
+	
 	keyword := c.GetString("keyword")
 	pageIndex,_ := c.GetInt("page",1)