You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For you to understand my doubt, I'm migrating my projet to Vite+Pinia+Ts+elementUI Plus. But I ran into a problem with my permissions
I can't use next({ ...to, replace: true })
when I load the page it works, when I press F5 the permission error
I'll leave some examples...
Previous version:
``
import router from './router'
import store from './store'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
import AuthService from '@/services/auth.service'
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
For you to understand my doubt, I'm migrating my projet to Vite+Pinia+Ts+elementUI Plus. But I ran into a problem with my permissions
I'll leave some examples...
Previous version:
``
import router from './router'
import store from './store'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
import AuthService from '@/services/auth.service'
NProgress.configure({ showSpinner: false })
const whiteList = ['/login']
router.beforeEach(async (to, from, next) => {
AuthService.validaLogin().then( async (resultValidaLogin) => {
const hasToken = resultValidaLogin
//Start progress bar
NProgress.start()
})
})
router.afterEach(() => {
// finish progress bar
NProgress.done()
})
My version of now
import router from "@/router"
import { configure, start, done } from "nprogress"
import "nprogress/nprogress.css"
import AuthService from "@/utils/auth.service"
import { useUserStore } from "@/store/userAuth"
import { usePermissionStore } from "@/store/permission"
configure({ showSpinner: false })
const whiteList = ['/login']
router.beforeEach((to, _from, next) => {
AuthService.validaLogin().then( async (hasToken) => {
//Start progress bar
start()
if(hasToken !== 'Invalido') {
if(to.path === whiteList[0]){
next({ path: '/' })
done()
} else {
try {
const userPermissionInfo = await useUserStore().userPermissionInfo
const accessRoutes = await usePermissionStore().generateRoutes(userPermissionInfo)
})
})
router.afterEach(() => {
// finish progress bar
done()
})
Beta Was this translation helpful? Give feedback.
All reactions