1
0
Fork 0
mirror of https://gitlab.com/bramw/baserow.git synced 2025-04-12 08:18:07 +00:00
bramw_baserow/web-frontend/middleware/authentication.js

16 lines
509 B
JavaScript

import { getToken } from '@/utils/auth'
export default function({ store, req, app }) {
// If nuxt generate, pass this middleware
if (process.server && !req) return
// Load the token
const token = getToken(app.$cookies)
// If there already is a token we will refresh it to check if it is valid and
// to get fresh user information. This will probably happen on the server
// side.
if (token && !store.getters['auth/isAuthenticated']) {
return store.dispatch('auth/refresh', token)
}
}