mirror of
https://github.com/mindoc-org/mindoc.git
synced 2025-05-07 15:17:48 +08:00
fix:修复Token无法访问文档的BUG
This commit is contained in:
parent
a515cab3ca
commit
329b87c685
@ -1237,6 +1237,7 @@ func (c *DocumentController) isReadable(identify, token string) *models.BookResu
|
|||||||
}
|
}
|
||||||
// 如果文档是私有的
|
// 如果文档是私有的
|
||||||
if book.PrivatelyOwned == 1 && (!c.isUserLoggedIn() || !c.Member.IsAdministrator()) {
|
if book.PrivatelyOwned == 1 && (!c.isUserLoggedIn() || !c.Member.IsAdministrator()) {
|
||||||
|
if s,ok := c.GetSession(identify).(string); !ok || (!strings.EqualFold(s,book.PrivateToken) && !strings.EqualFold(s,book.BookPassword)) {
|
||||||
|
|
||||||
if book.PrivateToken != "" && !isOk && token != "" {
|
if book.PrivateToken != "" && !isOk && token != "" {
|
||||||
// 如果有访问的 Token,并且该项目设置了访问 Token,并且和用户提供的相匹配,则记录到 Session 中。
|
// 如果有访问的 Token,并且该项目设置了访问 Token,并且和用户提供的相匹配,则记录到 Session 中。
|
||||||
@ -1245,16 +1246,17 @@ func (c *DocumentController) isReadable(identify, token string) *models.BookResu
|
|||||||
if token != "" && strings.EqualFold(token, book.PrivateToken) {
|
if token != "" && strings.EqualFold(token, book.PrivateToken) {
|
||||||
c.SetSession(identify, token)
|
c.SetSession(identify, token)
|
||||||
} else if token, ok := c.GetSession(identify).(string); !ok || !strings.EqualFold(token, book.PrivateToken) {
|
} else if token, ok := c.GetSession(identify).(string); !ok || !strings.EqualFold(token, book.PrivateToken) {
|
||||||
|
beego.Info("尝试访问文档但权限不足 ->", identify, token)
|
||||||
c.ShowErrorPage(403, "权限不足")
|
c.ShowErrorPage(403, "权限不足")
|
||||||
}
|
}
|
||||||
} else if password := c.GetString("bPassword", "");!isOk && book.BookPassword != "" && password != ""{
|
} else if password := c.GetString("bPassword", ""); !isOk && book.BookPassword != "" && password != "" {
|
||||||
|
|
||||||
//如果设置了密码,则判断密码是否正确
|
//如果设置了密码,则判断密码是否正确
|
||||||
if book.BookPassword != password {
|
if book.BookPassword != password {
|
||||||
c.JsonResult(5001, "密码错误")
|
c.JsonResult(5001, "密码错误")
|
||||||
} else {
|
} else {
|
||||||
c.SetSession(identify, password)
|
c.SetSession(identify, password)
|
||||||
c.JsonResult(0,"OK")
|
c.JsonResult(0, "OK")
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if !isOk {
|
} else if !isOk {
|
||||||
@ -1269,10 +1271,12 @@ func (c *DocumentController) isReadable(identify, token string) *models.BookResu
|
|||||||
c.CustomAbort(200, body)
|
c.CustomAbort(200, body)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
beego.Info("尝试访问文档但权限不足 ->", identify, token)
|
||||||
c.ShowErrorPage(403, "权限不足")
|
c.ShowErrorPage(403, "权限不足")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return bookResult
|
return bookResult
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user