Skip to content

Commit

Permalink
Merge pull request #2047 from haverchuck/angular-signup-fields
Browse files Browse the repository at this point in the history
fixing parameter structure in react HOC and logger error in signup jsx
  • Loading branch information
haverchuck authored Nov 7, 2018
2 parents 530bc62 + 6627bee commit e316ac6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
6 changes: 4 additions & 2 deletions packages/aws-amplify-react/src/Auth/SignUp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import * as React from 'react';

import { I18n } from '@aws-amplify/core';
import { I18n, ConsoleLogger as Logger } from '@aws-amplify/core';
import Auth from '@aws-amplify/auth';

import AuthPiece from './AuthPiece';
Expand All @@ -36,6 +36,8 @@ import countryDialCodes from './common/country-dial-codes.js';
import defaultSignUpFields from './common/default-sign-in-fields'
import { valid } from 'semver';

const logger = new Logger('SignUp');


export default class SignUp extends AuthPiece {
constructor(props) {
Expand Down Expand Up @@ -128,7 +130,7 @@ export default class SignUp extends AuthPiece {
if (key.indexOf('custom:') !== 0) {
return field.custom ;
} else if (key.indexOf('custom:') === 0 && field.custom === false) {
logger.warn('Custom prefix prepended to key but custom field flag is set to false');
logger.warn('Custom prefix prepended to key but custom field flag is set to false; retaining manually entered prefix');

}
return null;
Expand Down
28 changes: 21 additions & 7 deletions packages/aws-amplify-react/src/Auth/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@ export function withAuthenticator(Comp, includeGreetings = false, authenticatorC
authState: props.authState || null,
authData: props.authData || null
};

this.authConfig = {};

if (typeof includeGreetings === 'object' && includeGreetings !== null){
this.authConfig = Object.assign(this.authConfig, this.includeGreetings)
} else {
this.authConfig = {
includeGreetings,
authenticatorComponents,
federated,
theme,
signUpConfig
}
}
}

handleAuthStateChange(state, data) {
Expand All @@ -58,11 +72,11 @@ export function withAuthenticator(Comp, includeGreetings = false, authenticatorC
return (
<div>
{
includeGreetings?
this.authConfig.includeGreetings?
<Greetings
authState={authState}
authData={authData}
federated={federated || this.props.federated}
federated={this.authConfig.federated || {} }
onStateChange={this.handleAuthStateChange}
theme={theme}
/>
Expand All @@ -80,12 +94,12 @@ export function withAuthenticator(Comp, includeGreetings = false, authenticatorC

return <Authenticator
{...this.props}
theme={theme}
federated={federated || this.props.federated}
hideDefault={authenticatorComponents.length > 0}
signUpConfig={signUpConfig}
theme={this.authConfig.theme}
federated={this.authConfig.federated}
hideDefault={this.authConfig.authenticatorComponents && this.authConfig.authenticatorComponents.length > 0}
signUpConfig={this.authConfig.signUpConfig}
onStateChange={this.handleAuthStateChange}
children={authenticatorComponents}
children={this.authConfig.authenticatorComponents}
/>;
}
};
Expand Down

0 comments on commit e316ac6

Please sign in to comment.