Logged in/ Logged out

- Created midlewares for authenticated and guest]
- Add the token to the api calls
- Added redirect after the login
This commit is contained in:
2020-11-11 20:26:45 +00:00
parent fe1a5d77c3
commit 6945c27ec0
13 changed files with 597 additions and 21 deletions

View File

@@ -0,0 +1,6 @@
export default function ({ store, redirect }) {
// If the user is not authenticated
if (!store.state.auth.loggedIn) {
return redirect('/login')
}
}

6
middleware/guest.js Normal file
View File

@@ -0,0 +1,6 @@
export default function ({ store, redirect }) {
// If the user is not authenticated
if (store.state.auth.loggedIn) {
return redirect('/')
}
}