From 0fe8ea94ffafcb09d2e9baedd8674451ae9af3c2 Mon Sep 17 00:00:00 2001 From: wimo7083 Date: Wed, 31 Oct 2018 15:22:35 -0600 Subject: [PATCH 01/10] re-add the password host route --- config/env.js | 1 + src/config/environment.js | 3 +- .../resetPassword/setPassword/setPassword.js | 29 ++++++++++--------- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/config/env.js b/config/env.js index 258b54d63..6c016d883 100644 --- a/config/env.js +++ b/config/env.js @@ -73,6 +73,7 @@ function getClientEnvironment(publicUrl) { PUBLIC_URL: publicUrl, // Note - fallback string values are for development, and are not prod secrets. OC_API_URL: process.env.OC_API_URL || 'https://api.staging.operationcode.org/api/v1', + OC_BACKEND_HOST: process.env.OC_BACKEND_HOST || 'https://api.staging.operationcode.org/', OC_GOOGLE_KEY: process.env.OC_GOOGLE_KEY, OC_FACEBOOK_KEY: process.env.OC_FACEBOOK_KEY } diff --git a/src/config/environment.js b/src/config/environment.js index 7937a3998..1230b3ebc 100644 --- a/src/config/environment.js +++ b/src/config/environment.js @@ -1,7 +1,8 @@ const config = { apiUrl: process.env.OC_API_URL, + backendHostUrl: process.env.OC_BACKEND_HOST, googleKey: process.env.OC_GOOGLE_KEY, - facebookKey: process.env.OC_FACEBOOK_KEY + facebookKey: process.env.OC_FACEBOOK_KEY, }; export default config; diff --git a/src/scenes/home/resetPassword/setPassword/setPassword.js b/src/scenes/home/resetPassword/setPassword/setPassword.js index a67b67af5..4ca7e7f05 100644 --- a/src/scenes/home/resetPassword/setPassword/setPassword.js +++ b/src/scenes/home/resetPassword/setPassword/setPassword.js @@ -17,7 +17,7 @@ class RequestToken extends Component { passwordConfirmValid: true, error: false, isValid: true, - success: false + success: false, }; } @@ -31,19 +31,22 @@ class RequestToken extends Component { validatePasswordConfirm = value => value === '' || value === this.state.password; - handleOnClick = (e) => { + handleOnClick = e => { e.preventDefault(); if (this.isFormValid()) { - axios.post(`${config.apiUrl}/users/password`, { - user: { - reset_password_token: this.props.resetPasswordToken, - password: this.state.password - } - }).then(() => { - this.setState({ success: true, error: null }); - }).catch(() => { - this.setState({ error: 'We were unable to set the password for this email' }); - }); + axios + .post(`${config.backendHostUrl}/users/password`, { + user: { + reset_password_token: this.props.resetPasswordToken, + password: this.state.password, + }, + }) + .then(() => { + this.setState({ success: true, error: null }); + }) + .catch(() => { + this.setState({ error: 'We were unable to set the password for this email' }); + }); } }; @@ -80,7 +83,7 @@ class RequestToken extends Component { } RequestToken.propTypes = { - resetPasswordToken: PropTypes.string.isRequired + resetPasswordToken: PropTypes.string.isRequired, }; export default RequestToken; From 4c799ce22f684d2112a9598e7585154f550945d7 Mon Sep 17 00:00:00 2001 From: wimo7083 Date: Mon, 5 Nov 2018 21:53:43 -0700 Subject: [PATCH 02/10] fix linting --- src/config/environment.js | 2 +- .../resetPassword/setPassword/setPassword.js | 21 ++++++++----------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/config/environment.js b/src/config/environment.js index 1230b3ebc..a6836a269 100644 --- a/src/config/environment.js +++ b/src/config/environment.js @@ -2,7 +2,7 @@ const config = { apiUrl: process.env.OC_API_URL, backendHostUrl: process.env.OC_BACKEND_HOST, googleKey: process.env.OC_GOOGLE_KEY, - facebookKey: process.env.OC_FACEBOOK_KEY, + facebookKey: process.env.OC_FACEBOOK_KEY }; export default config; diff --git a/src/scenes/home/resetPassword/setPassword/setPassword.js b/src/scenes/home/resetPassword/setPassword/setPassword.js index 4ca7e7f05..e87cf9774 100644 --- a/src/scenes/home/resetPassword/setPassword/setPassword.js +++ b/src/scenes/home/resetPassword/setPassword/setPassword.js @@ -17,7 +17,7 @@ class RequestToken extends Component { passwordConfirmValid: true, error: false, isValid: true, - success: false, + success: false }; } @@ -31,25 +31,22 @@ class RequestToken extends Component { validatePasswordConfirm = value => value === '' || value === this.state.password; - handleOnClick = e => { + handleOnClick = (e) => { e.preventDefault(); if (this.isFormValid()) { - axios - .post(`${config.backendHostUrl}/users/password`, { + axios.post(`${config.backendHostUrl}/users/password`, { user: { reset_password_token: this.props.resetPasswordToken, - password: this.state.password, - }, - }) - .then(() => { + password: this.state.password + } + }).then(() => { this.setState({ success: true, error: null }); - }) - .catch(() => { + }).catch(() => { this.setState({ error: 'We were unable to set the password for this email' }); }); } }; - + isFormValid = () => this.state.passwordValid && this.state.passwordConfirmValid; render() { @@ -83,7 +80,7 @@ class RequestToken extends Component { } RequestToken.propTypes = { - resetPasswordToken: PropTypes.string.isRequired, + resetPasswordToken: PropTypes.string.isRequired }; export default RequestToken; From 02071e6d92166c882473daa170f4b8f2b52afb77 Mon Sep 17 00:00:00 2001 From: wimo7083 Date: Mon, 5 Nov 2018 21:56:19 -0700 Subject: [PATCH 03/10] more spacing --- .../resetPassword/setPassword/setPassword.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/scenes/home/resetPassword/setPassword/setPassword.js b/src/scenes/home/resetPassword/setPassword/setPassword.js index e87cf9774..9504840c3 100644 --- a/src/scenes/home/resetPassword/setPassword/setPassword.js +++ b/src/scenes/home/resetPassword/setPassword/setPassword.js @@ -35,18 +35,17 @@ class RequestToken extends Component { e.preventDefault(); if (this.isFormValid()) { axios.post(`${config.backendHostUrl}/users/password`, { - user: { - reset_password_token: this.props.resetPasswordToken, - password: this.state.password - } - }).then(() => { - this.setState({ success: true, error: null }); - }).catch(() => { - this.setState({ error: 'We were unable to set the password for this email' }); - }); + user: { + reset_password_token: this.props.resetPasswordToken, + password: this.state.password + } + }).then(() => { + this.setState({ success: true, error: null }); + }).catch(() => { + this.setState({ error: 'We were unable to set the password for this email' }); + }); } }; - isFormValid = () => this.state.passwordValid && this.state.passwordConfirmValid; render() { From cea175a28322998afd5b3b39516e284dd66bdb55 Mon Sep 17 00:00:00 2001 From: wimo7083 Date: Tue, 6 Nov 2018 01:26:28 -0700 Subject: [PATCH 04/10] update env variables --- config/env.js | 1 - 1 file changed, 1 deletion(-) diff --git a/config/env.js b/config/env.js index 6c016d883..258b54d63 100644 --- a/config/env.js +++ b/config/env.js @@ -73,7 +73,6 @@ function getClientEnvironment(publicUrl) { PUBLIC_URL: publicUrl, // Note - fallback string values are for development, and are not prod secrets. OC_API_URL: process.env.OC_API_URL || 'https://api.staging.operationcode.org/api/v1', - OC_BACKEND_HOST: process.env.OC_BACKEND_HOST || 'https://api.staging.operationcode.org/', OC_GOOGLE_KEY: process.env.OC_GOOGLE_KEY, OC_FACEBOOK_KEY: process.env.OC_FACEBOOK_KEY } From 20b0b4f6713cee13fec81f9e52d27340b04f5060 Mon Sep 17 00:00:00 2001 From: wimo7083 Date: Tue, 6 Nov 2018 01:26:51 -0700 Subject: [PATCH 05/10] add environment context --- src/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 722419881..8aeeaa884 100644 --- a/src/index.js +++ b/src/index.js @@ -8,6 +8,8 @@ import './shared/styles/react-select.global.css'; import './shared/styles/notifications.global.css'; import './index.css'; -Raven.config('https://6350058c0b0247bf8923b9965ca744fa@sentry.io/222621').install(); +Raven.config('https://6350058c0b0247bf8923b9965ca744fa@sentry.io/222621', { + environment: process.env.NODE_ENV +}).install(); ReactDOM.render(, document.getElementById('root')); From 52a7b0ad13071696e26a3f68bfb7ab06ef22fb2c Mon Sep 17 00:00:00 2001 From: wimo7083 Date: Tue, 6 Nov 2018 01:28:14 -0700 Subject: [PATCH 06/10] remove user object --- .../resetPassword/setPassword/setPassword.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/scenes/home/resetPassword/setPassword/setPassword.js b/src/scenes/home/resetPassword/setPassword/setPassword.js index 9504840c3..0172b11db 100644 --- a/src/scenes/home/resetPassword/setPassword/setPassword.js +++ b/src/scenes/home/resetPassword/setPassword/setPassword.js @@ -34,16 +34,17 @@ class RequestToken extends Component { handleOnClick = (e) => { e.preventDefault(); if (this.isFormValid()) { - axios.post(`${config.backendHostUrl}/users/password`, { - user: { + axios + .post(`${config.apiUrl}/users/passwords/reset`, { reset_password_token: this.props.resetPasswordToken, password: this.state.password - } - }).then(() => { - this.setState({ success: true, error: null }); - }).catch(() => { - this.setState({ error: 'We were unable to set the password for this email' }); - }); + }) + .then(() => { + this.setState({ success: true, error: null }); + }) + .catch(() => { + this.setState({ error: 'We were unable to set the password for this email' }); + }); } }; isFormValid = () => this.state.passwordValid && this.state.passwordConfirmValid; From 88e813b2ab3ca4739b47a1a32e26c0a26f4f5bad Mon Sep 17 00:00:00 2001 From: wimo7083 Date: Tue, 6 Nov 2018 01:28:42 -0700 Subject: [PATCH 07/10] use new route and get sentry logging when we get issues --- .../home/resetPassword/requestToken/requestToken.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/scenes/home/resetPassword/requestToken/requestToken.js b/src/scenes/home/resetPassword/requestToken/requestToken.js index ae06611e4..a85d83a01 100644 --- a/src/scenes/home/resetPassword/requestToken/requestToken.js +++ b/src/scenes/home/resetPassword/requestToken/requestToken.js @@ -27,13 +27,19 @@ class RequestToken extends Component { e.preventDefault(); if (this.isFormValid()) { axios - .post(`${config.apiUrl}/users/passwords/reset`, { + .post(`${config.apiUrl}/users/passwords/forgot`, { email: this.state.email }) .then(() => { this.setState({ success: true, error: null }); }) - .catch(() => { + .catch((err) => { + Raven.setUserContext({ + email: this.state.email, + action: 'Attemped password reset' + }); + Raven.captureException(err); + Raven.setUserContext(); this.setState({ error: 'We were unable to reset the password for this email' }); }); } From 3b582d8cbce8dec24ad1e0c77ca70472d8540f69 Mon Sep 17 00:00:00 2001 From: wimo7083 Date: Tue, 6 Nov 2018 01:47:30 -0700 Subject: [PATCH 08/10] remove old env var and include the import --- src/config/environment.js | 1 - src/scenes/home/resetPassword/requestToken/requestToken.js | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config/environment.js b/src/config/environment.js index a6836a269..7937a3998 100644 --- a/src/config/environment.js +++ b/src/config/environment.js @@ -1,6 +1,5 @@ const config = { apiUrl: process.env.OC_API_URL, - backendHostUrl: process.env.OC_BACKEND_HOST, googleKey: process.env.OC_GOOGLE_KEY, facebookKey: process.env.OC_FACEBOOK_KEY }; diff --git a/src/scenes/home/resetPassword/requestToken/requestToken.js b/src/scenes/home/resetPassword/requestToken/requestToken.js index a85d83a01..92b0fa6e3 100644 --- a/src/scenes/home/resetPassword/requestToken/requestToken.js +++ b/src/scenes/home/resetPassword/requestToken/requestToken.js @@ -6,6 +6,7 @@ import FormEmail from 'shared/components/form/formEmail/formEmail'; import FormButton from 'shared/components/form/formButton/formButton'; import config from 'config/environment'; import styles from './requestToken.css'; +import Raven from 'raven-js'; class RequestToken extends Component { constructor(props) { From ef9f28b390af49c7e08aba8ec8ae291d2f63a556 Mon Sep 17 00:00:00 2001 From: William Montgomery <10781353+wimo7083@users.noreply.github.com> Date: Tue, 6 Nov 2018 11:39:01 -0700 Subject: [PATCH 09/10] change message. --- src/scenes/home/resetPassword/setPassword/setPassword.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scenes/home/resetPassword/setPassword/setPassword.js b/src/scenes/home/resetPassword/setPassword/setPassword.js index 0172b11db..7b94c4bf0 100644 --- a/src/scenes/home/resetPassword/setPassword/setPassword.js +++ b/src/scenes/home/resetPassword/setPassword/setPassword.js @@ -43,7 +43,7 @@ class RequestToken extends Component { this.setState({ success: true, error: null }); }) .catch(() => { - this.setState({ error: 'We were unable to set the password for this email' }); + this.setState({ error: 'Error: please email staff@operationcode.org for help' }); }); } }; From f730d0eac7320faaf135b48ae9b3d80d78fe312d Mon Sep 17 00:00:00 2001 From: Kyle Holmberg Date: Tue, 6 Nov 2018 13:51:10 -0800 Subject: [PATCH 10/10] Move import to appease linting --- src/scenes/home/resetPassword/requestToken/requestToken.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scenes/home/resetPassword/requestToken/requestToken.js b/src/scenes/home/resetPassword/requestToken/requestToken.js index 92b0fa6e3..a4f04f9fd 100644 --- a/src/scenes/home/resetPassword/requestToken/requestToken.js +++ b/src/scenes/home/resetPassword/requestToken/requestToken.js @@ -1,12 +1,12 @@ import React, { Component } from 'react'; import axios from 'axios'; +import Raven from 'raven-js'; import { Redirect } from 'react-router-dom'; import Form from 'shared/components/form/form'; import FormEmail from 'shared/components/form/formEmail/formEmail'; import FormButton from 'shared/components/form/formButton/formButton'; import config from 'config/environment'; import styles from './requestToken.css'; -import Raven from 'raven-js'; class RequestToken extends Component { constructor(props) {