mirror of
https://github.com/mindoc-org/mindoc.git
synced 2026-02-27 17:03:57 +08:00
添加只读用户角色,不能创建、编辑,只能被设置为观察者 (#992)
* 添加只读用户角色,不能创建、编辑,只能被设置为观察者 * Update markdown.preview.css toc隐藏的时候,article宽度为100% * Update cherry-markdown.css cherry样式,隐藏toc时宽度100% * 发布pdf时候的默认发布者(项目填写了公司名称以公司名称为准) * 验证只读用户权限
This commit is contained in:
@@ -162,6 +162,9 @@ func (c *BlogController) ManageSetting() {
|
||||
bookIdentify := strings.TrimSpace(c.GetString("bookIdentify"))
|
||||
documentId := 0
|
||||
|
||||
if c.Member.Role == conf.MemberReaderRole {
|
||||
c.JsonResult(6001, i18n.Tr(c.Lang, "message.no_permission"))
|
||||
}
|
||||
if blogTitle == "" {
|
||||
c.JsonResult(6001, i18n.Tr(c.Lang, "message.blog_title_empty"))
|
||||
}
|
||||
@@ -286,6 +289,10 @@ func (c *BlogController) ManageEdit() {
|
||||
c.Prepare()
|
||||
c.TplName = "blog/manage_edit.tpl"
|
||||
|
||||
if c.Member.Role == conf.MemberReaderRole {
|
||||
c.JsonResult(6001, i18n.Tr(c.Lang, "message.no_permission"))
|
||||
}
|
||||
|
||||
if c.Ctx.Input.IsPost() {
|
||||
blogId, _ := c.GetInt("blogId", 0)
|
||||
|
||||
|
||||
@@ -466,6 +466,9 @@ func (c *BookController) Create() {
|
||||
editor := c.GetString("editor")
|
||||
itemId, _ := c.GetInt("itemId")
|
||||
|
||||
if c.Member.Role == conf.MemberReaderRole {
|
||||
c.JsonResult(6001, i18n.Tr(c.Lang, "message.no_permission"))
|
||||
}
|
||||
if bookName == "" {
|
||||
c.JsonResult(6001, i18n.Tr(c.Lang, "message.project_name_empty"))
|
||||
}
|
||||
@@ -566,7 +569,9 @@ func (c *BookController) Copy() {
|
||||
if _, err := c.IsPermission(); err != nil {
|
||||
c.JsonResult(500, err.Error())
|
||||
}
|
||||
|
||||
if c.Member.Role == conf.MemberReaderRole {
|
||||
c.JsonResult(6001, i18n.Tr(c.Lang, "message.no_permission"))
|
||||
}
|
||||
identify := strings.TrimSpace(c.GetString("identify", ""))
|
||||
if identify == "" {
|
||||
c.JsonResult(6001, i18n.Tr(c.Lang, "message.param_error"))
|
||||
@@ -587,7 +592,9 @@ func (c *BookController) Copy() {
|
||||
|
||||
// 导入zip压缩包或docx
|
||||
func (c *BookController) Import() {
|
||||
|
||||
if c.Member.Role == conf.MemberReaderRole {
|
||||
c.JsonResult(6001, i18n.Tr(c.Lang, "message.no_permission"))
|
||||
}
|
||||
file, moreFile, err := c.GetFile("import-file")
|
||||
if err == http.ErrMissingFile {
|
||||
c.JsonResult(6003, "没有发现需要上传的文件")
|
||||
|
||||
@@ -41,6 +41,10 @@ func (c *BookMemberController) AddMember() {
|
||||
if _, err := models.NewRelationship().FindForRoleId(book.BookId, member.MemberId); err == nil {
|
||||
c.JsonResult(6003, i18n.Tr(c.Lang, "message.user_exist_in_proj"))
|
||||
}
|
||||
//如果是只读用户,只能设置为观察者
|
||||
if member.Role == conf.MemberReaderRole && roleId != int(conf.BookObserver) {
|
||||
c.JsonResult(6003, i18n.Tr(c.Lang, "message.readusr_only_observer"))
|
||||
}
|
||||
|
||||
relationship := models.NewRelationship()
|
||||
relationship.BookId = book.BookId
|
||||
@@ -94,6 +98,10 @@ func (c *BookMemberController) ChangeRole() {
|
||||
if member.Status == 1 {
|
||||
c.JsonResult(6004, i18n.Tr(c.Lang, "message.user_disable"))
|
||||
}
|
||||
//如果是只读用户,只能设置为观察者
|
||||
if member.Role == conf.MemberReaderRole && role != int(conf.BookObserver) {
|
||||
c.JsonResult(6003, i18n.Tr(c.Lang, "message.readusr_only_observer"))
|
||||
}
|
||||
|
||||
relationship, err := models.NewRelationship().UpdateRoleId(book.BookId, memberId, conf.BookRole(role))
|
||||
|
||||
|
||||
@@ -328,6 +328,10 @@ func Flatten(list []*models.DocumentTree, flattened *[]DocumentTreeFlatten) {
|
||||
func (c *DocumentController) Edit() {
|
||||
c.Prepare()
|
||||
|
||||
if c.Member.Role == conf.MemberReaderRole {
|
||||
c.JsonResult(6001, i18n.Tr(c.Lang, "message.no_permission"))
|
||||
}
|
||||
|
||||
identify := c.Ctx.Input.Param(":key")
|
||||
if identify == "" {
|
||||
c.ShowErrorPage(404, i18n.Tr(c.Lang, "message.project_id_error"))
|
||||
|
||||
@@ -175,7 +175,7 @@ func (c *ManagerController) ChangeMemberRole() {
|
||||
if memberId <= 0 {
|
||||
c.JsonResult(6001, i18n.Tr(c.Lang, "message.param_error"))
|
||||
}
|
||||
if role != int(conf.MemberAdminRole) && role != int(conf.MemberGeneralRole) {
|
||||
if role != int(conf.MemberAdminRole) && role != int(conf.MemberGeneralRole) && role != int(conf.MemberReaderRole) {
|
||||
c.JsonResult(6001, i18n.Tr(c.Lang, "message.no_permission"))
|
||||
}
|
||||
member := models.NewMember()
|
||||
|
||||
Reference in New Issue
Block a user