title: Trouble getting user data inside vue-router from composition
body: <p>I'm very new to vue.js, I am currently working on my final assignment for university.</p>
  <p>I'm trying to get information of my user into my router, this works fine on my usual pages/components, but the techniques used on those files don't seem to work here. I've tried reading through some of the documention for router and composition, but I can't seem to figure out where I'm going wrong. This is my latest attempt as earlier I was not using <code>setup()</code> and getting the error; <code>inject() can only be used inside setup() or functional components.</code></p>
  <p>The problem is occuring with &quot;useAuth,&quot; I'm not getting any data, my <code>console.log(isAdmin)</code> is displaying 'undefined,' this should be a boolean true/false.</p>
  <p>Router code:</p>
  <pre><code>import { createWebHistory, createRouter } from &quot;vue-router&quot;;
  import Dashboard from &quot;../pages/DashboardSDT.vue&quot;;
  import Events from &quot;../pages/EventsSDT.vue&quot;;
  import Results from &quot;../pages/ResultsSDT.vue&quot;;
  import Admin from &quot;../pages/AdminSDT.vue&quot;;
  import Settings from &quot;../pages/SettingsSDT.vue&quot;;
  import Login from &quot;../pages/LoginSDT.vue&quot;;
  import Register from &quot;../pages/RegisterSDT.vue&quot;;
  import { getAuth } from &quot;firebase/auth&quot;;
  import useAuth from &quot;../composition/useAuth&quot;;
  
  const routes = [
      {
          path: &quot;/&quot;,
          name: &quot;Dashboard&quot;,
          component: Dashboard
      },
      {
          path: &quot;/Events&quot;,
          name: &quot;Events&quot;,
          component: Events
      },
      {
          path: &quot;/Results&quot;,
          name: &quot;Results&quot;,
          component: Results
      },
      {
          path: &quot;/Admin&quot;,
          name: &quot;Admin&quot;,
          component: Admin,
          meta: { onlyAdminUser: true }
      },
      {
          path: &quot;/Settings&quot;,
          name: &quot;Settings&quot;,
          component: Settings,
          meta: { onlyAuthUser: true }
      },
      {
          path: &quot;/Login&quot;,
          name: &quot;Login&quot;,
          component: Login,
          meta: { onlyGuestUser: true }
      },
      {
          path: &quot;/Register&quot;,
          name: &quot;Register&quot;,
          component: Register,
          meta: { onlyGuestUser: true }
      }
  ]
  
  const router = createRouter({
      history: createWebHistory(),
      routes
  })
  
  
  
  router.beforeEach((to, _, next) =&gt; {
      const isAuth = !!getAuth().currentUser;
      const isAdmin = useAuth.admin;
      console.log(isAdmin)
  
      if (to.meta.onlyAuthUser) {
          if (isAuth) {
              next()
          } else {
              next({ name: &quot;Login&quot; })
          }
          // } else if(to.meta.onlyAdminUser) {
          //     if(isAdmin) {
          //         next()
          //     }
          //     else {
          //         next({name: &quot;BasicUser&quot;})
          //     }
      } else if (to.meta.onlyGuestUser) {
          if (isAuth) {
              next({ name: &quot;Dashboard&quot; })
          } else {
              next()
          }
      } else {
          next()
      }
  })
  
  export default {
      setup() {
          return {
              ...useAuth()
          }
      },
      ...router
  }
  </code></pre>
  <p>useAuth code:</p>
  <pre><code>import { useStore } from 'vuex'
  import { computed } from 'vue'
  
  export default function useAuth() {
      const store = useStore();
      const { state } = store;
  
      const error = computed(() =&gt; state.user.auth.error);
      const isProcessing = computed(() =&gt; state.user.auth.isProcessing);
      const isAuthenticated = computed(() =&gt; store.getters[&quot;user/isAuthenticated&quot;]);
      const user = computed(() =&gt; state.user.data);
      const admin = computed(() =&gt; state.user.data.admin);
  
      return {
          error,
          isProcessing,
          isAuthenticated,
          user,
          admin
      }
  }
  </code></pre>