Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4fde274

Browse files
committed
控制显示
1 parent d7f33d9 commit 4fde274

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

http/controller/topic.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,12 @@ func (TopicController) Detail(ctx echo.Context) error {
161161
}
162162

163163
me, ok := ctx.Get("user").(*model.Me)
164-
// 当前用户是否对付费内容可见
165-
if topic["permission"] == model.PermissionPay {
164+
if topic["permission"] == model.PermissionOnlyMe {
165+
if !ok || (topic["uid"].(int) != me.Uid && !me.IsRoot) {
166+
return ctx.Redirect(http.StatusSeeOther, "/topics")
167+
}
168+
} else if topic["permission"] == model.PermissionPay {
169+
// 当前用户是否对付费内容可见
166170
if !ok || (!me.IsVip && !me.IsRoot && topic["uid"].(int) != me.Uid) {
167171
data["can_view"] = false
168172
}

model/topic.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const (
2525
PermissionLogin // 登录可见
2626
PermissionFollow // 关注可见(暂未实现)
2727
PermissionPay // 知识星球或其他方式付费可见
28+
PermissionOnlyMe // 自己可见
2829
)
2930

3031
// 社区主题信息

0 commit comments

Comments
 (0)