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.team = data.team;
this.token = Cookie.get('accessToken');
console.log('token', this.token);
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);
console.log(`redirecting: ${team.url}/dashboard`);
ctx.redirect(`${team.url}/dashboard`);
});

View File

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

View File

@ -45,13 +45,15 @@ const Team = sequelize.define(
{
getterMethods: {
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);
url.host = `${this.subdomain}.${url.host}`;
return url.href.replace(/\/$/, '');
},
logo() {
logoUrl() {
return (
this.avatarUrl || (this.slackData ? this.slackData.image_88 : null)
);

View File

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

View File

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

View File

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