Named Middleware
Using named middleware to authenticate a user using the store and allow them to visit a page once authenticated
In this example:
pages/named-middleware.vue
contains a middleware
property with the value of auth
which is called before a user enters the route.
middleware/auth.js
checks to see if the user is authenticated and if they aren't it redirects them to the auth page.
pages/auth.vue
uses the store to authenticate the user.
store/auth.js
sets the user and password values and redirects the user.
Learn more in the Directory Structure book in the middleware chapter.
Loading Sandbox...
Edit this page on GitHub
Updated at Mon, Aug 19, 2024
Sébastien Chopin
Nazaré da Piedade
Nobu
川音리오
Maciek Palmowski
Nestor Vera
Daniel Roe
Yue Yang
Jeronimas
Clément Ollivier
Alexander Lichter
N3-rd
Adrien Zaganelli
Mag
Stefan Huber
Olga Bulat
Paiva
Florian Reuschel
Savas Vedova
HIJACK
Vinícius Alves
Kareem Dabbeet
Valentín Costa
Ryan Skinner
Alex Hirzel
Ajeet Chaulagain
René Eschke
Nico Devs
Muhammad
Naoki Hamada
Tom
Yann Aufray
Anthony Chu
Nuzhat Minhaz
Lucas Portet
Richard Schloss
Bobby
bpy
Antony Konstantinidis
Hibariya
Jose Seabra
Eze
Florian Lefebvre
Lucas Recoaro
Julien SEIXAS