Display text when login on new-admin

This commit is contained in:
Spitfireap
2024-12-20 22:15:48 +01:00
parent 97e2cf27dd
commit 52c31a2838
5 changed files with 40 additions and 11 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
FROM python:3.12-alpine AS base
FROM python:3.12-alpine3.20 AS base
LABEL org.opencontainers.image.authors="Antoine Nguyen <tonio@ngyn.org>"
ENV VIRTUAL_ENV=/opt/venv
+12 -6
View File
@@ -280,15 +280,21 @@ router.beforeEach(async (to, from, next) => {
if (!authStore.authUser) {
await authStore.initialize()
}
authStore.validateAccess()
if (to.meta.allowedRoles !== undefined) {
if (to.meta.allowedRoles.indexOf(authStore.authUser.role) === -1) {
const isAuth = await authStore.validateAccess()
if (isAuth) {
if (to.meta.allowedRoles !== undefined) {
if (to.meta.allowedRoles.indexOf(authStore.authUser.role) === -1) {
next({ name: 'Dashboard' })
return
}
}
if (to.meta.requiresMailbox && !authStore.authUser.mailbox) {
next({ name: 'Dashboard' })
return
}
}
if (to.meta.requiresMailbox && !authStore.authUser.mailbox) {
next({ name: 'Dashboard' })
} else {
next({ name: 'Login' })
return
}
}
next()
+4 -2
View File
@@ -115,11 +115,11 @@ export const useAuthStore = defineStore('auth', () => {
async function validateAccess() {
const user = await manager.getUser()
if (!user || user.expired) {
manager.signinRedirect()
return
return false
}
repository.defaults.headers.common.Authorization = `Bearer ${user.access_token}`
repository.defaults.headers.post['Content-Type'] = 'application/json'
return true
}
async function login() {
@@ -145,6 +145,8 @@ export const useAuthStore = defineStore('auth', () => {
return user
} catch (error) {
console.error('Error completing login:', error)
// Redirect to Dashboard so the router will attempt again login
router.push({ name: 'Dashboard' })
return null
}
}
@@ -9,4 +9,18 @@ onMounted(() => {
</script>
<template>
<v-container class="fill-height" fluid>
<v-row align="center" justify="center">
<v-col cols="auto" class="text-center">
<h1 class="ma-5">{{ $gettext('Attempting to log you in.') }}</h1>
<v-progress-circular
color="primary"
indeterminate
:size="128"
:width="12"
align-self="center"
></v-progress-circular>
</v-col>
</v-row>
</v-container>
</template>
+9 -2
View File
@@ -13,8 +13,15 @@ onMounted(() => authStore.login())
<template>
<v-container class="fill-height" fluid>
<v-row align="center" justify="center">
<v-col>
<h1>{{ $gettext('Attempting to log you in.') }}</h1>
<v-col cols="auto" class="text-center">
<h1 class="ma-5">{{ $gettext('Attempting to log you in.') }}</h1>
<v-progress-circular
color="primary"
indeterminate
:size="128"
:width="12"
align-self="center"
></v-progress-circular>
</v-col>
</v-row>
</v-container>