This commit is contained in:
Tom Moor
2018-11-11 21:17:03 -08:00
parent c81135c09e
commit 61138ff4fa
7 changed files with 9 additions and 12 deletions

View File

@ -132,7 +132,6 @@ class AuthStore {
this.user = data.user; this.user = data.user;
this.team = data.team; this.team = data.team;
this.token = Cookie.get('accessToken'); this.token = Cookie.get('accessToken');
console.log('token', this.token);
if (this.token) setImmediate(() => this.fetch()); if (this.token) setImmediate(() => this.fetch());

View File

@ -32,8 +32,6 @@ router.get('/redirect', auth(), async ctx => {
}); });
const team = await Team.findById(user.teamId); const team = await Team.findById(user.teamId);
console.log(`redirecting: ${team.url}/dashboard`);
ctx.redirect(`${team.url}/dashboard`); ctx.redirect(`${team.url}/dashboard`);
}); });

View File

@ -117,7 +117,7 @@ export default function auth(options?: { required?: boolean } = {}) {
...existing, ...existing,
[team.subdomain]: { [team.subdomain]: {
name: team.name, name: team.name,
logo: team.logo, logoUrl: team.logoUrl,
url: team.url, url: team.url,
expires, expires,
}, },
@ -133,14 +133,13 @@ export default function auth(options?: { required?: boolean } = {}) {
expires: addMinutes(new Date(), 1), expires: addMinutes(new Date(), 1),
domain, domain,
}); });
console.log(`redirecting: ${team.url}/auth/redirect`);
ctx.redirect(`${team.url}/auth/redirect`); ctx.redirect(`${team.url}/auth/redirect`);
} else { } else {
ctx.cookies.set('accessToken', user.getJwtToken(), { ctx.cookies.set('accessToken', user.getJwtToken(), {
httpOnly: false, httpOnly: false,
expires, expires,
}); });
ctx.redirect(team.url); ctx.redirect(`${team.url}/dashboard`);
} }
}; };

View File

@ -45,13 +45,15 @@ const Team = sequelize.define(
{ {
getterMethods: { getterMethods: {
url() { url() {
if (!this.subdomain) return process.env.URL; if (!this.subdomain || !process.env.SUBDOMAINS_ENABLED) {
return process.env.URL;
}
const url = new URL(process.env.URL); const url = new URL(process.env.URL);
url.host = `${this.subdomain}.${url.host}`; url.host = `${this.subdomain}.${url.host}`;
return url.href.replace(/\/$/, ''); return url.href.replace(/\/$/, '');
}, },
logo() { logoUrl() {
return ( return (
this.avatarUrl || (this.slackData ? this.slackData.image_88 : null) this.avatarUrl || (this.slackData ? this.slackData.image_88 : null)
); );

View File

@ -19,7 +19,7 @@ import {
type Sessions = { type Sessions = {
[subdomain: string]: { [subdomain: string]: {
name: string, name: string,
logo: string, logoUrl: string,
expires: string, expires: string,
url: string, url: string,
}, },
@ -54,7 +54,7 @@ function TopNavigation({ sessions }: { sessions: ?Sessions }) {
{orderedSessions.map(session => ( {orderedSessions.map(session => (
<MenuItem key={session.url}> <MenuItem key={session.url}>
<a href={`${session.url}/dashboard`}> <a href={`${session.url}/dashboard`}>
<TeamLogo src={session.logo} width={20} height={20} /> <TeamLogo src={session.logoUrl} width={20} height={20} />
{session.name} {session.name}
</a> </a>
</MenuItem> </MenuItem>

View File

@ -7,7 +7,7 @@ function present(ctx: Object, team: Team) {
return { return {
id: team.id, id: team.id,
name: team.name, name: team.name,
avatarUrl: team.logo, avatarUrl: team.logoUrl,
slackConnected: !!team.slackId, slackConnected: !!team.slackId,
googleConnected: !!team.googleId, googleConnected: !!team.googleId,
sharing: team.sharing, sharing: team.sharing,

View File

@ -70,7 +70,6 @@ router.get('/', async ctx => {
const subdomain = domain ? domain.subdomain : undefined; const subdomain = domain ? domain.subdomain : undefined;
const accessToken = ctx.cookies.get('accessToken'); const accessToken = ctx.cookies.get('accessToken');
console.log('accessToken', accessToken);
ctx.set('Cache-Control', 'no-cache'); ctx.set('Cache-Control', 'no-cache');
if (accessToken) { if (accessToken) {