18 lines
438 B
JavaScript
18 lines
438 B
JavaScript
/**
|
|
* @description Middleware to check if user is admin
|
|
*/
|
|
import { hasStoredSessionToken } from "@/services/sessionStorage.js";
|
|
|
|
export default function adminMiddleware({ next, router }) {
|
|
if (!hasStoredSessionToken()) {
|
|
return router.push({
|
|
// Redirect to login page
|
|
name: 'login',
|
|
// Set redirect path to current route
|
|
query: { redirect: window.location.href }
|
|
});
|
|
}
|
|
|
|
return next();
|
|
}
|