import { notAuthRedirectPath } from '@/config/auth' ; import selector from '@/store/middleware/auth/selector' ; import { Store } from '@/store/root' ; import Router from 'vue-router' ; export function isNeedRedirect ( path , state ) { return path !== notAuthRedirectPath && selector . isLoggedIn ( state ) && ! selector . isEmailVerified ( state ) ; } export function requiredVerifyEmailMiddleware ( router , state ) { router . beforeEach ( ( to , _ , next ) => { if ( ( isNeedRedirect ( to . path , state ) ) ) { return next ( notAuthRedirectPath ) ; } return next ( ) ; } ) ; }