Renames, clear token, show signin options based on env
This commit is contained in:
@ -29,7 +29,6 @@ class AuthStore {
|
|||||||
return JSON.stringify({
|
return JSON.stringify({
|
||||||
user: this.user,
|
user: this.user,
|
||||||
team: this.team,
|
team: this.team,
|
||||||
token: this.token,
|
|
||||||
oauthState: this.oauthState,
|
oauthState: this.oauthState,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -57,7 +56,7 @@ class AuthStore {
|
|||||||
this.user = null;
|
this.user = null;
|
||||||
this.token = null;
|
this.token = null;
|
||||||
|
|
||||||
Cookie.remove('loggedIn', { path: '/' });
|
Cookie.remove('accessToken', { path: '/' });
|
||||||
await localForage.clear();
|
await localForage.clear();
|
||||||
window.location.href = BASE_URL;
|
window.location.href = BASE_URL;
|
||||||
};
|
};
|
||||||
@ -106,7 +105,6 @@ class AuthStore {
|
|||||||
);
|
);
|
||||||
this.user = res.data.user;
|
this.user = res.data.user;
|
||||||
this.team = res.data.team;
|
this.team = res.data.team;
|
||||||
this.token = res.data.accessToken;
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
@ -123,10 +121,8 @@ class AuthStore {
|
|||||||
}
|
}
|
||||||
this.user = data.user;
|
this.user = data.user;
|
||||||
this.team = data.team;
|
this.team = data.team;
|
||||||
this.token = Cookie.get('accessToken') || data.token;
|
|
||||||
console.log('TOKEN', this.token);
|
|
||||||
|
|
||||||
this.oauthState = data.oauthState;
|
this.oauthState = data.oauthState;
|
||||||
|
this.token = Cookie.get('accessToken') || data.token;
|
||||||
|
|
||||||
autorun(() => {
|
autorun(() => {
|
||||||
try {
|
try {
|
||||||
|
@ -66,7 +66,7 @@ router.get('google.callback', async ctx => {
|
|||||||
await team.createFirstCollection(user.id);
|
await team.createFirstCollection(user.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.cookies.set('lastLoggedIn', 'google', {
|
ctx.cookies.set('lastSignedIn', 'google', {
|
||||||
httpOnly: false,
|
httpOnly: false,
|
||||||
expires: new Date('2100'),
|
expires: new Date('2100'),
|
||||||
});
|
});
|
||||||
|
@ -5,15 +5,17 @@ import styled from 'styled-components';
|
|||||||
import Grid from 'styled-components-grid';
|
import Grid from 'styled-components-grid';
|
||||||
import breakpoint from 'styled-components-breakpoint';
|
import breakpoint from 'styled-components-breakpoint';
|
||||||
import Hero from './components/Hero';
|
import Hero from './components/Hero';
|
||||||
import SignupButton from './components/SignupButton';
|
import SigninButtons from './components/SigninButtons';
|
||||||
import { developers, githubUrl } from '../../shared/utils/routeHelpers';
|
import { developers, githubUrl } from '../../shared/utils/routeHelpers';
|
||||||
import { color } from '../../shared/styles/constants';
|
import { color } from '../../shared/styles/constants';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
lastLoggedIn: string,
|
lastSignedIn: string,
|
||||||
|
googleSigninEnabled: boolean,
|
||||||
|
slackSigninEnabled: boolean,
|
||||||
};
|
};
|
||||||
|
|
||||||
function Home({ lastLoggedIn }: Props) {
|
function Home(props: Props) {
|
||||||
return (
|
return (
|
||||||
<span>
|
<span>
|
||||||
<Helmet>
|
<Helmet>
|
||||||
@ -27,7 +29,7 @@ function Home({ lastLoggedIn }: Props) {
|
|||||||
logs, brainstorming, & more…
|
logs, brainstorming, & more…
|
||||||
</HeroText>
|
</HeroText>
|
||||||
<p>
|
<p>
|
||||||
<SignupButton lastLoggedIn={lastLoggedIn} />
|
<SigninButtons {...props} />
|
||||||
</p>
|
</p>
|
||||||
</Hero>
|
</Hero>
|
||||||
<Features reverse={{ mobile: true, tablet: false, desktop: false }}>
|
<Features reverse={{ mobile: true, tablet: false, desktop: false }}>
|
||||||
@ -94,10 +96,10 @@ function Home({ lastLoggedIn }: Props) {
|
|||||||
<Footer>
|
<Footer>
|
||||||
<h2>Create an account</h2>
|
<h2>Create an account</h2>
|
||||||
<p>
|
<p>
|
||||||
On the same page as us? Create a beta account to give Outline a try.
|
On the same page as us? Create a free account to give Outline a try.
|
||||||
</p>
|
</p>
|
||||||
<FooterCTA>
|
<FooterCTA>
|
||||||
<SignupButton />
|
<SigninButtons {...props} />
|
||||||
</FooterCTA>
|
</FooterCTA>
|
||||||
</Footer>
|
</Footer>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
72
server/pages/components/SigninButtons.js
Normal file
72
server/pages/components/SigninButtons.js
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
// @flow
|
||||||
|
import * as React from 'react';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
import { signin } from '../../../shared/utils/routeHelpers';
|
||||||
|
import Flex from '../../../shared/components/Flex';
|
||||||
|
import GoogleLogo from '../../../shared/components/GoogleLogo';
|
||||||
|
import SlackLogo from '../../../shared/components/SlackLogo';
|
||||||
|
import { color } from '../../../shared/styles/constants';
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
lastSignedIn: string,
|
||||||
|
googleSigninEnabled: boolean,
|
||||||
|
slackSigninEnabled: boolean,
|
||||||
|
};
|
||||||
|
|
||||||
|
const SigninButtons = ({
|
||||||
|
lastSignedIn,
|
||||||
|
slackSigninEnabled,
|
||||||
|
googleSigninEnabled,
|
||||||
|
}: Props) => {
|
||||||
|
return (
|
||||||
|
<Flex justify="center">
|
||||||
|
{slackSigninEnabled && (
|
||||||
|
<Flex column>
|
||||||
|
<Button href={signin('slack')}>
|
||||||
|
<SlackLogo />
|
||||||
|
<Spacer>Sign In with Slack</Spacer>
|
||||||
|
</Button>
|
||||||
|
<LastLogin>
|
||||||
|
{lastSignedIn === 'slack' && 'You signed in with Slack previously'}
|
||||||
|
</LastLogin>
|
||||||
|
</Flex>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{googleSigninEnabled && (
|
||||||
|
<Flex column>
|
||||||
|
<Button href={signin('google')}>
|
||||||
|
<GoogleLogo />
|
||||||
|
<Spacer>Sign In with Google</Spacer>
|
||||||
|
</Button>
|
||||||
|
<LastLogin>
|
||||||
|
{lastSignedIn === 'google' &&
|
||||||
|
'You signed in with Google previously'}
|
||||||
|
</LastLogin>
|
||||||
|
</Flex>
|
||||||
|
)}
|
||||||
|
</Flex>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const Spacer = styled.span`
|
||||||
|
padding-left: 10px;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const Button = styled.a`
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
padding: 10px 20px;
|
||||||
|
color: ${color.white};
|
||||||
|
background: ${color.black};
|
||||||
|
border-radius: 4px;
|
||||||
|
font-weight: 600;
|
||||||
|
height: 56px;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const LastLogin = styled.p`
|
||||||
|
font-size: 12px;
|
||||||
|
color: ${color.slate};
|
||||||
|
padding-top: 4px;
|
||||||
|
`;
|
||||||
|
|
||||||
|
export default SigninButtons;
|
@ -1,61 +0,0 @@
|
|||||||
// @flow
|
|
||||||
import * as React from 'react';
|
|
||||||
import styled from 'styled-components';
|
|
||||||
import { signin } from '../../../shared/utils/routeHelpers';
|
|
||||||
import Flex from '../../../shared/components/Flex';
|
|
||||||
import GoogleLogo from '../../../shared/components/GoogleLogo';
|
|
||||||
import SlackLogo from '../../../shared/components/SlackLogo';
|
|
||||||
import { color } from '../../../shared/styles/constants';
|
|
||||||
|
|
||||||
type Props = {
|
|
||||||
lastLoggedIn: string,
|
|
||||||
};
|
|
||||||
|
|
||||||
const SignupButton = ({ lastLoggedIn }: Props) => {
|
|
||||||
return (
|
|
||||||
<Flex justify="center">
|
|
||||||
<Flex column>
|
|
||||||
<Button href={signin('slack')}>
|
|
||||||
<SlackLogo />
|
|
||||||
<Spacer>Sign In with Slack</Spacer>
|
|
||||||
</Button>
|
|
||||||
<LastLogin>
|
|
||||||
{lastLoggedIn === 'slack' && 'You signed in with Slack previously'}
|
|
||||||
</LastLogin>
|
|
||||||
</Flex>
|
|
||||||
|
|
||||||
<Flex column>
|
|
||||||
<Button href={signin('google')}>
|
|
||||||
<GoogleLogo />
|
|
||||||
<Spacer>Sign In with Google</Spacer>
|
|
||||||
</Button>
|
|
||||||
<LastLogin>
|
|
||||||
{lastLoggedIn === 'google' && 'You signed in with Google previously'}
|
|
||||||
</LastLogin>
|
|
||||||
</Flex>
|
|
||||||
</Flex>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const Spacer = styled.span`
|
|
||||||
padding-left: 10px;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const Button = styled.a`
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: center;
|
|
||||||
padding: 10px 20px;
|
|
||||||
color: ${color.white};
|
|
||||||
background: ${color.black};
|
|
||||||
border-radius: 4px;
|
|
||||||
font-weight: 600;
|
|
||||||
height: 56px;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const LastLogin = styled.p`
|
|
||||||
font-size: 12px;
|
|
||||||
color: ${color.slate};
|
|
||||||
padding-top: 4px;
|
|
||||||
`;
|
|
||||||
|
|
||||||
export default SignupButton;
|
|
@ -62,14 +62,20 @@ router.get('/changelog', async ctx => {
|
|||||||
|
|
||||||
// home page
|
// home page
|
||||||
router.get('/', async ctx => {
|
router.get('/', async ctx => {
|
||||||
const lastLoggedIn = ctx.cookies.get('lastLoggedIn');
|
const lastSignedIn = ctx.cookies.get('lastSignedIn');
|
||||||
const accessToken = ctx.cookies.get('accessToken');
|
const accessToken = ctx.cookies.get('accessToken');
|
||||||
console.log(lastLoggedIn, accessToken);
|
|
||||||
|
|
||||||
if (accessToken) {
|
if (accessToken) {
|
||||||
await renderapp(ctx);
|
await renderapp(ctx);
|
||||||
} else {
|
} else {
|
||||||
await renderpage(ctx, <Home lastLoggedIn={lastLoggedIn} />);
|
await renderpage(
|
||||||
|
ctx,
|
||||||
|
<Home
|
||||||
|
lastSignedIn={lastSignedIn}
|
||||||
|
googleSigninEnabled={!!process.env.GOOGLE_CLIENT_ID}
|
||||||
|
slackSigninEnabled={!!process.env.SLACK_KEY}
|
||||||
|
/>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user