websanova / vue-auth

A simple light-weight authentication library for Vue.js
MIT License
2.35k stars 383 forks source link

Am i missing something here #140

Closed kyoukhana closed 7 years ago

kyoukhana commented 7 years ago

The code below should be working properly. Can you please take a look. Still having issue with the following. This has to do with Vue.http.options.root. But the strange thing is that if I remove any auth required for the route. It will display without that error

DOMException [NotFoundError: "Node was not found"
import Vue from 'vue'
import VueRouter from 'vue-router'
import VueResource from 'vue-resource'
import App from './components/app.vue'

Vue.use(VueResource);
Vue.use(VueRouter);

Vue.http.options.root="http://www.devqi.com/";

var authOptions = {
    authRedirect:'/',
    auth: require('@websanova/vue-auth/drivers/auth/bearer.js'),
    http: require('@websanova/vue-auth/drivers/http/vue-resource.1.x.js'),
    router: require('@websanova/vue-auth/drivers/router/vue-router.2.x.js'),
    token: [{request: 'token', response: 'token', authType: 'bearer', foundIn: 'header'}],
    tokenName:'token',
    loginData: {url: 'api/auth', method: 'POST', redirect: 'dashboard'},
    logoutData: {url: 'api/logout', method: 'POST', redirect: 'login',  makeRequest: false},
    fetchData: {url: 'api/account', method: 'GET' , authType: 'bearer'},
    refreshData: {enabled: false},
    rolesVar: 'role_id'
};

Vue.use(auth,authOptions);
var component = require('./components/app.vue');
component.router = Vue.router;
new Vue(component).$mount('#app');
kyoukhana commented 7 years ago

Here is something interesting. If I comment this line out

//Vue.http.options.root="http://www.devqi.com";

and then remove all the auth meta it redirects with no errors

Change this

path: '/yinyangadmin/dashboard',name:"dashboardadmin",meta: {auth: ["1","2"]}, component: (resolve) => { require(['./components/views/admin/dashboard.vue'], resolve)},

To this

path: '/yinyangadmin/dashboard',name:"dashboardadmin", component: (resolve) => { require(['./components/views/admin/dashboard.vue'], resolve)},

It Redirects with no issue Keep in mind I am using

"vue": "^2.2.6",
 "@websanova/vue-auth": "^2.8.2-beta",
   "vue-router": "^2.4.0",
websanova commented 7 years ago

I'm guessing it's how you are using your "redirect". Note that the auth plugin just uses the vue-resource $http directly. So everything there gets passed directly in, no magic from vue-auth here.

In this case I see you have set redirects without a forward slash. Should probably be "/login" and "/dashboard" or used name routes, redirect: {name: 'login'} etc..

On Mon, Apr 17, 2017 at 6:37 AM, kyoukhana notifications@github.com wrote:

Here is something interesting. If I comment this line out

//Vue.http.options.root="http://www.devqi.com";

and then remove all the auth meta it redirects with no errors Change this

path: '/yinyangadmin/dashboard',name:"dashboardadmin",meta: {auth: ["1","2"]}, component: (resolve) => { require(['./components/views/admin/dashboard.vue'], resolve)},

To this

path: '/yinyangadmin/dashboard',name:"dashboardadmin", component: (resolve) => { require(['./components/views/admin/dashboard.vue'], resolve)},

It Redirects with no issue Keep in mind I am using

"vue": "^2.2.6", "@websanova/vue-auth": "^2.8.2-beta", "vue-router": "^2.4.0",

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/websanova/vue-auth/issues/140#issuecomment-294380623, or mute the thread https://github.com/notifications/unsubscribe-auth/ABkcy5luJF2TFKdZc8f7MfNsbzWajvOzks5rwqZMgaJpZM4M-tsy .

kyoukhana commented 7 years ago

Thanks for the help. So I change the code to this not much difference. But the problem is that if I add the following below

meta: {auth: ["1","2"]}

to the routes I get

DOMException [NotFoundError: "Node was not found"
code: 8
nsresult: 0x80530008

So I am not 100% sure as to why that is happening.

Vue.http.options.root="http://www.devqi.com";

var authOptions = {
    authRedirect:'/usr/login',
    auth: require('@websanova/vue-auth/drivers/auth/bearer.js'),
    http: require('@websanova/vue-auth/drivers/http/vue-resource.1.x.js'),
    router: require('@websanova/vue-auth/drivers/router/vue-router.2.x.js'),
    token: [{request: 'token', response: 'token', authType: 'bearer', foundIn: 'header'}],
    tokenName:'token',
    loginData: {url: 'api/auth', method: 'POST', redirect: '/usr/dashboard/dashboard'},
    logoutData: {url: 'api/logout', method: 'POST', redirect: 'login',  makeRequest: false},
    fetchData: {url: 'api/account', method: 'GET' , authType: 'bearer'},
    refreshData: {enabled: false},
    rolesVar: 'role_id'
};

Vue.use(auth,authOptions);
var component = require('./components/app.vue');
component.router = Vue.router;
new Vue(component).$mount('#app');
kyoukhana commented 7 years ago

Here is a more detailed recap of the code I am using. So If I remove the meta for auth and comment out

import Vue from 'vue'
import VueRouter from 'vue-router'
import VueResource from 'vue-resource'
import App from './components/app.vue'
import mdl from 'material-design-lite'
import VueMdl from 'vue-mdl'
import VueX from 'vuex'
import axios from 'axios'
import VueAxios from 'vue-axios'
import vdropzone from 'vue2-dropzone'
import VueScollTo from 'vue-scrollto'
import VueLazyload from 'vue-lazyload'
import VeeValidate from 'vee-validate';
import VueQr from 'v-qrcode';
import auth from '@websanova/vue-auth'

Vue.use(VueResource);
Vue.use(VueRouter);
Vue.use(VueMdl);
Vue.use(VueAxios, axios);
Vue.use(VueScollTo);

Vue.use(VueLazyload, {
    preLoad: 1.3,
    error: '/images/loose/loader-error.svg',
    loading: '/images/loose/loader.svg',
    attempt: 5,
    listenEvents: [ 'scroll' ]
})

//Vue.http.options="http://www.devqi.com"

It routes to the dashboard.

If I put the meta auth back in. It will redirect back to /usr/login. So not sure why

Here is a snippet of the code

Vue.router = new VueRouter({
    hashbang: false,
    linkActiveClass: 'active',
    mode: 'history',
    routes: [
           {path: '/yinyangadmin/login',name:'login',meta: {auth: false}, component: (resolve) => { require(['./components/views/admin/login.vue'], resolve)}},
        {
            path: '/yinyangadmin/dashboard',name:"dashboardadmin",component: (resolve) => { require(['./components/views/admin/dashboard.vue'], resolve)},meta: {auth: ["1","2"]},

            children: [
                {
                    path: '', component: (resolve) => { require(['./components/views/admin/dashboardHome.vue'], resolve)} }

            ],

        },

        {path: '/usr/login', component: (resolve) => { require(['./components/views/users/login.vue'], resolve)} },
        {path: '/login', component: (resolve) => { require(['./components/views/users/login.vue'], resolve)} },
        {path: '/usr/login/forgot', component: (resolve) => { require(['./components/views/users/forgot.vue'], resolve)} },
        {path: '/usr/login/reset/:etkn', name:'resettoken', component: (resolve) => { require(['./components/views/users/reset.vue'], resolve)} },
        {path: '/usr/activate/:etkn', name:'useractivate', component: (resolve) => { require(['./components/views/users/activateuser.vue'], resolve)} },
        {path: '/usr/dashboard',name:"dashuser",meta: {auth: true}, component: (resolve) => { require(['./components/views/users/dashboard/dashboard.vue'], resolve)},
        children:[
            {path: '',meta: {auth: true}, component: (resolve) => { require(['./components/views/users/dashboard/dashboardHome.vue'], resolve)}}
          ]}

    ] /*End routing */
});

/*CRFC TOKEN For form validations */
Vue.http.headers.common['X-CSRF-TOKEN'] = document.querySelector('#token').getAttribute('content');

//Vue.http.options.root="http://www.devqi.com";

var authOptions = {
    authRedirect:'/usr/login',
    auth: require('@websanova/vue-auth/drivers/auth/bearer.js'),
    http: require('@websanova/vue-auth/drivers/http/vue-resource.1.x.js'),
    router: require('@websanova/vue-auth/drivers/router/vue-router.2.x.js'),
    token: [{request: 'token', response: 'token', authType: 'bearer', foundIn: 'header'}],
    tokenName:'token',
    loginData: {url: 'api/auth', method: 'POST', redirect: '/usr/dashboard/dashboard'},
    logoutData: {url: 'api/logout', method: 'POST', redirect: 'login',  makeRequest: false},
    fetchData: {url: 'api/account', method: 'GET' , authType: 'bearer'},
    refreshData: {enabled: false},
    rolesVar: 'role_id'
};

Vue.use(auth,authOptions);
var component = require('./components/app.vue');
component.router = Vue.router;
new Vue(component).$mount('#app');
websanova commented 7 years ago

Well you definitely need Vue.http.options.root="http://www.devqi.com"; set otherwise you will get errors during login.

So leave that on, it's some other issue, the meta should not really have an effect, you can leave it out. and see what happens.

On Tue, Apr 18, 2017 at 7:00 AM, kyoukhana notifications@github.com wrote:

Here is a more detailed recap of the code I am using. So If I remove the meta for auth and comment out

//Vue.http.options="http://www.devqi.com"

It routes to the dashboard.

If I put the meta auth back in. It will redirect back to /usr/login. So not sure why

Here is a snippet of the code

Vue.router = new VueRouter({ hashbang: false, linkActiveClass: 'active', mode: 'history', routes: [ {path: '/yinyangadmin/login',name:'login',meta: {auth: false}, component: (resolve) => { require(['./components/views/admin/login.vue'], resolve)}}, { path: '/yinyangadmin/dashboard',name:"dashboardadmin",component: (resolve) => { require(['./components/views/admin/dashboard.vue'], resolve)},meta: {auth: ["1","2"]},

        children: [
            {
                path: '', component: (resolve) => { require(['./components/views/admin/dashboardHome.vue'], resolve)} }

        ],

    },

    {path: '/usr/login', component: (resolve) => { require(['./components/views/users/login.vue'], resolve)} },
    {path: '/login', component: (resolve) => { require(['./components/views/users/login.vue'], resolve)} },
    {path: '/usr/login/forgot', component: (resolve) => { require(['./components/views/users/forgot.vue'], resolve)} },
    {path: '/usr/login/reset/:etkn', name:'resettoken', component: (resolve) => { require(['./components/views/users/reset.vue'], resolve)} },
    {path: '/usr/activate/:etkn', name:'useractivate', component: (resolve) => { require(['./components/views/users/activateuser.vue'], resolve)} },
    {path: '/usr/dashboard',name:"dashuser",meta: {auth: true}, component: (resolve) => { require(['./components/views/users/dashboard/dashboard.vue'], resolve)},
    children:[
        {path: '',meta: {auth: true}, component: (resolve) => { require(['./components/views/users/dashboard/dashboardHome.vue'], resolve)}}
      ]}

] /*End routing */

});

/CRFC TOKEN For form validations / Vue.http.headers.common['X-CSRF-TOKEN'] = document.querySelector('#token').getAttribute('content');

//Vue.http.options.root="http://www.devqi.com";

var authOptions = { authRedirect:'/usr/login', auth: require('@websanova/vue-auth/drivers/auth/bearer.js'), http: require('@websanova/vue-auth/drivers/http/vue-resource.1.x.js'), router: require('@websanova/vue-auth/drivers/router/vue-router.2.x.js'), token: [{request: 'token', response: 'token', authType: 'bearer', foundIn: 'header'}], tokenName:'token', loginData: {url: 'api/auth', method: 'POST', redirect: '/usr/dashboard/dashboard'}, logoutData: {url: 'api/logout', method: 'POST', redirect: 'login', makeRequest: false}, fetchData: {url: 'api/account', method: 'GET' , authType: 'bearer'}, refreshData: {enabled: false}, rolesVar: 'role_id' };

Vue.use(auth,authOptions); var component = require('./components/app.vue'); component.router = Vue.router; new Vue(component).$mount('#app');

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/websanova/vue-auth/issues/140#issuecomment-294630567, or mute the thread https://github.com/notifications/unsubscribe-auth/ABkcy0Y37oADfP6JX0UAnXawMGPZ_Imbks5rw_0rgaJpZM4M-tsy .

kyoukhana commented 7 years ago

Thanks for the help. I did add the

`Vue.http.options.root="http://www.devqi.com";`

When I log in i get the error. In the console

DOMException [NotFoundError: "Node was not found"
code: 8
nsresult: 0x80530008
location: http://www.devqi.com/js/app.js:20708]
kyoukhana commented 7 years ago

So maybe I can shine some light. It seems its a vue-resource issue.

@websanova/vue-auth/drivers/http/vue-resource.1.x.js

Vue-resource generates the error when trying to login

DOMException [NotFoundError: "Node was not found"
code: 8
nsresult: 0x80530008
location: http://www.devqi.com/js/app.js:20708]

If I use

@websanova/vue-auth/drivers/http/axios.1.x.js

I just get stuck in a login loop. All the API's in the back-end haven't changed.

I also talked to some of the guys in Gitter they say it could be related to this

https://github.com/pagekit/vue-resource/blob/2cd014dec1dce477f2c7b22e29ce6179d472f2d3/dist/vue-resource.js#L913

He said that on line 929, status is undefined. That might be tripping it. removeChild will give a DOMException 8.

websanova commented 7 years ago

Can you give me version of all your packages.

On Wed, Apr 19, 2017 at 2:02 AM, kyoukhana notifications@github.com wrote:

So maybe I can shine some light. It seems its a vue-resource issue.

@websanova/vue-auth/drivers/http/vue-resource.1.x.js

Vue-resource generates the error when trying to login

DOMException [NotFoundError: "Node was not found" code: 8 nsresult: 0x80530008 location: http://www.devqi.com/js/app.js:20708]

If I use

@websanova/vue-auth/drivers/http/axios.1.x.js

I just get stuck in a login loop. All the API's in the back-end haven't changed.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/websanova/vue-auth/issues/140#issuecomment-294947402, or mute the thread https://github.com/notifications/unsubscribe-auth/ABkcy3xDnp5iSrZCVVGS2Z3LgqD8eY-Uks5rxQi1gaJpZM4M-tsy .

kyoukhana commented 7 years ago

Here is a list of all my packages

{
  "private": true,
  "dependencies": {
    "@websanova/vue-auth": "^2.9.4-beta",
    "axios": "^0.16.1",
    "babel-core": "^6.24.1",
    "babel-eslint": "^7.2.1",
    "babel-loader": "^6.4.1",
    "babel-plugin-transform-runtime": "^6.23.0",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-stage-2": "^6.24.1",
    "bootstrap-sass": "^3.3.7",
    "css-loader": "^0.23.0",
    "dropzone": "^4.3.0",
    "file-loader": "^0.9.0",
    "gulp": "^3.9.1",
    "image-webpack-loader": "^3.3.0",
    "jimp": "^0.2.27",
    "jquery": "^3.1.0",
    "laravel-elixir": "^6.0.0-9",
    "laravel-elixir-vue-2": "^0.2.0",
    "laravel-elixir-webpack-official": "^1.0.2",
    "lodash": "^4.16.2",
    "material-design-lite": "^1.3.0",
    "path": "^0.12.7",
    "responsive-loader": "^0.7.0",
    "style-loader": "^0.13.0",
    "svg-url-loader": "^1.1.0",
    "url-loader": "^0.5.8",
    "v-qrcode": "^1.0.3",
    "vee-validate": "^1.0.0-beta.10",
    "vue": "^2.2.6",
    "vue-auth": "^1.0.0-alpha.1",
    "vue-axios": "^1.2.2",
    "vue-hot-reload-api": "^2.0.11",
    "vue-html-loader": "1.2.3",
    "vue-lazyload": "^1.0.3",
    "vue-loader": "^11.3.4",
    "vue-mdl": "^1.1.1",
    "vue-progressbar": "^0.7.1",
    "vue-resource": "^1.2.1",
    "vue-router": "^2.4.0",
    "vue-scrollto": "^2.4.2",
    "vue-strap": "^1.0.11",
    "vue-style-loader": "^1.0.0",
    "vue-template-compiler": "^2.2.6",
    "vue2-dropzone": "^2.2.5",
    "vuelidate": "^0.2.0",
    "vuex": "^2.3.0",
    "webpack": "^2.3.3",
    "webpack-dev-server": "^1.16.1"
  },
  "devDependencies": {
    "autoprefixer-loader": "^3.2.0",
    "babel-core": "^6.17.0",
    "babel-loader": "^6.2.5",
    "babel-preset-es2015": "^6.16.0",
    "image-webpack-loader": "^3.2.0",
    "srcset-loader": "^2.0.1"
  },
  "scripts": {
    "build": "webpack --config webpack.config.prod.js"
  }
}
websanova commented 7 years ago

Ok, could be issue with latest vue router or vue. I will check it tonight.

On Wed, Apr 19, 2017 at 9:14 AM, kyoukhana notifications@github.com wrote:

Here is a list of all my packages

{ "private": true, "dependencies": { "@websanova/vue-auth": "^2.9.4-beta", "axios": "^0.16.1", "babel-core": "^6.24.1", "babel-eslint": "^7.2.1", "babel-loader": "^6.4.1", "babel-plugin-transform-runtime": "^6.23.0", "babel-preset-es2015": "^6.24.1", "babel-preset-stage-2": "^6.24.1", "bootstrap-sass": "^3.3.7", "css-loader": "^0.23.0", "dropzone": "^4.3.0", "file-loader": "^0.9.0", "gulp": "^3.9.1", "image-webpack-loader": "^3.3.0", "jimp": "^0.2.27", "jquery": "^3.1.0", "laravel-elixir": "^6.0.0-9", "laravel-elixir-vue-2": "^0.2.0", "laravel-elixir-webpack-official": "^1.0.2", "lodash": "^4.16.2", "material-design-lite": "^1.3.0", "path": "^0.12.7", "responsive-loader": "^0.7.0", "style-loader": "^0.13.0", "svg-url-loader": "^1.1.0", "url-loader": "^0.5.8", "v-qrcode": "^1.0.3", "vee-validate": "^1.0.0-beta.10", "vue": "^2.2.6", "vue-auth": "^1.0.0-alpha.1", "vue-axios": "^1.2.2", "vue-hot-reload-api": "^2.0.11", "vue-html-loader": "1.2.3", "vue-lazyload": "^1.0.3", "vue-loader": "^11.3.4", "vue-mdl": "^1.1.1", "vue-progressbar": "^0.7.1", "vue-resource": "^1.2.1", "vue-router": "^2.4.0", "vue-scrollto": "^2.4.2", "vue-strap": "^1.0.11", "vue-style-loader": "^1.0.0", "vue-template-compiler": "^2.2.6", "vue2-dropzone": "^2.2.5", "vuelidate": "^0.2.0", "vuex": "^2.3.0", "webpack": "^2.3.3", "webpack-dev-server": "^1.16.1" }, "devDependencies": { "autoprefixer-loader": "^3.2.0", "babel-core": "^6.17.0", "babel-loader": "^6.2.5", "babel-preset-es2015": "^6.16.0", "image-webpack-loader": "^3.2.0", "srcset-loader": "^2.0.1" }, "scripts": { "build": "webpack --config webpack.config.prod.js" } }

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/websanova/vue-auth/issues/140#issuecomment-295042562, or mute the thread https://github.com/notifications/unsubscribe-auth/ABkcy1-8BjLprBscU1efZarZYKmJLUNPks5rxW34gaJpZM4M-tsy .

websanova commented 7 years ago

ok, i just upped to the latest in my demo, all looks good to me. At this point I would need a fiddle, seems you have a lot of code going on.

kyoukhana commented 7 years ago

do i need to update the package?

websanova commented 7 years ago

Well vue resource is 1.3.1 so maybe update to latest for all your vue packages?

kyoukhana commented 7 years ago

Just double checking is this all correct?

/*API URL */
Vue.http.options.root="http://www.devqi.com/api";

var authOptions = {
    authRedirect:'/usr/login',
    auth: require('@websanova/vue-auth/drivers/auth/bearer.js'),
    http: require('@websanova/vue-auth/drivers/http/vue-resource.1.x.js'),
    router: require('@websanova/vue-auth/drivers/router/vue-router.2.x.js'),
    token: [{request: 'token', response: 'token', authType: 'bearer', foundIn: 'header'}],
    tokenName:'token',
    loginData: {url: 'auth', method: 'POST', redirect: '/usr/dashboard/dashboard'},
    logoutData: {url: 'logout', method: 'POST', redirect: 'login',  makeRequest: false},
    fetchData: {url: 'account', method: 'GET' , authType: 'bearer'},
    refreshData: {enabled: false},
    rolesVar: 'role_id'
};

Vue.use(require('@websanova/vue-auth'),authOptions);
var component = require('./components/app.vue');
component.router = Vue.router;
new Vue(component).$mount('#app');
kyoukhana commented 7 years ago

In your demo I don't see you import VueAuth?

import VueAuth from '@websanova/vue-auth'  

Vue.http.options.root="http://www.devqi.com/api";

var authOptions = {
    authRedirect:'/usr/login',
    auth: require('@websanova/vue-auth/drivers/auth/bearer.js'),
    http: require('@websanova/vue-auth/drivers/http/vue-resource.1.x.js'),
    router: require('@websanova/vue-auth/drivers/router/vue-router.2.x.js'),
    token: [{request: 'token', response: 'token', authType: 'bearer', foundIn: 'header'}],
    tokenName:'token',
    loginData: {url: 'auth', method: 'POST', redirect: '/usr/dashboard/dashboard'},
    logoutData: {url: 'logout', method: 'POST', redirect: 'login',  makeRequest: false},
    fetchData: {url: 'account', method: 'GET' , authType: 'bearer'},
    refreshData: {enabled: false},
    rolesVar: 'role_id'
};

Vue.use(VueAuth,authOptions);
var component = require('./components/app.vue');
component.router = Vue.router;
new Vue(component).$mount('#app');
kyoukhana commented 7 years ago

So the problem is with vue-resource. That error

DOMException [NotFoundError: "Node was not found"
code: 8
nsresult: 0x80530008
location: http://www.devqi.com/js/app.js:20708]

Has to do with some configuration not being returned or read. Its coming from the following file

@websanova/vue-auth/drivers/http/vue-resource.1.x.js

Code from the file

    _http: function (data) {
        this.options.Vue.http(data).then(data.success,data.error);
    },
kyoukhana commented 7 years ago

Ok here is some insight. I edited @websanova/vue-auth/src/auth.js and put some debug code. When I submit my form the following gets passed

Object { url: "/api/auth", method: "POST", redirect: "/dashboard", fetchUser: true, body: Object, rememberMe: true, success: __duckPunch/data.success(), error: module.exports._bindData/data.error(), query: Object }

Login Auth Code

    this.$auth.login({
                    body: this.data.body,
                    rememberMe: true,
                    redirect: '/dashboard',
                    success() {
                        console.log('success ');
                    },
                    error(res) {
                        console.log('error ' );
                        this.error = res.data;
                    }
                });

Thanks for the help I am really stuck on this

kyoukhana commented 7 years ago

Ok so let me shine some light. If I use Axios which is another problem but the route redirects with no problem. Then I went back to the vue-resource driver and modified the following code. This redirects with no issue or problems. There is a problem with

this.options.Vue.http(data).then(data.success,data.error);

It looks like in the latest version of vue-resource it might require some additional parameters https://github.com/pagekit/vue-resource/blob/develop/docs/config.md

   _http: function (data) {

        //this.options.Vue.http(data).then(data.success,data.error);

        var router = this.options.Vue.router;
        this.options.Vue.http(data).then(response => {
            router.push(data.redirect);
        }, response => {
            console.log(data);
        });
    },
kyoukhana commented 7 years ago

So finally Isolated the issue. The error actually comes up when its pulling account.

fetchData: {url: 'api/account', method: 'GET' , authType: 'bearer'}

I debugged this using what you had as a auth

Vue.use(VueAuth, {
    auth: {
        request: function (req, token) {
            this.options.http._setHeaders.call(this, req, {Authorization: 'Bearer ' + token});
        },

        response: function (res) {
            var headers = this.options.http._getHeaders.call(this, res),
                token = headers.Authorization || headers.authorization;

            if (token) {
                // token = token.split(/Bearer\:?\s?/i);
                //
                // return token[token.length > 1 ? 1 : 0].trim();

                console.log(token);

            }
        }
    },
    //http: require('@websanova/vue-auth/drivers/http/axios.1.x.js'),
    http: require('@websanova/vue-auth/drivers/http/vue-resource.1.x.js'),
    router: require('@websanova/vue-auth/drivers/router/vue-router.2.x.js'),
    loginData: {url: 'api/auth', method: 'POST', redirect: 'dashboard'},
    logoutData: {url: 'api/logout', method: 'POST', redirect: 'login',  makeRequest: false},
    fetchData: {url: 'api/account', method: 'GET' , authType: 'bearer'},
    refreshData: { enabled: false },
    rolesVar: 'role_id',
    token: [{request: 'token', response: 'token', authType: 'bearer', foundIn: 'header'}],
    tokenName:'token',
})

Account returns the following data

{
  "status": "success",
  "data": {
    "id": 10,
    "role_id": "4",
    "name": "John",
    "lastname": "doe",
    "email": "jdoe@gmail.com,
    "lang": "en",
    "referral_code": "zoltar",
    "created_at": "2016-10-11 19:26:09",
    "updated_at": "2017-01-11 02:50:58",
    "stripe_id": null,
    "card_brand": null,
    "card_last_four": null,
    "trial_ends_at": null,
    "subscribe_cat_id": 1,
    "activated": 1,
    "verified": 1,
    "email_token": null
  }
}

Is there something missing

kyoukhana commented 7 years ago

So I think I have found the problem but need help in fixing it. The original error is

DOMException [NotFoundError: "Node was not found"
code: 8
nsresult: 0x80530008
location: http://www.devqi.com/js/app.js:20708]

This issue is caused by the token isn't being passed to account. How can we fix this

I change the code in @websanova/vue-auth/drivers/http/vue-resource.1.x.js to this

    _http: function (data) {

        var dataUrl=data.url;
        if(dataUrl='api/account'){
            this.options.Vue.http.get(dataUrl).then(response => {
               //console.log(response);
            }, response => {
                //console.log(response);
            });
        }
        else
        {
            this.options.Vue.http(data).then(data.success,data.error);
        }

    }

But I don't know how to get the token at this point

websanova commented 7 years ago

Huh? Is that a typo? You set dataUrl = to in the if check??

On Apr 22, 2017 03:00, "kyoukhana" notifications@github.com wrote:

So I think I have found the problem but need help in fixing it. The original error is

DOMException [NotFoundError: "Node was not found" code: 8 nsresult: 0x80530008 location: http://www.devqi.com/js/app.js:20708]

This issue is caused by the token isn't being passed to account. How can we fix this

I change the code in @websanova/vue-auth/drivers/http/vue-resource.1.x.js to this

_http: function (data) {

    var dataUrl=data.url;
    if(dataUrl='api/account'){
        this.options.Vue.http.get(dataUrl).then(response => {
           //console.log(response);
        }, response => {
            //console.log(response);
        });
    }
    else
    {
        this.options.Vue.http(data).then(data.success,data.error);
    }

}

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/websanova/vue-auth/issues/140#issuecomment-296292415, or mute the thread https://github.com/notifications/unsubscribe-auth/ABkcy8k0Fc5uEHXqHucyzG15nC44iJ70ks5ryQrigaJpZM4M-tsy .

kyoukhana commented 7 years ago

It should be like this

if(dataUrl='api/account')
websanova commented 7 years ago

You're setting it equal to ? That will always be true.

On Sat, Apr 22, 2017 at 7:54 AM, kyoukhana notifications@github.com wrote:

It should be like this

if(dataUrl='api/account')

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/websanova/vue-auth/issues/140#issuecomment-296335593, or mute the thread https://github.com/notifications/unsubscribe-auth/ABkcyxHEpMfRlSYHUZjxy22n_cqjKv5Sks5ryU_PgaJpZM4M-tsy .

kyoukhana commented 7 years ago

sorry i see it now.
Should be like this

if(dataUrl=='api/account')

Thanks for the help

kyoukhana commented 7 years ago

So now the code looks like this. When I console log the data I get the following but without any token.

Object { url: "api/account", method: "GET", enabled: true, authType: "bearer", success: __duckPunch/data.success(), error: _fetchPerform/data.error() }
    _http: function (data) {
       // this.options.Vue.http(data).then(data.success,data.error);

        var dataUrl=data.url;
        if(dataUrl=='api/account'){

            console.log(data);

        }
        else
        {
            this.options.Vue.http(data).then(data.success,data.error);
        }

    },
websanova commented 7 years ago

I dunno man, seems you got some funky stuff going on.

On Sat, Apr 22, 2017 at 9:01 AM, kyoukhana notifications@github.com wrote:

So now the code looks like this. When I console log the data I get the following but without any token.

Object { url: "api/account", method: "GET", enabled: true, authType: "bearer", success: __duckPunch/data.success(), error: _fetchPerform/data.error() }

_http: function (data) {
   // this.options.Vue.http(data).then(data.success,data.error);

    var dataUrl=data.url;
    if(dataUrl=='api/account'){

        console.log(data);

    }
    else
    {
        this.options.Vue.http(data).then(data.success,data.error);
    }

},

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/websanova/vue-auth/issues/140#issuecomment-296339580, or mute the thread https://github.com/notifications/unsubscribe-auth/ABkcy1fJuhtnj_uFRPHMAKZp3-bMQMYgks5ryV9hgaJpZM4M-tsy .

kyoukhana commented 7 years ago

I sent you a email can you please take a look. Thanks for the help. I am missing something and its small.

websanova commented 7 years ago

Yes, I seen your email, I don't really have time for this. You would need to provide me a fiddle with isolated issue at this point.

On Sat, Apr 22, 2017 at 9:09 AM, kyoukhana notifications@github.com wrote:

I sent you a email can you please take a look. Thanks for the help. I am missing something and its small.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/websanova/vue-auth/issues/140#issuecomment-296340105, or mute the thread https://github.com/notifications/unsubscribe-auth/ABkcy7Fcovq_XUPXRMBbx25Y05u8B903ks5ryWFVgaJpZM4M-tsy .

kyoukhana commented 7 years ago

How can I do that. Its a application. The problem is that after pulling this information

fetchData: {url: 'api/account', method: 'GET' , authType: 'bearer',enabled: true}

Once it processes this then that DOM ERROR comes up. It even happens with the basic route with meta auth.