From 3451b1d948e7f88c1738ec6eda79be20a7152e84 Mon Sep 17 00:00:00 2001 From: Max Stoiber Date: Fri, 7 Jun 2019 14:05:17 +0200 Subject: [PATCH 1/7] Add documentation on hourly backups --- docs/operations/hourly-backups.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 docs/operations/hourly-backups.md diff --git a/docs/operations/hourly-backups.md b/docs/operations/hourly-backups.md new file mode 100644 index 0000000000..b700b2ad7c --- /dev/null +++ b/docs/operations/hourly-backups.md @@ -0,0 +1,10 @@ +# Hourly Off-site Backups + +In order to avoid more data loss we implemented hourly off-site backups in [#5150](https://github.com/withspectrum/spectrum/pull/5150). While the implementation is simple, it should cover us well enough. + +It works by running two cron jobs: + +1. Runs at 30 minutes past every hour and triggers an "on-demand backup" with our database host (Compose) +2. Runs at 0 minutes past every hour, fetches the latest "on-demand backup" from our database host and uploads it to our S3 bucket + +To access the latest hourly backup you can either go to the Compose dashboard (app.compose.com), navigate to the RethinkDB deployment and download the newest on-demand backup, or open our S3 bucket and download the latest one from there. From 985d37e8b919ca617aaa3667569bd7eb980ff54d Mon Sep 17 00:00:00 2001 From: Brian Lovin Date: Thu, 20 Jun 2019 13:03:13 -0400 Subject: [PATCH 2/7] Restrict sign ups to GitHub, work on UX --- api/authentication.js | 15 ++-- api/routes/auth/create-signin-routes.js | 4 +- shared/analytics/event-types/page-home.js | 1 + shared/db/queries/user.js | 6 +- src/components/fullscreenView/style.js | 2 +- src/components/loginButtonSet/facebook.js | 2 +- src/components/loginButtonSet/github.js | 10 ++- src/components/loginButtonSet/google.js | 2 +- src/components/loginButtonSet/index.js | 86 +++++++++++++++-------- src/components/loginButtonSet/style.js | 1 + src/components/loginButtonSet/twitter.js | 2 +- src/views/login/index.js | 36 ++++++---- src/views/newUserOnboarding/index.js | 4 +- src/views/pages/components/nav.js | 68 ++++++++++++------ src/views/pages/style.js | 18 ++++- 15 files changed, 170 insertions(+), 87 deletions(-) diff --git a/api/authentication.js b/api/authentication.js index c8111fa43c..3ad2e2770d 100644 --- a/api/authentication.js +++ b/api/authentication.js @@ -139,8 +139,9 @@ const init = () => { return user; }) .catch(err => { - done(err); - return null; + return done(null, err, { + message: 'Please sign in with GitHub to create a new account.', + }); }); } ) @@ -204,8 +205,9 @@ const init = () => { return user; }) .catch(err => { - done(err); - return null; + return done(null, err, { + message: 'Please sign in with GitHub to create a new account.', + }); }); } ) @@ -268,8 +270,9 @@ const init = () => { return user; }) .catch(err => { - done(err); - return null; + return done(null, err, { + message: 'Please sign in with GitHub to create a new account.', + }); }); } ) diff --git a/api/routes/auth/create-signin-routes.js b/api/routes/auth/create-signin-routes.js index e9cc1ad0a3..4048fbd41c 100644 --- a/api/routes/auth/create-signin-routes.js +++ b/api/routes/auth/create-signin-routes.js @@ -41,7 +41,9 @@ export const createSigninRoutes = ( // redirecting to the right place and handling tokens callbacks: [ passport.authenticate(strategy, { - failureRedirect: IS_PROD ? '/' : 'http://localhost:3000/', + failureRedirect: IS_PROD + ? '/new/user' + : 'http://localhost:3000/new/user', }), (req: express$Request, res: express$Response) => { // $FlowIssue diff --git a/shared/analytics/event-types/page-home.js b/shared/analytics/event-types/page-home.js index e578d11725..e12732c0f1 100644 --- a/shared/analytics/event-types/page-home.js +++ b/shared/analytics/event-types/page-home.js @@ -4,5 +4,6 @@ export const HOME_PAGE_VIEWED = 'Home Page Viewed'; export const HOME_PAGE_JOIN_SPECTRUM_CLICKED = 'Home Page Join Spectrum Clicked'; export const HOME_PAGE_CREATE_COMMUNITY_CLICKED = 'Home Page Create Community Clicked'; export const HOME_PAGE_SIGN_IN_CLICKED = 'Home Page Sign In Clicked'; +export const HOME_PAGE_LOG_IN_CLICKED = 'Home Page Log In Clicked'; export const HOME_PAGE_EXPLORE_CLICKED = 'Home Page Explore Clicked'; export const HOME_PAGE_EXAMPLE_CONVERSATION_CLICKED = 'Home Page Example Conversation Clicked'; \ No newline at end of file diff --git a/shared/db/queries/user.js b/shared/db/queries/user.js index a2a6b34d3b..ff4003a662 100644 --- a/shared/db/queries/user.js +++ b/shared/db/queries/user.js @@ -224,7 +224,9 @@ export const createOrFindUser = (user: Object, providerMethod: string): Promise< if (storedUser && storedUser.id) { return Promise.resolve(storedUser); } - + + // restrict new signups to github auth only + if (providerMethod !== 'githubProviderId') return Promise.resolve(null) // if no user exists, create a new one with the oauth profile data return storeUser(user); }) @@ -233,6 +235,8 @@ export const createOrFindUser = (user: Object, providerMethod: string): Promise< console.error(err); return null; } + + if (providerMethod !== 'githubProviderId') return null return storeUser(user); }); }; diff --git a/src/components/fullscreenView/style.js b/src/components/fullscreenView/style.js index 0d0f6c037c..e1c8a80f9a 100644 --- a/src/components/fullscreenView/style.js +++ b/src/components/fullscreenView/style.js @@ -18,7 +18,7 @@ export const FullscreenViewContainer = styled.div` justify-content: flex-start; flex-direction: column; z-index: ${zIndex.fullscreen}; - overflow-y: scroll; + overflow-y: auto; -webkit-transform: translate3d(0, 0, 0); `; diff --git a/src/components/loginButtonSet/facebook.js b/src/components/loginButtonSet/facebook.js index 5d25f655c6..90b21b6419 100644 --- a/src/components/loginButtonSet/facebook.js +++ b/src/components/loginButtonSet/facebook.js @@ -11,7 +11,7 @@ export const FacebookSigninButton = (props: ButtonProps) => { onClickHandler && onClickHandler('facebook')} href={href}> - + ); diff --git a/src/components/loginButtonSet/github.js b/src/components/loginButtonSet/github.js index 8af2534cb1..7830dc92e6 100644 --- a/src/components/loginButtonSet/github.js +++ b/src/components/loginButtonSet/github.js @@ -5,13 +5,17 @@ import { GithubButton, Label, A } from './style'; import Icon from 'src/components/icon'; export const GithubSigninButton = (props: ButtonProps) => { - const { href, preferred, showAfter, onClickHandler } = props; + const { href, preferred, showAfter, onClickHandler, githubOnly } = props; return ( - onClickHandler && onClickHandler('github')} href={href}> + onClickHandler && onClickHandler('github')} + href={href} + > - + ); diff --git a/src/components/loginButtonSet/google.js b/src/components/loginButtonSet/google.js index e9006f85e0..284340afec 100644 --- a/src/components/loginButtonSet/google.js +++ b/src/components/loginButtonSet/google.js @@ -11,7 +11,7 @@ export const GoogleSigninButton = (props: ButtonProps) => { onClickHandler && onClickHandler('google')} href={href}> - + ); diff --git a/src/components/loginButtonSet/index.js b/src/components/loginButtonSet/index.js index d2328bf160..38d5b11aaf 100644 --- a/src/components/loginButtonSet/index.js +++ b/src/components/loginButtonSet/index.js @@ -1,6 +1,7 @@ // @flow import * as React from 'react'; import { getItemFromStorage, storeItem } from 'src/helpers/localStorage'; +import { TextButton } from 'src/components/button'; import { withRouter } from 'react-router'; import queryString from 'query-string'; import { SERVER_URL, CLIENT_URL } from '../../api/constants'; @@ -21,6 +22,7 @@ export type ButtonProps = { href: string, preferred: boolean, showAfter: boolean, + githubOnly?: boolean, }; class LoginButtonSet extends React.Component { @@ -30,7 +32,7 @@ class LoginButtonSet extends React.Component { }; render() { - const { redirectPath, location } = this.props; + const { redirectPath, location, githubOnly } = this.props; let r; if (location) { @@ -52,37 +54,63 @@ class LoginButtonSet extends React.Component { } return ( - - + + + {!githubOnly && ( + + - + - + + + )} - - + + + + {!githubOnly && ( + +
+ + New to Spectrum? Click here to sign up. + + + )} + ); } } diff --git a/src/components/loginButtonSet/style.js b/src/components/loginButtonSet/style.js index 548d1358ea..2e425b5626 100644 --- a/src/components/loginButtonSet/style.js +++ b/src/components/loginButtonSet/style.js @@ -16,6 +16,7 @@ export const Container = styled.div` export const A = styled.a` display: flex; + grid-column: ${props => (props.githubOnly ? '1 / 3' : 'auto')}; `; export const SigninButton = styled.div` diff --git a/src/components/loginButtonSet/twitter.js b/src/components/loginButtonSet/twitter.js index c05f2563e1..5d4ac8b246 100644 --- a/src/components/loginButtonSet/twitter.js +++ b/src/components/loginButtonSet/twitter.js @@ -11,7 +11,7 @@ export const TwitterSigninButton = (props: ButtonProps) => { onClickHandler && onClickHandler('twitter')} href={href}> - + ); diff --git a/src/views/login/index.js b/src/views/login/index.js index ba5a6c90b8..24b6cba6ca 100644 --- a/src/views/login/index.js +++ b/src/views/login/index.js @@ -5,6 +5,7 @@ import { connect } from 'react-redux'; import compose from 'recompose/compose'; import { Link } from 'react-router-dom'; import Icon from 'src/components/icon'; +import { TextButton } from 'src/components/button'; import FullscreenView from 'src/components/fullscreenView'; import LoginButtonSet from 'src/components/loginButtonSet'; import { @@ -25,6 +26,7 @@ type Props = { close?: Function, location?: Object, dispatch: Function, + githubOnly?: boolean, }; class Login extends React.Component { @@ -42,15 +44,7 @@ class Login extends React.Component { } render() { - const { redirectPath, signinType = 'signin' } = this.props; - - const viewTitle = - signinType === 'login' ? 'Welcome back!' : 'Sign in to get started'; - - const viewSubtitle = - signinType === 'login' - ? "We're happy to see you again - sign in below to get back into the conversation!" - : 'Spectrum is a place where communities can share, discuss, and grow together. Sign in below to get in on the conversation.'; + const { redirectPath, signinType = 'signin', githubOnly } = this.props; return ( @@ -58,13 +52,25 @@ class Login extends React.Component { data-cy="login-page" style={{ justifyContent: 'center' }} > - - - - {viewTitle} - {viewSubtitle} + {githubOnly ? 'Sign up' : 'Log in'} + {githubOnly && ( + + New accounts on Spectrum can only be created by signing up with + GitHub. + + )} + + - + {githubOnly && ( + + Existing user? Click here to log in + + )} By using Spectrum, you agree to our{' '} diff --git a/src/views/newUserOnboarding/index.js b/src/views/newUserOnboarding/index.js index d276e1b169..3ddde1d7b8 100644 --- a/src/views/newUserOnboarding/index.js +++ b/src/views/newUserOnboarding/index.js @@ -11,6 +11,7 @@ import type { UserInfoType } from 'shared/graphql/fragments/user/userInfo'; import { SERVER_URL } from 'src/api/constants'; import { setTitlebarProps } from 'src/actions/titlebar'; import { ViewGrid, CenteredGrid } from 'src/components/layout'; +import Login from 'src/views/login'; import { LogOutButton, Emoji, Heading, Description, Card } from './style'; type Props = { @@ -42,8 +43,7 @@ class NewUserOnboarding extends React.Component { const { currentUser, history } = this.props; if (!currentUser) { - history.replace('/'); - return null; + return ; } if (currentUser && currentUser.username) { diff --git a/src/views/pages/components/nav.js b/src/views/pages/components/nav.js index dbfd0464b3..8fd2745ee0 100644 --- a/src/views/pages/components/nav.js +++ b/src/views/pages/components/nav.js @@ -16,10 +16,12 @@ import { MenuTab, SupportTab, FeaturesTab, + LoginTab, AppsTab, AuthTab, LogoLink, AuthLink, + LoginLink, SupportLink, FeaturesLink, AppsLink, @@ -93,8 +95,8 @@ class Nav extends React.Component { > Support - - {this.props.currentUser ? ( + {this.props.currentUser ? ( + { showHoverProfile={false} /> - ) : ( - + ) : ( + + track(events.HOME_PAGE_SIGN_IN_CLICKED)} + data-cy="navigation-splash-login" > - + + track(events.HOME_PAGE_SIGN_IN_CLICKED)} > - Log in or sign up - - - )} - + + Sign up + + + + + )} { Return home ) : ( - track(events.HOME_PAGE_SIGN_IN_CLICKED)} - > - Log in or sign up - + + track(events.HOME_PAGE_LOG_IN_CLICKED)} + > + Log in + + track(events.HOME_PAGE_SIGN_IN_CLICKED)} + > + Sign up + + )} @@ -629,12 +629,16 @@ export const AuthLink = styled(DropdownLink)` } `; +export const LoginLink = styled(DropdownLink)` + grid-area: login; +`; + export const MenuContainer = styled.div` position: fixed; display: grid; grid-template-columns: auto; grid-template-rows: auto 16px repeat(5, auto) 1fr auto; - grid-template-areas: 'logo' '.' 'features' 'apps' 'support' 'explore' '.' 'auth'; + grid-template-areas: 'logo' '.' 'features' 'apps' 'support' 'explore' 'login' '.' 'auth'; align-content: start; left: 0; top: 0; @@ -713,6 +717,14 @@ export const SupportTab = styled(Tab)` } `; +export const LoginTab = styled(Tab)` + grid-area: login; + + @media (max-width: ${MEDIA_BREAK}px) { + display: none; + } +`; + export const AuthTab = styled.div` grid-area: auth; color: ${props => From b8eac51a45bda79c4a5a11033c4c841977dd4a37 Mon Sep 17 00:00:00 2001 From: Brian Lovin Date: Mon, 24 Jun 2019 12:15:31 -0400 Subject: [PATCH 3/7] Styling, fixes instance implementation of login flows, faq --- src/components/loginButtonSet/index.js | 20 ++++++++++---------- src/components/modals/LoginModal/index.js | 16 ++++++++++++++-- src/views/communityLogin/index.js | 8 +++++++- src/views/login/index.js | 8 +++----- src/views/pages/faq/index.js | 15 +++++++++++++++ 5 files changed, 49 insertions(+), 18 deletions(-) diff --git a/src/components/loginButtonSet/index.js b/src/components/loginButtonSet/index.js index 38d5b11aaf..863565e605 100644 --- a/src/components/loginButtonSet/index.js +++ b/src/components/loginButtonSet/index.js @@ -1,7 +1,7 @@ // @flow import * as React from 'react'; import { getItemFromStorage, storeItem } from 'src/helpers/localStorage'; -import { TextButton } from 'src/components/button'; +import { OutlineButton } from 'src/components/button'; import { withRouter } from 'react-router'; import queryString from 'query-string'; import { SERVER_URL, CLIENT_URL } from '../../api/constants'; @@ -100,16 +100,16 @@ class LoginButtonSet extends React.Component { } showAfter={preferredSigninMethod === 'github'} /> - - {!githubOnly && ( - -
- - New to Spectrum? Click here to sign up. - - - )} + {!githubOnly && ( +
+
+ + New to Spectrum? Click here to sign up. + +
+ )} + ); } diff --git a/src/components/modals/LoginModal/index.js b/src/components/modals/LoginModal/index.js index 7d7eca02dc..0ef9967cc8 100644 --- a/src/components/modals/LoginModal/index.js +++ b/src/components/modals/LoginModal/index.js @@ -7,6 +7,7 @@ import { Link } from 'react-router-dom'; import { closeModal } from 'src/actions/modals'; import ModalContainer from '../modalContainer'; import { modalStyles } from '../styles'; +import { OutlineButton } from 'src/components/button'; import LoginButtonSet from 'src/components/loginButtonSet'; import { Container, CodeOfConduct } from './style'; import { track, events } from 'src/helpers/analytics'; @@ -40,7 +41,7 @@ class LoginModal extends React.Component { /* TODO(@mxstbr): Fix this */ ariaHideApp={false} isOpen={isOpen} - contentLabel={'Sign in'} + contentLabel={'Sign up'} onRequestClose={this.close} shouldCloseOnOverlayClick={true} style={styles} @@ -50,13 +51,24 @@ class LoginModal extends React.Component { We pass the closeModal dispatch into the container to attach the action to the 'close' icon in the top right corner of all modals */} - + + + Existing user? Click here to log in + + +
+ By using Spectrum, you agree to our{' '} { size={88} /> - Sign in to the {community.name} community + Sign up to join the {community.name} community {brandedLogin.message && brandedLogin.message.length > 0 ? brandedLogin.message @@ -102,8 +103,13 @@ export class Login extends React.Component { redirectPath || `${CLIENT_URL}/${match.params.communitySlug}` } signinType={'signin'} + githubOnly /> + + Existing user? Click here to log in + + By using Spectrum, you agree to our{' '} { /> {githubOnly && ( - + Existing user? Click here to log in - + )} diff --git a/src/views/pages/faq/index.js b/src/views/pages/faq/index.js index d1e6ba1c0d..f493c4efe3 100644 --- a/src/views/pages/faq/index.js +++ b/src/views/pages/faq/index.js @@ -26,6 +26,21 @@ class FAQ extends React.Component<{}> { Frequently Asked Questions +
+ + Why can new accounts only be created with GitHub? + + + + Spectrum joined GitHub in November, 2018 to build the world’s best + communities for developers. In staying with this mission, we are + investing in deeper integrations with the GitHub ecosystem. For + this reason, new Spectrum accounts must be connected to a GitHub + profile. In the future this will help us associate community posts + with your code, projects, and collaborators on GitHub. + +
+
What happens when I delete my account on Spectrum? From 33afeeceedd4226f1aa1f40d036c7f4a07622c80 Mon Sep 17 00:00:00 2001 From: Brian Lovin Date: Tue, 25 Jun 2019 07:31:35 -0400 Subject: [PATCH 4/7] Fix flow --- src/components/loginButtonSet/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/loginButtonSet/index.js b/src/components/loginButtonSet/index.js index 863565e605..b3139e1363 100644 --- a/src/components/loginButtonSet/index.js +++ b/src/components/loginButtonSet/index.js @@ -15,6 +15,7 @@ import { track, events } from 'src/helpers/analytics'; type Props = { redirectPath: ?string, location: Object, + githubOnly?: boolean, }; export type ButtonProps = { From d60c80bc13faaccedf597fdf2075427ba226aaee Mon Sep 17 00:00:00 2001 From: Brian Lovin Date: Tue, 25 Jun 2019 08:05:54 -0400 Subject: [PATCH 5/7] Fix tests and redirect path persistence --- cypress/integration/login_spec.js | 76 ++++++++++++++++++- cypress/integration/navbar_spec.js | 2 +- src/components/loginButtonSet/index.js | 19 +++-- src/components/modals/LoginModal/index.js | 2 +- src/views/communityLogin/index.js | 6 +- src/views/login/index.js | 5 +- src/views/newUserOnboarding/index.js | 19 ++++- src/views/userSettings/components/editForm.js | 6 +- 8 files changed, 114 insertions(+), 21 deletions(-) diff --git a/cypress/integration/login_spec.js b/cypress/integration/login_spec.js index cc2adcd444..d4d7f23e99 100644 --- a/cypress/integration/login_spec.js +++ b/cypress/integration/login_spec.js @@ -1,27 +1,72 @@ -describe('Login View', () => { +describe('Sign up', () => { + beforeEach(() => { + cy.visit('/new/user'); + }); + + it('should only allow github signup', () => { + cy.get('[data-cy="login-page"]').should('be.visible'); + cy.get('[href*="/auth/github"]').should('be.visible'); + cy.get('[href*="/login"]').should('be.visible'); + cy.get('[href*="github.com/withspectrum/code-of-conduct"]').should( + 'be.visible' + ); + }); +}); + +describe('Log in', () => { beforeEach(() => { cy.visit('/login'); }); - it('should render', () => { + it('should render login methods', () => { cy.get('[data-cy="login-page"]').should('be.visible'); cy.get('[href*="/auth/twitter"]').should('be.visible'); cy.get('[href*="/auth/facebook"]').should('be.visible'); cy.get('[href*="/auth/google"]').should('be.visible'); cy.get('[href*="/auth/github"]').should('be.visible'); + cy.get('[href*="/new/user"]').should('be.visible'); + cy.get('[href*="github.com/withspectrum/code-of-conduct"]').should( 'be.visible' ); }); }); -describe('Community Login View', () => { +describe('Community Signup View', () => { beforeEach(() => { cy.visit('/spectrum/login'); }); it('should render', () => { cy.get('[data-cy="community-login-page"]').should('be.visible'); + cy.get('[href*="/auth/github?r=http://localhost:3000/spectrum"]').should( + 'be.visible' + ); + cy.get('[href*="github.com/withspectrum/code-of-conduct"]').should( + 'be.visible' + ); + + cy.get('[href*="/login?r=http://localhost:3000/spectrum"]').should( + 'be.visible' + ); + }); +}); + +describe('Redirect paths', () => { + it('should preserve community redirect paths', () => { + cy.visit('/spectrum/login'); + cy.get('[data-cy="community-login-page"]').should('be.visible'); + cy.get('[href*="/auth/github?r=http://localhost:3000/spectrum"]').should( + 'be.visible' + ); + cy.get('[href*="github.com/withspectrum/code-of-conduct"]').should( + 'be.visible' + ); + + cy.get('[href*="/login?r=http://localhost:3000/spectrum"]') + .should('be.visible') + .click(); + cy.get('[href*="/auth/twitter?r=http://localhost:3000/spectrum"]').should( 'be.visible' ); @@ -34,8 +79,33 @@ describe('Community Login View', () => { cy.get('[href*="/auth/github?r=http://localhost:3000/spectrum"]').should( 'be.visible' ); + cy.get('[href*="/new/user?r=http://localhost:3000/spectrum"]').should( + 'be.visible' + ); + }); + + it('should preserve thread redirect paths', () => { + const path = + 'http://localhost:3000/spectrum/general/yet-another-thread~thread-3'; + cy.visit(path); + cy.get('[data-cy="join-community-chat-upsell"]') + .should('be.visible') + .click(); + + cy.get('[data-cy="login-modal"]').should('be.visible'); + cy.get(`[href*="/auth/github?r=${path}"]`).should('be.visible'); cy.get('[href*="github.com/withspectrum/code-of-conduct"]').should( 'be.visible' ); + + cy.get(`[href*="/login?r=${path}"]`) + .should('be.visible') + .click(); + + cy.get(`[href*="/auth/twitter?r=${path}"]`).should('be.visible'); + cy.get(`[href*="/auth/facebook?r=${path}"]`).should('be.visible'); + cy.get(`[href*="/auth/google?r=${path}"]`).should('be.visible'); + cy.get(`[href*="/auth/github?r=${path}"]`).should('be.visible'); + cy.get(`[href*="/new/user?r=${path}"]`).should('be.visible'); }); }); diff --git a/cypress/integration/navbar_spec.js b/cypress/integration/navbar_spec.js index 66cfe6c430..afdc7f3f98 100644 --- a/cypress/integration/navbar_spec.js +++ b/cypress/integration/navbar_spec.js @@ -14,7 +14,7 @@ const coreSplashPageNavbarLinksVisible = () => { const checkSignedOutSplashNavbarLinksRender = () => { coreSplashPageNavbarLinksVisible(); - + cy.get('[data-cy="navigation-splash-login"]').should('be.visible'); cy.get('[data-cy="navigation-splash-signin"]').should('be.visible'); }; diff --git a/src/components/loginButtonSet/index.js b/src/components/loginButtonSet/index.js index b3139e1363..bec8b4f46d 100644 --- a/src/components/loginButtonSet/index.js +++ b/src/components/loginButtonSet/index.js @@ -4,7 +4,7 @@ import { getItemFromStorage, storeItem } from 'src/helpers/localStorage'; import { OutlineButton } from 'src/components/button'; import { withRouter } from 'react-router'; import queryString from 'query-string'; -import { SERVER_URL, CLIENT_URL } from '../../api/constants'; +import { SERVER_URL, CLIENT_URL } from 'src/api/constants'; import { Container } from './style'; import { TwitterSigninButton } from './twitter'; import { FacebookSigninButton } from './facebook'; @@ -44,8 +44,8 @@ class LoginButtonSet extends React.Component { const postAuthRedirectPath = redirectPath !== undefined || r !== undefined ? // $FlowFixMe - `?r=${redirectPath || r}` - : `?r=${CLIENT_URL}/home`; + `${redirectPath || r}` + : `${CLIENT_URL}/home`; const preferredSigninMethod = getItemFromStorage('preferred_signin_method'); @@ -61,7 +61,7 @@ class LoginButtonSet extends React.Component { { { { { {!githubOnly && (
- + New to Spectrum? Click here to sign up.
diff --git a/src/components/modals/LoginModal/index.js b/src/components/modals/LoginModal/index.js index 0ef9967cc8..22e362cd22 100644 --- a/src/components/modals/LoginModal/index.js +++ b/src/components/modals/LoginModal/index.js @@ -62,7 +62,7 @@ class LoginModal extends React.Component { Existing user? Click here to log in diff --git a/src/views/communityLogin/index.js b/src/views/communityLogin/index.js index 4d52571c8a..7ab5cb13c6 100644 --- a/src/views/communityLogin/index.js +++ b/src/views/communityLogin/index.js @@ -106,7 +106,11 @@ export class Login extends React.Component { githubOnly /> - + Existing user? Click here to log in diff --git a/src/views/login/index.js b/src/views/login/index.js index f1a1b11a22..2acebe6d62 100644 --- a/src/views/login/index.js +++ b/src/views/login/index.js @@ -65,7 +65,10 @@ class Login extends React.Component { /> {githubOnly && ( - + Existing user? Click here to log in )} diff --git a/src/views/newUserOnboarding/index.js b/src/views/newUserOnboarding/index.js index 3ddde1d7b8..e47b4732c5 100644 --- a/src/views/newUserOnboarding/index.js +++ b/src/views/newUserOnboarding/index.js @@ -2,13 +2,14 @@ import React from 'react'; import { connect } from 'react-redux'; import type { Dispatch } from 'redux'; +import queryString from 'query-string'; import compose from 'recompose/compose'; import { withRouter, type History, type Location } from 'react-router-dom'; import { withCurrentUser } from 'src/components/withCurrentUser'; import SetUsername from './components/setUsername'; import { track, events } from 'src/helpers/analytics'; import type { UserInfoType } from 'shared/graphql/fragments/user/userInfo'; -import { SERVER_URL } from 'src/api/constants'; +import { SERVER_URL, CLIENT_URL } from 'src/api/constants'; import { setTitlebarProps } from 'src/actions/titlebar'; import { ViewGrid, CenteredGrid } from 'src/components/layout'; import Login from 'src/views/login'; @@ -40,10 +41,22 @@ class NewUserOnboarding extends React.Component { }; render() { - const { currentUser, history } = this.props; + const { currentUser } = this.props; + + let r; + if (location) { + const searchObj = queryString.parse(this.props.location.search); + r = searchObj.r; + } + + const redirectPath = + redirectPath !== undefined || r !== undefined + ? // $FlowFixMe + `${redirectPath || r}` + : `${CLIENT_URL}/home`; if (!currentUser) { - return ; + return ; } if (currentUser && currentUser.username) { diff --git a/src/views/userSettings/components/editForm.js b/src/views/userSettings/components/editForm.js index 88dba39ea9..87f3eaa027 100644 --- a/src/views/userSettings/components/editForm.js +++ b/src/views/userSettings/components/editForm.js @@ -324,7 +324,7 @@ class UserWithData extends React.Component { didChangeEmail, } = this.state; - const postAuthRedirectPath = `?r=${CLIENT_URL}/users/${username}/settings`; + const postAuthRedirectPath = `${CLIENT_URL}/users/${username}/settings`; return ( @@ -422,7 +422,7 @@ class UserWithData extends React.Component { Connect your GitHub Profile { Your GitHub Profile ·{' '}
Refresh username From f7c5fc3cfa101540649c43d758851f85ab1e9d06 Mon Sep 17 00:00:00 2001 From: Brian Lovin Date: Tue, 25 Jun 2019 08:15:06 -0400 Subject: [PATCH 6/7] Fix flow --- src/views/login/index.js | 2 +- src/views/newUserOnboarding/index.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/views/login/index.js b/src/views/login/index.js index 2acebe6d62..b6ebec29d2 100644 --- a/src/views/login/index.js +++ b/src/views/login/index.js @@ -67,7 +67,7 @@ class Login extends React.Component { {githubOnly && ( Existing user? Click here to log in diff --git a/src/views/newUserOnboarding/index.js b/src/views/newUserOnboarding/index.js index e47b4732c5..6053c97b65 100644 --- a/src/views/newUserOnboarding/index.js +++ b/src/views/newUserOnboarding/index.js @@ -50,9 +50,9 @@ class NewUserOnboarding extends React.Component { } const redirectPath = - redirectPath !== undefined || r !== undefined + r !== undefined ? // $FlowFixMe - `${redirectPath || r}` + `${r}` : `${CLIENT_URL}/home`; if (!currentUser) { From fa9b1029f7cc4d9890c1d8f49d72fa4b471ead97 Mon Sep 17 00:00:00 2001 From: Brian Lovin Date: Tue, 25 Jun 2019 08:30:21 -0400 Subject: [PATCH 7/7] 3.1.15 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4bc1668eae..59164489b4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "Spectrum", - "version": "3.1.14", + "version": "3.1.15", "license": "BSD-3-Clause", "devDependencies": { "@babel/preset-flow": "^7.0.0",