Fix: invalidates session if user cookie is absent (#2046)

This commit is contained in:
Nithin David Thomas 2021-04-02 15:31:22 +05:30 committed by GitHub
parent 1b99ab3098
commit 1d3b1c1ae5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -61,7 +61,9 @@ export default {
},
isLoggedIn() {
return !!Cookies.getJSON('auth_data');
const hasAuthCookie = !!Cookies.getJSON('auth_data');
const hasUserCookie = !!Cookies.getJSON('user');
return hasAuthCookie && hasUserCookie;
},
isAdmin() {
@ -79,7 +81,9 @@ export default {
},
getPubSubToken() {
if (this.isLoggedIn()) {
return Cookies.getJSON('user').pubsub_token;
const user = Cookies.getJSON('user') || {};
const { pubsub_token: pubsubToken } = user;
return pubsubToken;
}
return null;
},