mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
Merge pull request #3896 from modoboa/task/removed-top-redirection-setting
Removed default top redirection setting.
This commit is contained in:
@@ -94,11 +94,10 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, onMounted, ref } from 'vue'
|
import { computed, onMounted } from 'vue'
|
||||||
import { getActivePinia } from 'pinia'
|
import { getActivePinia } from 'pinia'
|
||||||
import { useGettext } from 'vue3-gettext'
|
import { useGettext } from 'vue3-gettext'
|
||||||
import { useGlobalStore } from '@/stores'
|
import { useGlobalStore } from '@/stores'
|
||||||
import accountApi from '@/api/account'
|
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
user: {
|
user: {
|
||||||
@@ -114,8 +113,7 @@ const props = defineProps({
|
|||||||
const { $gettext } = useGettext()
|
const { $gettext } = useGettext()
|
||||||
const globalStore = useGlobalStore()
|
const globalStore = useGlobalStore()
|
||||||
|
|
||||||
const applications = ref([])
|
const applications = computed(() => globalStore.applications)
|
||||||
|
|
||||||
const userInitials = computed(() => {
|
const userInitials = computed(() => {
|
||||||
if (props.user.first_name && props.user.last_name) {
|
if (props.user.first_name && props.user.last_name) {
|
||||||
return `${props.user.first_name[0].toUpperCase()}${props.user.last_name[0].toUpperCase()}`
|
return `${props.user.first_name[0].toUpperCase()}${props.user.last_name[0].toUpperCase()}`
|
||||||
@@ -148,9 +146,7 @@ async function logout() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
accountApi.getAvailableApplications().then((resp) => {
|
globalStore.fetchAvailableApplications()
|
||||||
applications.value = resp.data
|
|
||||||
})
|
|
||||||
globalStore.fetchNotifications()
|
globalStore.fetchNotifications()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { createRouter, createWebHistory } from 'vue-router'
|
import { createRouter, createWebHistory } from 'vue-router'
|
||||||
import { useAuthStore } from '@/stores'
|
import { useAuthStore, useGlobalStore } from '@/stores'
|
||||||
import { useGlobalConfig } from '@/main'
|
import { useGlobalConfig } from '@/main'
|
||||||
import constants from '@/constants.json'
|
import constants from '@/constants.json'
|
||||||
|
|
||||||
@@ -494,11 +494,16 @@ router.beforeEach(async (to, from, next) => {
|
|||||||
const previousPage = window.location.href
|
const previousPage = window.location.href
|
||||||
sessionStorage.setItem('previousPage', previousPage)
|
sessionStorage.setItem('previousPage', previousPage)
|
||||||
const authStore = useAuthStore()
|
const authStore = useAuthStore()
|
||||||
|
const globalStore = useGlobalStore()
|
||||||
const isAuth = await authStore.validateAccess()
|
const isAuth = await authStore.validateAccess()
|
||||||
if (isAuth) {
|
if (isAuth) {
|
||||||
if (to.meta.allowedRoles !== undefined) {
|
if (to.meta.allowedRoles !== undefined) {
|
||||||
if (to.meta.allowedRoles.indexOf(authStore.authUser.role) === -1) {
|
if (to.meta.allowedRoles.indexOf(authStore.authUser.role) === -1) {
|
||||||
next({ name: 'AccountSettings' })
|
await globalStore.fetchAvailableApplications()
|
||||||
|
const nextPage = globalStore.webmailEnabled
|
||||||
|
? 'MailboxView'
|
||||||
|
: 'AccountSettings'
|
||||||
|
next({ name: nextPage })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
|
import accountApi from '@/api/account'
|
||||||
import capabilitiesApi from '@/api/capabilities'
|
import capabilitiesApi from '@/api/capabilities'
|
||||||
import notificationsApi from '@/api/notifications'
|
import notificationsApi from '@/api/notifications'
|
||||||
|
|
||||||
export const useGlobalStore = defineStore('global', () => {
|
export const useGlobalStore = defineStore('global', () => {
|
||||||
const capabilities = ref([])
|
const capabilities = ref([])
|
||||||
const notifications = ref([])
|
const notifications = ref([])
|
||||||
|
const applications = ref([])
|
||||||
|
|
||||||
async function fetchCapabilities() {
|
async function fetchCapabilities() {
|
||||||
const response = await capabilitiesApi.getCapabilities()
|
const response = await capabilitiesApi.getCapabilities()
|
||||||
@@ -15,6 +17,12 @@ export const useGlobalStore = defineStore('global', () => {
|
|||||||
const response = await notificationsApi.getNotifications()
|
const response = await notificationsApi.getNotifications()
|
||||||
notifications.value = response.data
|
notifications.value = response.data
|
||||||
}
|
}
|
||||||
|
async function fetchAvailableApplications() {
|
||||||
|
if (!applications.value.length) {
|
||||||
|
const response = await accountApi.getAvailableApplications()
|
||||||
|
applications.value = response.data
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getNotificationById(id) {
|
function getNotificationById(id) {
|
||||||
return notifications.value.find((item) => item.id === id)
|
return notifications.value.find((item) => item.id === id)
|
||||||
@@ -33,14 +41,21 @@ export const useGlobalStore = defineStore('global', () => {
|
|||||||
return notifications.value.filter((notif) => notif.target === 'admin')
|
return notifications.value.filter((notif) => notif.target === 'admin')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const webmailEnabled = computed(
|
||||||
|
() => applications.value.find((app) => app.name === 'webmail') !== undefined
|
||||||
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
applications,
|
||||||
capabilities,
|
capabilities,
|
||||||
notifications,
|
notifications,
|
||||||
fetchCapabilities,
|
fetchCapabilities,
|
||||||
fetchNotifications,
|
fetchNotifications,
|
||||||
|
fetchAvailableApplications,
|
||||||
getNotificationById,
|
getNotificationById,
|
||||||
activeNotifications,
|
activeNotifications,
|
||||||
adminNotifications,
|
adminNotifications,
|
||||||
|
webmailEnabled,
|
||||||
$reset,
|
$reset,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -190,19 +190,12 @@ class CoreGlobalParametersSerializer(serializers.Serializer):
|
|||||||
log_maximum_age = serializers.IntegerField(default=365)
|
log_maximum_age = serializers.IntegerField(default=365)
|
||||||
message_history_maximum_age = serializers.IntegerField(default=180)
|
message_history_maximum_age = serializers.IntegerField(default=180)
|
||||||
items_per_page = serializers.IntegerField(default=30)
|
items_per_page = serializers.IntegerField(default=30)
|
||||||
default_top_redirection = serializers.ChoiceField(
|
|
||||||
default="user", choices=[("user", _("User profile"))], required=False
|
|
||||||
)
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
sms_backend_fields = sms_backends.get_all_backend_serializer_settings()
|
sms_backend_fields = sms_backends.get_all_backend_serializer_settings()
|
||||||
for field, definition in sms_backend_fields.items():
|
for field, definition in sms_backend_fields.items():
|
||||||
self.fields[field] = definition["type"](**definition["attrs"])
|
self.fields[field] = definition["type"](**definition["attrs"])
|
||||||
# Choices serializer for default_top_redirection field
|
|
||||||
self.fields["default_top_redirection"].choices = (
|
|
||||||
app_settings.enabled_applications()
|
|
||||||
)
|
|
||||||
# Populate choices of password_scheme
|
# Populate choices of password_scheme
|
||||||
self.fields["password_scheme"].choices = app_settings.get_password_scheme()
|
self.fields["password_scheme"].choices = app_settings.get_password_scheme()
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,6 @@ CORE_SETTINGS = {
|
|||||||
"top_notifications_check_interval": 30,
|
"top_notifications_check_interval": 30,
|
||||||
"log_maximum_age": 365,
|
"log_maximum_age": 365,
|
||||||
"items_per_page": 30,
|
"items_per_page": 30,
|
||||||
"default_top_redirection": "user",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,18 +10,6 @@ from modoboa.core.password_hashers.utils import cache_available_password_hasher
|
|||||||
from . import sms_backends
|
from . import sms_backends
|
||||||
|
|
||||||
|
|
||||||
def enabled_applications():
|
|
||||||
"""Return the list of installed extensions."""
|
|
||||||
from modoboa.core.extensions import exts_pool
|
|
||||||
|
|
||||||
result = [("user", _("User profile"))]
|
|
||||||
for extension in exts_pool.list_all():
|
|
||||||
if "topredirection_url" not in extension:
|
|
||||||
continue
|
|
||||||
result.append((extension["name"], extension["label"]))
|
|
||||||
return sorted(result, key=lambda e: e[0])
|
|
||||||
|
|
||||||
|
|
||||||
def get_password_scheme():
|
def get_password_scheme():
|
||||||
available_schemes = cache.get("password_scheme_choice")
|
available_schemes = cache.get("password_scheme_choice")
|
||||||
if available_schemes is None:
|
if available_schemes is None:
|
||||||
@@ -740,16 +728,6 @@ GLOBAL_PARAMETERS_STRUCT = collections.OrderedDict(
|
|||||||
),
|
),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
(
|
|
||||||
"default_top_redirection",
|
|
||||||
{
|
|
||||||
"label": gettext_lazy("Default top redirection"),
|
|
||||||
"help_text": gettext_lazy(
|
|
||||||
"The default redirection used when no application is "
|
|
||||||
"specified"
|
|
||||||
),
|
|
||||||
},
|
|
||||||
),
|
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ SETTINGS_SAMPLE = {
|
|||||||
"log_maximum_age": "365",
|
"log_maximum_age": "365",
|
||||||
"ldap_auth_method": "searchbind",
|
"ldap_auth_method": "searchbind",
|
||||||
"send_statistics": "True",
|
"send_statistics": "True",
|
||||||
"default_top_redirection": "user",
|
|
||||||
"sender_address": "noreply@modoboa.org",
|
"sender_address": "noreply@modoboa.org",
|
||||||
"ldap_server_port": "389",
|
"ldap_server_port": "389",
|
||||||
"rounds_number": "70000",
|
"rounds_number": "70000",
|
||||||
|
|||||||
Reference in New Issue
Block a user