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;
|
const team = this.team;
|
||||||
if (team) {
|
if (team) {
|
||||||
const sessions = Cookie.getJSON('sessions') || {};
|
const sessions = Cookie.getJSON('sessions') || {};
|
||||||
delete sessions[team.subdomain || 'root'];
|
delete sessions[team.id];
|
||||||
|
|
||||||
Cookie.set('sessions', sessions, {
|
Cookie.set('sessions', sessions, {
|
||||||
domain: stripSubdomain(window.location.hostname),
|
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 existing = JSON.parse(ctx.cookies.get('sessions') || '{}');
|
||||||
const sessions = JSON.stringify({
|
const sessions = JSON.stringify({
|
||||||
...existing,
|
...existing,
|
||||||
[team.subdomain]: {
|
[team.id]: {
|
||||||
name: team.name,
|
name: team.name,
|
||||||
logoUrl: team.logoUrl,
|
logoUrl: team.logoUrl,
|
||||||
url: team.url,
|
url: team.url,
|
||||||
expires,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
ctx.cookies.set('sessions', sessions, {
|
ctx.cookies.set('sessions', sessions, {
|
||||||
|
@ -3,7 +3,11 @@ import uuid from 'uuid';
|
|||||||
import { URL } from 'url';
|
import { URL } from 'url';
|
||||||
import { DataTypes, sequelize, Op } from '../sequelize';
|
import { DataTypes, sequelize, Op } from '../sequelize';
|
||||||
import { publicS3Endpoint, uploadToS3FromUrl } from '../utils/s3';
|
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 Collection from './Collection';
|
||||||
import User from './User';
|
import User from './User';
|
||||||
|
|
||||||
@ -50,7 +54,7 @@ const Team = sequelize.define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const url = new URL(process.env.URL);
|
const url = new URL(process.env.URL);
|
||||||
url.host = `${this.subdomain}.${url.host}`;
|
url.host = `${this.subdomain}.${stripSubdomain(url.host)}`;
|
||||||
return url.href.replace(/\/$/, '');
|
return url.href.replace(/\/$/, '');
|
||||||
},
|
},
|
||||||
logoUrl() {
|
logoUrl() {
|
||||||
|
Reference in New Issue
Block a user