diff --git a/app/stores/AuthStore.js b/app/stores/AuthStore.js index 2468787a..468ab148 100644 --- a/app/stores/AuthStore.js +++ b/app/stores/AuthStore.js @@ -29,7 +29,6 @@ class AuthStore { return JSON.stringify({ user: this.user, team: this.team, - token: this.token, oauthState: this.oauthState, }); } @@ -57,7 +56,7 @@ class AuthStore { this.user = null; this.token = null; - Cookie.remove('loggedIn', { path: '/' }); + Cookie.remove('accessToken', { path: '/' }); await localForage.clear(); window.location.href = BASE_URL; }; @@ -106,7 +105,6 @@ class AuthStore { ); this.user = res.data.user; this.team = res.data.team; - this.token = res.data.accessToken; return { success: true, @@ -123,10 +121,8 @@ class AuthStore { } this.user = data.user; this.team = data.team; - this.token = Cookie.get('accessToken') || data.token; - console.log('TOKEN', this.token); - this.oauthState = data.oauthState; + this.token = Cookie.get('accessToken') || data.token; autorun(() => { try { diff --git a/server/auth/google.js b/server/auth/google.js index 1f1c5f7e..40c6479b 100644 --- a/server/auth/google.js +++ b/server/auth/google.js @@ -66,7 +66,7 @@ router.get('google.callback', async ctx => { await team.createFirstCollection(user.id); } - ctx.cookies.set('lastLoggedIn', 'google', { + ctx.cookies.set('lastSignedIn', 'google', { httpOnly: false, expires: new Date('2100'), }); diff --git a/server/pages/Home.js b/server/pages/Home.js index 945a2c95..a77f1719 100644 --- a/server/pages/Home.js +++ b/server/pages/Home.js @@ -5,15 +5,17 @@ import styled from 'styled-components'; import Grid from 'styled-components-grid'; import breakpoint from 'styled-components-breakpoint'; import Hero from './components/Hero'; -import SignupButton from './components/SignupButton'; +import SigninButtons from './components/SigninButtons'; import { developers, githubUrl } from '../../shared/utils/routeHelpers'; import { color } from '../../shared/styles/constants'; type Props = { - lastLoggedIn: string, + lastSignedIn: string, + googleSigninEnabled: boolean, + slackSigninEnabled: boolean, }; -function Home({ lastLoggedIn }: Props) { +function Home(props: Props) { return ( @@ -27,7 +29,7 @@ function Home({ lastLoggedIn }: Props) { logs, brainstorming, & more…

- +

@@ -94,10 +96,10 @@ function Home({ lastLoggedIn }: Props) {

Create an account

- 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.

- +
diff --git a/server/pages/components/SigninButtons.js b/server/pages/components/SigninButtons.js new file mode 100644 index 00000000..acd84f0d --- /dev/null +++ b/server/pages/components/SigninButtons.js @@ -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 ( + + {slackSigninEnabled && ( + + + + {lastSignedIn === 'slack' && 'You signed in with Slack previously'} + + + )} +   + {googleSigninEnabled && ( + + + + {lastSignedIn === 'google' && + 'You signed in with Google previously'} + + + )} + + ); +}; + +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; diff --git a/server/pages/components/SignupButton.js b/server/pages/components/SignupButton.js deleted file mode 100644 index 3c06a0e8..00000000 --- a/server/pages/components/SignupButton.js +++ /dev/null @@ -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 ( - - - - - {lastLoggedIn === 'slack' && 'You signed in with Slack previously'} - - -   - - - - {lastLoggedIn === 'google' && 'You signed in with Google previously'} - - - - ); -}; - -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; diff --git a/server/routes.js b/server/routes.js index 1c05f47b..58320988 100644 --- a/server/routes.js +++ b/server/routes.js @@ -62,14 +62,20 @@ router.get('/changelog', async ctx => { // home page router.get('/', async ctx => { - const lastLoggedIn = ctx.cookies.get('lastLoggedIn'); + const lastSignedIn = ctx.cookies.get('lastSignedIn'); const accessToken = ctx.cookies.get('accessToken'); - console.log(lastLoggedIn, accessToken); if (accessToken) { await renderapp(ctx); } else { - await renderpage(ctx, ); + await renderpage( + ctx, + + ); } });