|
@@ -56,23 +56,14 @@ func (c *BlogController) Index() {
|
|
if blog.BlogStatus == "password" && password != blog.Password {
|
|
if blog.BlogStatus == "password" && password != blog.Password {
|
|
c.JsonResult(6001, i18n.Tr(c.Lang, "message.blog_pwd_incorrect"))
|
|
c.JsonResult(6001, i18n.Tr(c.Lang, "message.blog_pwd_incorrect"))
|
|
} else if blog.BlogStatus == "password" && password == blog.Password {
|
|
} 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 {
|
|
} else {
|
|
c.JsonResult(0, "OK")
|
|
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"
|
|
c.TplName = "blog/index_password.tpl"
|
|
}
|
|
}
|