If I logout the store keeps all the auth data, this memory can be cleaned by default?
Good catch. Yeah that probably should be a configurable default.
Maybe I can help with this?
I'm struggling with the same problem !
Do you have any workaround ?
Maybe this can help? https://forum-archive.vuejs.org/topic/4365/restore-state-item-to-initial-value/7
A workaround that would be quite simple would be to do a full redirect after logout.
I like that solution, thanks.
Thanks for the link, too. I think that will help me implement a fix without a redirect.
For the moment I'm doing this
methods: {
...mapActions('auth', ['logout']),
logoutRedirect() {
// Force vuex reset with $router.go
this.logout().then(() => this.$router.go({ name: 'Login' }))
},
},
On the readme there is a mutation called 'clearAll', I can use this for clearing a service right?
How I can call this method?
@ellipticaldoor you can get access to it using the mapMutations helper:
import { mapMutations } from 'vuex'
export default {
methods: {
...mapMutations('todos', [
'clearAll', // lets you do `this.clearAll()` inside the component
]),
...mapMutations('todos', {
clearTodos: 'clearAll' // lets you do `this.clearTodos()` inside the component
})
}
}
@marshallswain works fine for me! should I close this issue?
Not yet. I'll be looking at ways to wipe out all data on logout, so it doesn't have to be wired up manually. Thanks!
Any updates on this?
Not yet. Building towards an update. Damn house got flooded and stole my entire vacation. 😢
When using nuxt.js it keeps all the data in the server, it even authenticates.
@DaviTeodoro could you expound on that a bit? I think you might be saying that the cookie is not getting deleted on logout so you still appear as logged in when you refresh?
@marshallswain it is strange. I dont know yet what is happening, but I think it's a problem with the feathersVuex. If I log in and then log out the server seems to keep all the data. Later on, If I refresh the page the app authenticates the last user for a second then log him out. Inspecting the vueStore it looks like there is a "base state" with all the data, even the auth data from the last user. More strange yet is the fact that this information seems to come from the server.
If you dont mind to take a look in the screnshot I took, you can see the "baseState" with the auth information, it also has a errorOnAuthenticate object that says it can't login properly, because, in fact, there is no cookie, so it begins the auth/logout mutation.
The screenshot: https://imgur.com/a/nIREB
btw, my packages
"engines": {
"node": ">= 6.11.0",
"npm": ">= 3.0.0"
},
"scripts": {
"test": "npm run eslint && npm run mocha",
"eslint": "eslint src/. test/. --config .eslintrc.js",
"build": "nuxt build",
"dev": "cross-env-shell DEBUG=nuxt:* nodemon --watch src/ --watch config/ src/index.js",
"prestart": "npm run build",
"start": "NODE_ENV=production node src/",
"mocha": "mocha test/ --recursive"
},
"dependencies": {
"nuxtjs/bootstrap-vue": "^2.0.2",
"nuxtjs/google-analytics": "^1.0.0",
"nuxtjs/sitemap": "0.0.3",
"algoliasearch": "^3.24.5",
"axios": "^0.16.2",
"body-parser": "^1.18.0",
"compression": "^1.7.0",
"cookie-storage": "^3.1.0",
"cors": "^2.8.4",
"feathers": "^2.2.0",
"feathers-authentication": "^1.2.7",
"feathers-authentication-client": "^0.3.3",
"feathers-authentication-hooks": "^0.1.4",
"feathers-authentication-jwt": "^0.3.2",
"feathers-authentication-local": "^0.4.4",
"feathers-authentication-oauth2": "^0.3.2",
"feathers-configuration": "^0.4.1",
"feathers-errors": "^2.9.2",
"feathers-hooks": "^2.0.2",
"feathers-hooks-common": "^3.7.2",
"feathers-mongoose": "^5.1.2",
"feathers-rest": "^1.8.0",
"feathers-socketio": "^2.0.0",
"feathers-vuex": "^0.8.0",
"helmet": "^3.8.1",
"js-cookie": "^2.1.4",
"mongoose": "^4.11.11",
"normalize.css": "^7.0.0",
"nuxt": "^1.0.0-rc11",
"passport-facebook": "^2.1.1",
"passport-google-oauth20": "^1.0.0",
"serve-favicon": "^2.4.3",
"socket.io-client": "^2.0.3",
"validator": "^9.0.0",
"vue-multiselect": "^2.0.3",
"vue-quill-editor": "^2.3.3",
"winston": "^2.3.1"
},
"devDependencies": {
"cross-env": "^5.1.0",
"eslint": "^4.6.1",
"eslint-config-airbnb": "^15.1.0",
"eslint-import-resolver-webpack": "^0.8.3",
"eslint-plugin-html": "^3.2.1",
"eslint-plugin-import": "^2.7.0",
"mocha": "^3.5.3",
"nodemon": "^1.12.0",
"request": "^2.81.0",
"request-promise": "^4.2.1"
}
Thank you for your time !
Do you have any vuex backup plugin?
On Oct 22, 2017, at 7:17 PM, Davi Teodoro notifications@github.com wrote:
@marshallswain https://github.com/marshallswain it is strange. I dont know yet what is happening, but I think it's a problem with the feathersVuex. If I log in and then log out the server seems to keep all the data. Later on, If I refresh the page the app authenticates the last user for a second then log him out. Inspecting the vueStore it looks like there is a "base state" with all the data, even the auth data from the last user. More strange yet is the fact that this information seems to come from the server.
If you dont mind to take a look in the screnshot I took, you can see the "baseState" with the auth information, it also has a errorOnAuthenticate object that says it can't login properly, because, in fact, there is no cookie, so it beggins the auth/logout mutation.
The screenshot: https://imgur.com/a/nIREB https://imgur.com/a/nIREB
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/feathers-plus/feathers-vuex/issues/10#issuecomment-338524609, or mute the thread https://github.com/notifications/unsubscribe-auth/AAH3WaBn3UVSP8rBb_UXwQAVHHYh8zZ3ks5su-ksgaJpZM4NR16M.
No @marshallswain , I dont have any. Or if I do I didn't know. I'm using the template used in this article https://blog.feathersjs.com/ssr-vuejs-app-with-feathers-and-nuxt-bb7dfd3e6397
Any update here? I'm experiencing the same issue. Basically, when I logout, the accessToken is cleared from the auth store and the browser cookies are removed, but if I reload the page, the accessToken mysteriously reappears in the auth store. Only stopping and starting the server ensures that the accessToken does not reappear in the store. Thoughts?
Can you use the dev tools to verify that the cookies are for sure not being
sent in the request?
On Thu, Jan 11, 2018 at 12:15 AM briankilgore notifications@github.com
wrote:
Any update here? I'm experiencing the same issue. Basically, when I
logout, the accessToken is cleared from the auth store and the browser
cookies are removed, but if I reload the page, the accessToken mysteriously
reappears in the auth store. Only stopping and starting the server ensures
that the accessToken does not reappear in the store. Thoughts?—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/feathers-plus/feathers-vuex/issues/10#issuecomment-356846679,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAH3Wev0tE8U7P6e5GHyonlygo7S0mvjks5tJbT6gaJpZM4NR16M
.
I'm fairly new to feathers and working with sockets, but I inspected the network traffic like I would do for typical HTTP type requests and didn't see any cookies being passed in the requests. I also added a console.log() on the server side to output the headers for all requests and while I see the cookie for authenticated requests, as soon as I log out the cookies no longer appear.
Something else that I just noticed as I was testing this--if I log in and then immediately log out, the cookie clears and doesn't reappear in the store. However, if I log in, then do a browser reload while logged in, and then log out, the behavior that I described above returns. Since when I do the browser reload while logged in it re-runs nuxtServerInit() and thus initAuth(), maybe something in there is caching the cookie somewhere?
Ok. This is valuable information for when I troubleshoot this. Thank you.
So, I took initAuth() completely out of the equation and the problem persists. Here is my new nuxtServerInit()
nuxtServerInit: function ({ commit, dispatch }, { req }) { // eslint-disable-line consistent-return
const accessToken = parseCookies(req)['feathers-jwt'];
if (accessToken) {
console.log('nuxtServerInit - $accessToken', accessToken);
return dispatch('auth/authenticate', { strategy: 'jwt', accessToken });
}
// let auth = initAuth({
// commit,
// dispatch,
// req,
// moduleName: 'auth',
// cookieName: 'feathers-jwt',
// });
return auth;
},
@briankilgore wich store do you use? when i use the CookieStorage i get a ReferenceError: document is not defined
@superbarne Sorry, somehow I missed this. I am using js-cookie
Any news @marshallswain ?
Thanks!
I will post news when there is some.
On Sat, Jul 7, 2018 at 5:45 PM Ricardo Polo notifications@github.com
wrote:
Any news @marshallswain https://github.com/marshallswain ?
Thanks!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/feathers-plus/feathers-vuex/issues/10#issuecomment-403250214,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAH3WeeifI7Y5TSGb-NXwEdFNt8H9GxWks5uEUgEgaJpZM4NR16M
.
Refreshing the browser is the official solution. I don't feel like it's worth it to do anything else when there's such a simple, clean solution. I've added this to the docs: https://vuex.feathersjs.com/common-patterns.html#clearing-data-upon-user-logout
Most helpful comment
I will post news when there is some.
On Sat, Jul 7, 2018 at 5:45 PM Ricardo Polo notifications@github.com
wrote: