mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
Some fixes
This commit is contained in:
@@ -42,8 +42,9 @@ _axios.interceptors.response.use(
|
||||
!error.config.ignoreErrors
|
||||
) {
|
||||
const busStore = useBusStore()
|
||||
const msg = error.response.data?.error || error.response.data
|
||||
busStore.displayNotification({
|
||||
msg: error.response.data,
|
||||
msg,
|
||||
type: 'error',
|
||||
})
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
</v-card>
|
||||
</template>
|
||||
|
||||
<script setup lang="js">
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { useGettext } from 'vue3-gettext'
|
||||
import accountApi from '@/api/account'
|
||||
@@ -40,15 +40,17 @@ const busStore = useBusStore()
|
||||
const form = ref({})
|
||||
const loading = ref(false)
|
||||
|
||||
function submit() {
|
||||
async function submit() {
|
||||
loading.value = true
|
||||
accountApi.setForward(form.value).then(() => {
|
||||
loading.value = false
|
||||
try {
|
||||
await accountApi.setForward(form.value)
|
||||
busStore.displayNotification({
|
||||
type: 'success',
|
||||
msg: $gettext('Forward updated'),
|
||||
})
|
||||
})
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
accountApi.getForward().then((resp) => {
|
||||
|
||||
@@ -246,12 +246,8 @@ class AdminGlobalParametersSerializer(serializers.Serializer):
|
||||
|
||||
# Aliases settings
|
||||
alias_can_target_any_domain = serializers.BooleanField(default=True)
|
||||
alias_target_block_list = serializers.ListField(
|
||||
child=serializers.CharField(), required=False
|
||||
)
|
||||
alias_target_allow_list = serializers.ListField(
|
||||
child=serializers.CharField(), required=False
|
||||
)
|
||||
alias_target_block_list = serializers.CharField(required=False, allow_null=True)
|
||||
alias_target_allow_list = serializers.CharField(required=False, allow_null=True)
|
||||
|
||||
def validate_default_domain_quota(self, value):
|
||||
"""Ensure quota is a positive integer."""
|
||||
|
||||
@@ -91,16 +91,21 @@ class AliasManager(models.Manager):
|
||||
)
|
||||
|
||||
|
||||
def convert_to_list(raw_value: str) -> list[str]:
|
||||
"""Convert input string to list of string."""
|
||||
return [item.strip() for item in raw_value.split(",")]
|
||||
|
||||
|
||||
def is_alias_target_allowed(domain: str) -> bool:
|
||||
"""Check if alias target is allowed or not."""
|
||||
params = dict(param_tools.get_global_parameters(app="admin"))
|
||||
if params.get("alias_can_target_any_domain"):
|
||||
blocked_domains = params.get("alias_target_block_list", "").split(",")
|
||||
if domain in blocked_domains:
|
||||
blocked_domains = params.get("alias_target_block_list")
|
||||
if blocked_domains and domain in convert_to_list(blocked_domains):
|
||||
return False
|
||||
else:
|
||||
allowed_domains = params.get("alias_target_allow_list", "").split(",")
|
||||
if domain not in allowed_domains:
|
||||
allowed_domains = params.get("alias_target_allow_list")
|
||||
if allowed_domains and domain not in convert_to_list(allowed_domains):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user