I want to check if user is authorize before route. i have the method in app.js but when i call the method i get an error. i also tried to put the logic in the route.js it also did not work

This is my route.js

import ProfilePage from '../pages/profile.vue';

function checkAuth({ to, from, resolve, reject }) {

    if (this.$root.userCheck) {

  } else {


var routes = [
    path: '/profile',
    component: ProfilePage,
    beforeEnter : checkAuth,