hotfix: remove unnecessary code
This commit is contained in:
parent
b6cce0e0e2
commit
76fc60d89f
@ -4,15 +4,33 @@
|
|||||||
<input type="checkbox" v-model="rule.regex" /><label>Regex</label>
|
<input type="checkbox" v-model="rule.regex" /><label>Regex</label>
|
||||||
<input type="checkbox" v-model="rule.allow" /><label>Allow</label>
|
<input type="checkbox" v-model="rule.allow" /><label>Allow</label>
|
||||||
|
|
||||||
<input @keypress.enter.prevent type="text" style="margin-right: 8px;" v-if="rule.regex" v-model="rule.regexp.raw"
|
<input
|
||||||
:placeholder="$t('settings.insertRegex')" />
|
@keypress.enter.prevent
|
||||||
<input @keypress.enter.prevent type="text" style="margin-right: 8px;" v-else v-model="rule.path"
|
type="text"
|
||||||
:placeholder="$t('settings.insertPath')" />
|
style="margin-right: 8px"
|
||||||
|
v-if="rule.regex"
|
||||||
|
v-model="rule.regexp.raw"
|
||||||
|
:placeholder="$t('settings.insertRegex')"
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
@keypress.enter.prevent
|
||||||
|
type="text"
|
||||||
|
style="margin-right: 8px"
|
||||||
|
v-else
|
||||||
|
v-model="rule.path"
|
||||||
|
:placeholder="$t('settings.insertPath')"
|
||||||
|
/>
|
||||||
|
|
||||||
<input type="checkbox" :checked="rule.perm && rule.perm.includes('read')"
|
<input
|
||||||
@input="changePermOfRule('read', index)" /><label>Read</label>
|
type="checkbox"
|
||||||
<input type="checkbox" :checked="rule.perm && rule.perm.includes('write')"
|
:checked="rule.perm && rule.perm.includes('read')"
|
||||||
@input="changePermOfRule('write', index)" /><label>Write</label>
|
@input="changePermOfRule('read', index)"
|
||||||
|
/><label>Read</label>
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
:checked="rule.perm && rule.perm.includes('write')"
|
||||||
|
@input="changePermOfRule('write', index)"
|
||||||
|
/><label>Write</label>
|
||||||
|
|
||||||
<button class="button button--red" @click="remove($event, index)">
|
<button class="button button--red" @click="remove($event, index)">
|
||||||
-
|
-
|
||||||
@ -34,9 +52,17 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
changePermOfRule(ruleName, index) {
|
changePermOfRule(ruleName, index) {
|
||||||
const rule = this.rules[index];
|
const rule = this.rules[index];
|
||||||
const isRead = ruleName === "read" ? rule.perm.includes("read") : !rule.perm.includes("read");
|
const isRead =
|
||||||
const isWrite = ruleName === "write" ? rule.perm.includes("write") : !rule.perm.includes("write");
|
ruleName === "read"
|
||||||
this.rules[index].perm = `${!isRead ? "read" : ""}${!isRead && !isWrite ? "|" : ""}${!isWrite ? "write" : ""}`
|
? rule.perm.includes("read")
|
||||||
|
: !rule.perm.includes("read");
|
||||||
|
const isWrite =
|
||||||
|
ruleName === "write"
|
||||||
|
? rule.perm.includes("write")
|
||||||
|
: !rule.perm.includes("write");
|
||||||
|
this.rules[index].perm = `${!isRead ? "read" : ""}${
|
||||||
|
!isRead && !isWrite ? "|" : ""
|
||||||
|
}${!isWrite ? "write" : ""}`;
|
||||||
},
|
},
|
||||||
remove(event, index) {
|
remove(event, index) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|||||||
@ -87,9 +87,9 @@ func (d *data) CheckWritePerm(path string) bool {
|
|||||||
if rule.Matches(path) {
|
if rule.Matches(path) {
|
||||||
if !rule.Allow {
|
if !rule.Allow {
|
||||||
write = false
|
write = false
|
||||||
} else {
|
continue
|
||||||
write = strings.Contains(rule.Perm, "write")
|
|
||||||
}
|
}
|
||||||
|
write = strings.Contains(rule.Perm, "write")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,9 +97,9 @@ func (d *data) CheckWritePerm(path string) bool {
|
|||||||
if rule.Matches(path) {
|
if rule.Matches(path) {
|
||||||
if !rule.Allow {
|
if !rule.Allow {
|
||||||
write = false
|
write = false
|
||||||
} else {
|
continue
|
||||||
write = strings.Contains(rule.Perm, "write")
|
|
||||||
}
|
}
|
||||||
|
write = strings.Contains(rule.Perm, "write")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -183,26 +183,19 @@ func resourcePatchHandler(fileCache FileCache) handleFunc {
|
|||||||
dst := r.URL.Query().Get("destination")
|
dst := r.URL.Query().Get("destination")
|
||||||
action := r.URL.Query().Get("action")
|
action := r.URL.Query().Get("action")
|
||||||
dst, err := url.QueryUnescape(dst)
|
dst, err := url.QueryUnescape(dst)
|
||||||
switch action {
|
|
||||||
case "rename": // rename and move action
|
|
||||||
if !d.CheckWritePerm(src) || !d.CheckWritePerm(dst) {
|
|
||||||
return http.StatusForbidden, nil
|
|
||||||
}
|
|
||||||
break
|
|
||||||
case "copy": // copy action
|
|
||||||
if !d.CheckReadPerm(src) || !d.CheckWritePerm(dst) {
|
|
||||||
return http.StatusForbidden, nil
|
|
||||||
}
|
|
||||||
break
|
|
||||||
default:
|
|
||||||
break
|
|
||||||
}
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errToStatus(err), err
|
return errToStatus(err), err
|
||||||
}
|
}
|
||||||
if dst == "/" || src == "/" {
|
if dst == "/" || src == "/" {
|
||||||
return http.StatusForbidden, nil
|
return http.StatusForbidden, nil
|
||||||
}
|
}
|
||||||
|
if !d.CheckReadPerm(src) || !d.CheckWritePerm(dst) {
|
||||||
|
copy := action == "copy"
|
||||||
|
rename := action == "rename"
|
||||||
|
if !rename || !copy {
|
||||||
|
return http.StatusForbidden, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
err = checkParent(src, dst)
|
err = checkParent(src, dst)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user