Deal with password scheme deprecation (crypt as of now)

Also display notifications in new admin.

see #3350
This commit is contained in:
Antoine Nguyen
2024-11-29 14:15:46 +01:00
parent 8d1c1fcbcb
commit 92b93fa6bf
17 changed files with 241 additions and 48 deletions
+3
View File
@@ -4,4 +4,7 @@ export default {
getComponentsInformation() {
return repository.get('/admin/components/')
},
getNotifications() {
return repository.get('/admin/notifications/')
},
}
+23 -19
View File
@@ -22,11 +22,10 @@
</div>
<v-list nav>
<template v-for="item in menuItems">
<template v-for="item in menuItems" :key="item.text">
<template v-if="displayMenuItem(item)">
<v-list-item
v-if="!item.children"
:key="item.text"
:value="item"
:to="item.to"
link
@@ -34,8 +33,11 @@
:title="item.text"
:prepend-icon="item.icon"
>
<template v-if="item.withBell && displayInformationBell" #append>
<v-icon color="red" icon="mdi-bell-alert-outline" />
</template>
</v-list-item>
<v-list-group v-else :key="item.text" :value="item.text">
<v-list-group v-else :value="item.text">
<template #activator="{ props }">
<v-list-item
v-bind="props"
@@ -108,16 +110,15 @@
</v-navigation-drawer>
</template>
<script setup lang="js">
<script setup>
import { useRoute, useRouter } from 'vue-router'
import { ref, computed } from 'vue'
import { ref, computed, onMounted } from 'vue'
import { useGettext } from 'vue3-gettext'
import { getActivePinia } from 'pinia'
import { useGlobalStore, useAuthStore, useParametersStore } from '@/stores'
import parametersApi from '@/api/parameters'
import { useAuthStore, useParametersStore } from '@/stores'
import { onMounted } from 'vue'
const globalStore = useGlobalStore()
const authStore = useAuthStore()
const parametersStore = useParametersStore()
const route = useRoute()
@@ -132,7 +133,6 @@ const isAuthenticated = computed(() => authStore.isAuthenticated)
const backgroundColor = computed(() =>
route.meta.layout === 'account' ? 'bg-grey-darken-1' : 'bg-primary-darken-1'
)
const userInitials = computed(() => {
let initials = null
if (authUser.value.first_name) {
@@ -170,8 +170,13 @@ const mainColor = computed(() => {
const imapMigration = computed(() => parametersStore.imapMigrationEnabled)
const settings = []
const displayInformationBell = computed(
() =>
globalStore.notifications.length !== undefined &&
globalStore.notifications.length !== 0
)
const settings = []
const mainMenuItems = [
{
text: $gettext('Dashboard'),
@@ -246,6 +251,7 @@ const mainMenuItems = [
text: $gettext('Information'),
roles: ['SuperAdmins'],
to: { name: 'Information' },
withBell: true,
},
]
@@ -318,15 +324,13 @@ onMounted(() => {
})
})
})
}
if (
authUser.value.role === 'SuperAdmins' &&
parametersStore.imapMigrationEnabled === null
) {
parametersApi.getApplication('imap_migration').then((response) => {
parametersStore.imapMigrationEnabled =
response.data.params.enabled_imapmigration
})
globalStore.fetchNotifications()
if (parametersStore.imapMigrationEnabled === null) {
parametersApi.getApplication('imap_migration').then((response) => {
parametersStore.imapMigrationEnabled =
response.data.params.enabled_imapmigration
})
}
}
})
</script>
+18
View File
@@ -0,0 +1,18 @@
import { ref } from 'vue'
import { defineStore } from 'pinia'
import adminApi from '@/api/admin'
export const useGlobalStore = defineStore('global', () => {
const notifications = ref([])
async function fetchNotifications() {
const response = await adminApi.getNotifications()
notifications.value = response.data
}
function getNotificationById(id) {
return notifications.value.find((item) => item.id === id)
}
return { notifications, fetchNotifications, getNotificationById }
})
+1
View File
@@ -1,5 +1,6 @@
import { createPinia } from 'pinia'
export * from './global.store'
export * from './auth.store'
export * from './bus.store'
export * from './domains.store'
+73 -5
View File
@@ -3,6 +3,72 @@
<v-toolbar flat>
<v-toolbar-title>{{ $gettext('Information') }}</v-toolbar-title>
</v-toolbar>
<v-card v-if="globalStore.notifications.length" class="my-6">
<v-card-title>
{{ $gettext('Important messages') }}
</v-card-title>
<v-card-text>
<v-alert
v-for="notification in globalStore.notifications"
:key="notification.id"
:type="notification.level"
:title="notification.text"
border="start"
variant="tonal"
>
<template v-if="notification.id === 'deprecatedpasswordscheme'">
{{
$gettext(
'The password scheme you are using has been deprecated and will be removed in the next minor version. The procedure to upgrade to a stronger scheme is as follows:'
)
}}
<ol>
<li
v-html="
$gettext(
'Go to <strong>Settings > General</strong> section',
true
)
"
></li>
<li
v-html="
$gettext(
'Change the value of <strong>Default password scheme</strong>',
true
)
"
></li>
<li
v-html="
$gettext(
'Make sure <strong>Update password scheme at login</strong> option is enabled',
true
)
"
></li>
<li v-html="$gettext('Save your changes')"></li>
<li>
{{
$gettext(
'Logout / Login with your current account so its password gets updated'
)
}}
</li>
<li
v-html="
$gettext(
'Inform <strong>ALL</strong> your users that they must login to Modoboa to complete the operation',
true
)
"
></li>
</ol>
</template>
</v-alert>
</v-card-text>
</v-card>
<v-card class="mt-6">
<v-card-title>
{{ $gettext('Installed components') }}
@@ -10,10 +76,10 @@
<v-card-text>
<v-alert
v-if="updatesAvailable"
variant="outlined"
variant="tonal"
type="success"
text
border="left"
border="start"
>
<div tag="p">
{{ $gettext('One or more updates are available') }}
@@ -47,12 +113,14 @@
</div>
</template>
<script setup lang="js">
import { useGettext } from 'vue3-gettext'
import adminApi from '@/api/admin'
<script setup>
import { computed, ref, onMounted } from 'vue'
import { useGettext } from 'vue3-gettext'
import { useGlobalStore } from '@/stores'
import adminApi from '@/api/admin'
const { $gettext } = useGettext()
const globalStore = useGlobalStore()
const components = ref([])
const headers = [
+3 -1
View File
@@ -94,10 +94,11 @@ import parametersApi from '@/api/parameters'
import { ref, computed, watch } from 'vue'
import { useGettext } from 'vue3-gettext'
import { useRoute } from 'vue-router'
import { useParametersStore } from '@/stores'
import { useGlobalStore, useParametersStore } from '@/stores'
const { $gettext } = useGettext()
const busStore = useBusStore()
const globalStore = useGlobalStore()
const route = useRoute()
const parametersStore = useParametersStore()
@@ -152,6 +153,7 @@ async function save() {
busStore.displayNotification({
msg: $gettext('Parameters updated'),
})
globalStore.fetchNotifications()
if (route.params.app === 'imap_migration') {
parametersStore.imapMigrationEnabled =
parameters.value.enabled_imapmigration