Iterate, iterate

This commit is contained in:
Tom Moor
2018-11-11 14:23:31 -08:00
parent e24a187699
commit 10e1f0231c
3 changed files with 78 additions and 34 deletions

View File

@@ -102,12 +102,14 @@ class AuthStore {
this.user = null;
this.token = null;
// remove deprecated authentication if it exists
// remove authentication token itself
Cookie.remove('accessToken', { path: '/' });
if (this.team) {
// remove session record on apex cookie
const team = this.team;
if (team) {
const sessions = Cookie.getJSON('sessions') || {};
delete sessions[this.team.subdomain || 'root'];
delete sessions[team.subdomain || 'root'];
Cookie.set('sessions', sessions, {
domain: stripSubdomain(window.location.hostname),
@@ -129,16 +131,8 @@ class AuthStore {
}
this.user = data.user;
this.team = data.team;
const sessions = Cookie.getJSON('sessions') || {};
const subdomain = window.location.hostname.split('.')[0];
console.log({ sessions });
const accessToken = sessions[subdomain || 'root']
? sessions[subdomain || 'root'].accessToken
: Cookie.get('accessToken');
console.log({ accessToken });
this.token = accessToken;
this.token = Cookie.get('accessToken');
console.log('token', this.token);
if (this.token) setImmediate(() => this.fetch());