diff --git a/app/stores/AuthStore.js b/app/stores/AuthStore.js index bafe11b8..418bad75 100644 --- a/app/stores/AuthStore.js +++ b/app/stores/AuthStore.js @@ -109,7 +109,7 @@ class AuthStore { const team = this.team; if (team) { const sessions = Cookie.getJSON('sessions') || {}; - delete sessions[team.subdomain || 'root']; + delete sessions[team.id]; Cookie.set('sessions', sessions, { domain: stripSubdomain(window.location.hostname), diff --git a/server/middlewares/authentication.js b/server/middlewares/authentication.js index eeea0971..c95450a1 100644 --- a/server/middlewares/authentication.js +++ b/server/middlewares/authentication.js @@ -115,11 +115,10 @@ export default function auth(options?: { required?: boolean } = {}) { const existing = JSON.parse(ctx.cookies.get('sessions') || '{}'); const sessions = JSON.stringify({ ...existing, - [team.subdomain]: { + [team.id]: { name: team.name, logoUrl: team.logoUrl, url: team.url, - expires, }, }); ctx.cookies.set('sessions', sessions, { diff --git a/server/models/Team.js b/server/models/Team.js index 5d1edba5..fdecf2f3 100644 --- a/server/models/Team.js +++ b/server/models/Team.js @@ -3,7 +3,11 @@ import uuid from 'uuid'; import { URL } from 'url'; import { DataTypes, sequelize, Op } from '../sequelize'; import { publicS3Endpoint, uploadToS3FromUrl } from '../utils/s3'; -import { RESERVED_SUBDOMAINS } from '../../shared/utils/domains'; +import { + stripSubdomain, + RESERVED_SUBDOMAINS, +} from '../../shared/utils/domains'; + import Collection from './Collection'; import User from './User'; @@ -50,7 +54,7 @@ const Team = sequelize.define( } const url = new URL(process.env.URL); - url.host = `${this.subdomain}.${url.host}`; + url.host = `${this.subdomain}.${stripSubdomain(url.host)}`; return url.href.replace(/\/$/, ''); }, logoUrl() {