diff --git a/conf/lang/en-us.ini b/conf/lang/en-us.ini index e0e84910..1484ef03 100644 --- a/conf/lang/en-us.ini +++ b/conf/lang/en-us.ini @@ -315,7 +315,7 @@ prev = prev next = next no = no edit_title = Edit Blog -private_blog_tips = Private blog is accessible only to author and administrator +private_blog_tips = Private blog, please enter password to access [doc] modify_doc = Modify Document diff --git a/conf/lang/zh-cn.ini b/conf/lang/zh-cn.ini index 897892c3..d1a0b728 100644 --- a/conf/lang/zh-cn.ini +++ b/conf/lang/zh-cn.ini @@ -315,7 +315,7 @@ prev = 上一篇 next = 下一篇 no = 无 edit_title = 编辑文章 -private_blog_tips = 加密文章,仅作者和管理员可访问 +private_blog_tips = 加密文章,请输入密码访问 [doc] modify_doc = 修改文档 diff --git a/controllers/BlogController.go b/controllers/BlogController.go index 6e04c159..c40ff0e1 100644 --- a/controllers/BlogController.go +++ b/controllers/BlogController.go @@ -56,23 +56,14 @@ func (c *BlogController) Index() { if blog.BlogStatus == "password" && password != blog.Password { c.JsonResult(6001, i18n.Tr(c.Lang, "message.blog_pwd_incorrect")) } else if blog.BlogStatus == "password" && password == blog.Password { - // If the password is correct, then determine whether the user is correct - if c.Member != nil && (blog.MemberId == c.Member.MemberId || c.Member.IsAdministrator()) { - /* Private blog is accessible only to author and administrator. - Anonymous users are not allowed access. */ - // Store the session value - _ = c.CruSession.Set(context.TODO(), blogReadSession, blogId) - c.JsonResult(0, "OK") - } else { - c.JsonResult(6002, i18n.Tr(c.Lang, "blog.private_blog_tips")) - } + // Store the session value for the next GET request. + _ = c.CruSession.Set(context.TODO(), blogReadSession, blogId) + c.JsonResult(0, "OK") } else { c.JsonResult(0, "OK") } - } else if blog.BlogStatus == "password" && - (c.CruSession.Get(context.TODO(), blogReadSession) == nil || // Read session doesn't exist - c.Member == nil || // Anonymous, Not Allow - (blog.MemberId != c.Member.MemberId && !c.Member.IsAdministrator())) { // User isn't author or administrator + } else if blog.BlogStatus == "password" && c.CruSession.Get(context.TODO(), blogReadSession) == nil && // Read session doesn't exist + (c.Member == nil || (blog.MemberId != c.Member.MemberId && !c.Member.IsAdministrator())) { // User isn't author or administrator //如果不存在已输入密码的标记 c.TplName = "blog/index_password.tpl" } diff --git a/views/setting/password.tpl b/views/setting/password.tpl index f64baa42..8c302ef5 100644 --- a/views/setting/password.tpl +++ b/views/setting/password.tpl @@ -54,7 +54,7 @@
- +