feat: force auth for particular event types
This commit is contained in:
parent
58723a387f
commit
a8a2ef5e27
3 changed files with 54 additions and 8 deletions
|
|
@ -66,12 +66,13 @@ class StorageSpec(Spec):
|
|||
class AuthSpec(BaseModel):
|
||||
require_auth_events = Field(False, alias="requireAuthEvents")
|
||||
skiped_auth_events = Field([], alias="skipedAuthEvents")
|
||||
forced_auth_events = Field([], alias="forcedAuthEvents")
|
||||
require_auth_filter = Field(False, alias="requireAuthFilter")
|
||||
|
||||
def event_requires_auth(self, kind: int) -> bool:
|
||||
if not self.require_auth_events:
|
||||
return False
|
||||
if self.require_auth_events:
|
||||
return kind not in self.skiped_auth_events
|
||||
return kind in self.forced_auth_events
|
||||
|
||||
|
||||
class PaymentSpec(BaseModel):
|
||||
|
|
|
|||
|
|
@ -343,7 +343,7 @@
|
|||
color="secodary"
|
||||
class="q-ml-md q-mr-md"
|
||||
v-model="relay.config.requireAuthEvents"
|
||||
>For Events</q-toggle
|
||||
>For All Events</q-toggle
|
||||
>
|
||||
</div>
|
||||
<div class="col-5 col-sm-5">
|
||||
|
|
@ -388,9 +388,41 @@
|
|||
>
|
||||
{{ e }}
|
||||
</q-chip>
|
||||
<!-- <q-badge color="secondary" class="q-ml-sm" multi-line>
|
||||
{{ relay.config.skipedAuthEvents }}
|
||||
</q-badge> -->
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-else
|
||||
class="row items-center no-wrap q-mb-md q-mt-md"
|
||||
>
|
||||
<div class="col-3 q-pr-lg">Force Auth For Events:</div>
|
||||
<div class="col-1">
|
||||
<q-input
|
||||
filled
|
||||
dense
|
||||
v-model.trim="forceEventKind"
|
||||
type="number"
|
||||
min="0"
|
||||
></q-input>
|
||||
</div>
|
||||
<div class="col-1">
|
||||
<q-btn
|
||||
unelevated
|
||||
color="secondary"
|
||||
icon="add"
|
||||
@click="addForceAuthForEvent()"
|
||||
></q-btn>
|
||||
</div>
|
||||
<div class="col-7">
|
||||
<q-chip
|
||||
v-for="e in relay.config.forcedAuthEvents"
|
||||
:key="e"
|
||||
removable
|
||||
@remove="removeForceAuthForEvent(e)"
|
||||
color="primary"
|
||||
text-color="white"
|
||||
>
|
||||
{{ e }}
|
||||
</q-chip>
|
||||
</div>
|
||||
</div>
|
||||
<q-separator></q-separator>
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@ async function relayDetails(path) {
|
|||
description: ''
|
||||
}
|
||||
},
|
||||
skipEventKind: 0
|
||||
skipEventKind: 0,
|
||||
forceEventKind: 0
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -141,6 +142,18 @@ async function relayDetails(path) {
|
|||
value = +eventKind
|
||||
this.relay.config.skipedAuthEvents =
|
||||
this.relay.config.skipedAuthEvents.filter(e => e !== value)
|
||||
},
|
||||
addForceAuthForEvent: function () {
|
||||
value = +this.forceEventKind
|
||||
if (this.relay.config.forcedAuthEvents.indexOf(value) != -1) {
|
||||
return
|
||||
}
|
||||
this.relay.config.forcedAuthEvents.push(value)
|
||||
},
|
||||
removeSkipAuthForEvent: function (eventKind) {
|
||||
value = +eventKind
|
||||
this.relay.config.forcedAuthEvents =
|
||||
this.relay.config.forcedAuthEvents.filter(e => e !== value)
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue