mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
Removed default top redirection setting.
Simple users will be redirected to webmail by default (if enabled)
This commit is contained in:
@@ -94,11 +94,10 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { computed, onMounted } from 'vue'
|
||||
import { getActivePinia } from 'pinia'
|
||||
import { useGettext } from 'vue3-gettext'
|
||||
import { useGlobalStore } from '@/stores'
|
||||
import accountApi from '@/api/account'
|
||||
|
||||
const props = defineProps({
|
||||
user: {
|
||||
@@ -114,8 +113,7 @@ const props = defineProps({
|
||||
const { $gettext } = useGettext()
|
||||
const globalStore = useGlobalStore()
|
||||
|
||||
const applications = ref([])
|
||||
|
||||
const applications = computed(() => globalStore.applications)
|
||||
const userInitials = computed(() => {
|
||||
if (props.user.first_name && props.user.last_name) {
|
||||
return `${props.user.first_name[0].toUpperCase()}${props.user.last_name[0].toUpperCase()}`
|
||||
@@ -148,9 +146,7 @@ async function logout() {
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
accountApi.getAvailableApplications().then((resp) => {
|
||||
applications.value = resp.data
|
||||
})
|
||||
globalStore.fetchAvailableApplications()
|
||||
globalStore.fetchNotifications()
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { createRouter, createWebHistory } from 'vue-router'
|
||||
import { useAuthStore } from '@/stores'
|
||||
import { useAuthStore, useGlobalStore } from '@/stores'
|
||||
import { useGlobalConfig } from '@/main'
|
||||
import constants from '@/constants.json'
|
||||
|
||||
@@ -494,11 +494,16 @@ router.beforeEach(async (to, from, next) => {
|
||||
const previousPage = window.location.href
|
||||
sessionStorage.setItem('previousPage', previousPage)
|
||||
const authStore = useAuthStore()
|
||||
const globalStore = useGlobalStore()
|
||||
const isAuth = await authStore.validateAccess()
|
||||
if (isAuth) {
|
||||
if (to.meta.allowedRoles !== undefined) {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import { computed, ref } from 'vue'
|
||||
import { defineStore } from 'pinia'
|
||||
import accountApi from '@/api/account'
|
||||
import capabilitiesApi from '@/api/capabilities'
|
||||
import notificationsApi from '@/api/notifications'
|
||||
|
||||
export const useGlobalStore = defineStore('global', () => {
|
||||
const capabilities = ref([])
|
||||
const notifications = ref([])
|
||||
const applications = ref([])
|
||||
|
||||
async function fetchCapabilities() {
|
||||
const response = await capabilitiesApi.getCapabilities()
|
||||
@@ -15,6 +17,12 @@ export const useGlobalStore = defineStore('global', () => {
|
||||
const response = await notificationsApi.getNotifications()
|
||||
notifications.value = response.data
|
||||
}
|
||||
async function fetchAvailableApplications() {
|
||||
if (!applications.value.length) {
|
||||
const response = await accountApi.getAvailableApplications()
|
||||
applications.value = response.data
|
||||
}
|
||||
}
|
||||
|
||||
function getNotificationById(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')
|
||||
})
|
||||
|
||||
const webmailEnabled = computed(
|
||||
() => applications.value.find((app) => app.name === 'webmail') !== undefined
|
||||
)
|
||||
|
||||
return {
|
||||
applications,
|
||||
capabilities,
|
||||
notifications,
|
||||
fetchCapabilities,
|
||||
fetchNotifications,
|
||||
fetchAvailableApplications,
|
||||
getNotificationById,
|
||||
activeNotifications,
|
||||
adminNotifications,
|
||||
webmailEnabled,
|
||||
$reset,
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user