Fixes: handling of www subdomain in production
Hanging sessions when subdomain changes
This commit is contained in:
@ -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),
|
||||
|
@ -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, {
|
||||
|
@ -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() {
|
||||
|
Reference in New Issue
Block a user