Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

auth user is not updated reactively #621

Open
rkevinn opened this issue Apr 15, 2022 · 0 comments
Open

auth user is not updated reactively #621

rkevinn opened this issue Apr 15, 2022 · 0 comments

Comments

@rkevinn
Copy link

rkevinn commented Apr 15, 2022

Hi,

I am using the vuex auth plugin for authentication. I have a profiled field in user. If the user has a complete profile, can access all features, else push the user to Profile page. The profiled field validation is in the router. When the profile is updated, it does not update the authenticated user in the store state.auth.user.

Router.beforeEach((to, from, next) => {
       if (to.meta.requiresAuth) {
           if (store.getters.isAuthenticated) {
               const user = store.getters.user;
               if (store.getters.isProfiled) {
                   // redirects to list
                   next();
               } else {
                   if (to.name == "profile") {
                       next();
                   } else {
                       next(false);
                       return Router.push('profile');
                   }
               }
               next();
           } else {
               next(false);
               return Router.push('login')
           }
       } else {
           next()
       }
   })

I have the following Vuex store (store/index.js):


import Vue from 'vue'
import Vuex from 'vuex'
import client, { BaseModel, makeServicePlugin, makeAuthPlugin, FeathersVuex } from 'src/api/client'
 
Vue.use(Vuex)
Vue.use(FeathersVuex)
 
const store = new Vuex.Store({
   state: {
     ...
   },
   getters: {
       isAuthenticated: state => !!state.auth.accessToken,
       isProfiled: state => !!state.auth.user.profiled,
       user: state => state.auth.user,
   },
   mutations: {
     ...
   },
   actions: {},
   plugins: [
     ...
     ...      
           makeAuthPlugin({ userService: 'user' })
   ]
})
 
export default store

Expected behavior

The profiled in auth/user should change each time when the user profile got updated.

Actual behavior

auth/user is not updated reactively.

System configuration

Tell us about the applicable parts of your setup.

Module versions (especially the part that's not working):

        "@feathersjs/authentication-client": "^4.5.7",
        "@feathersjs/feathers": "^4.5.7",
        "@feathersjs/socketio-client": "^4.5.7",
        "@quasar/extras": "^1.9.3",
        "feathers-vuex": "^3.11.5",
        "quasar": "^1.12.13",
        "socket.io-client": "^2.3.0",

NodeJS version:

v12.22.7

Operating System:

Ubuntu 18.04

Browser Version:

Chrome 97

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant