Skip to content

Commit

Permalink
Merge pull request #1368 from sharetribe/pass-extra-values-as-protect…
Browse files Browse the repository at this point in the history
…ed-data-from-confirm-form

Pass additional values from ConfirmSignupForm forward as protected data
  • Loading branch information
OtterleyW authored Oct 16, 2020
2 parents c5843a2 + 1d933ba commit a65f0f8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ way to update this template, but currently, we follow a pattern:

## Upcoming version 2020-XX-XX

- [fix] Pass additional values from `ConfirmSignupForm` forward as user's protected data.
[#1368](https://github.com/sharetribe/ftw-daily/pull/1368)

## [v6.4.0] 2020-10-14

- [add] Add Facebook login as a first step towards supporting social logins and SSO in FTW. This PR
Expand Down
13 changes: 9 additions & 4 deletions src/containers/AuthenticationPage/AuthenticationPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import { manageDisableScrolling } from '../../ducks/UI.duck';

import css from './AuthenticationPage.css';
import { FacebookLogo } from './socialLoginLogos';
import { isEmpty } from 'lodash';

export class AuthenticationPageComponent extends Component {
constructor(props) {
Expand Down Expand Up @@ -76,7 +77,7 @@ export class AuthenticationPageComponent extends Component {
submitLogin,
submitSignup,
confirmError,
submitSinguoWithIdp,
submitSingupWithIdp,
tab,
sendVerificationEmailInProgress,
sendVerificationEmailError,
Expand Down Expand Up @@ -176,7 +177,7 @@ export class AuthenticationPageComponent extends Component {

const handleSubmitConfirm = values => {
const { idpToken, email, firstName, lastName, idpId } = this.state.authInfo;
const { email: newEmail, firstName: newFirstName, lastName: newLastName } = values;
const { email: newEmail, firstName: newFirstName, lastName: newLastName, ...rest } = values;

// Pass email, fistName or lastName to Flex API only if user has edited them
// sand they can't be fetched directly from idp provider (e.g. Facebook)
Expand All @@ -187,10 +188,14 @@ export class AuthenticationPageComponent extends Component {
...(newLastName !== lastName && { lastName: newLastName }),
};

submitSinguoWithIdp({
// If the confirm form has any additional values, pass them forward as user's protected data
const protectedData = !isEmpty(rest) ? { ...rest } : null;

submitSingupWithIdp({
idpToken,
idpId,
...authParams,
protectedData,
});
};

Expand Down Expand Up @@ -449,7 +454,7 @@ const mapStateToProps = state => {
const mapDispatchToProps = dispatch => ({
submitLogin: ({ email, password }) => dispatch(login(email, password)),
submitSignup: params => dispatch(signup(params)),
submitSinguoWithIdp: params => dispatch(signupWithIdp(params)),
submitSingupWithIdp: params => dispatch(signupWithIdp(params)),
onResendVerificationEmail: () => dispatch(sendVerificationEmail()),
onManageDisableScrolling: (componentId, disableScrolling) =>
dispatch(manageDisableScrolling(componentId, disableScrolling)),
Expand Down

0 comments on commit a65f0f8

Please sign in to comment.