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

Skip to content

Commit 958c98c

Browse files
committed
edit bugfix
1 parent 906ff17 commit 958c98c

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/logic/common.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ func CanEdit(me *model.Me, curModel interface{}) bool {
134134
return true
135135
}
136136
case map[string]interface{}:
137+
if adminCanEdit(entity, me) {
138+
return true
139+
}
140+
137141
if ctime, ok := entity["ctime"]; ok {
138142
if time.Now().Sub(time.Time(ctime.(model.OftenTime))) > canEditTime {
139143
return false
@@ -196,3 +200,21 @@ func website() string {
196200
}
197201
return host + WebsiteSetting.Domain
198202
}
203+
204+
func adminCanEdit(entity map[string]interface{}, me *model.Me) bool {
205+
if uid, ok := entity["uid"]; ok {
206+
if me.Uid != uid.(int) && me.IsAdmin {
207+
return true
208+
}
209+
return false
210+
}
211+
212+
if username, ok := entity["username"]; ok {
213+
if me.Username != username.(string) && me.IsAdmin {
214+
return true
215+
}
216+
return false
217+
}
218+
219+
return false
220+
}

0 commit comments

Comments
 (0)