未开启匿名访问时能够访问公开项目

pull/25/merge
Minho 2017-05-03 17:09:01 +08:00
parent 8075b0dc81
commit 4d51baf42f
5 changed files with 20 additions and 14 deletions

View File

@ -28,10 +28,9 @@ timezone = Asia/Shanghai
#数据库配置
db_host=127.0.0.1
db_port=3306
db_database=webhook_db
db_database=mindoc_db
db_username=root
db_password=123456
db_prefix=md_
#项目默认封面
cover=/static/images/book.jpg

View File

@ -1,6 +0,0 @@
[{
"name":"Editor.md",
"description" : "",
"style" : "",
"script" : ""
}]

View File

@ -91,6 +91,11 @@ func (c *DocumentController) Index() {
if identify == "" {
c.Abort("404")
}
//如果没有开启你们访问则跳转到登录
if !c.EnableAnonymous && c.Member == nil {
c.Redirect(beego.URLFor("AccountController.Login"),302)
return
}
bookResult := isReadable(identify,token,c)
@ -119,6 +124,13 @@ func (c *DocumentController) Read() {
if identify == "" || id == ""{
c.Abort("404")
}
//如果没有开启你们访问则跳转到登录
if !c.EnableAnonymous && c.Member == nil {
c.Redirect(beego.URLFor("AccountController.Login"),302)
return
}
bookResult := isReadable(identify,token,c)
c.TplName = "document/" + bookResult.Theme + "_read.tpl"

View File

@ -33,25 +33,25 @@ func NewOption() *Option {
return &Option{}
}
func (p *Option) Find(id int) error {
func (p *Option) Find(id int) (*Option,error) {
o := orm.NewOrm()
p.OptionId = id
if err := o.Read(p);err != nil {
return err
return p,err
}
return nil
return p,nil
}
func (p *Option) FindByKey(key string) error {
func (p *Option) FindByKey(key string) (*Option,error) {
o := orm.NewOrm()
p.OptionName = key
if err := o.Read(p);err != nil {
return err
return p,err
}
return nil
return p,nil
}
func GetOptionValue(key, def string) string {

View File

@ -5,6 +5,7 @@ import (
"github.com/astaxie/beego/context"
"github.com/lifei6671/godoc/conf"
"github.com/lifei6671/godoc/models"
"strings"
)
func init() {