diff --git a/lib/types/account-types.js b/lib/types/account-types.js --- a/lib/types/account-types.js +++ b/lib/types/account-types.js @@ -39,6 +39,7 @@ ...LogInExtraInfo, +username: string, +password: string, + +primaryIdentityPublicKey?: string, }; type DeviceTokenUpdateRequest = { diff --git a/native/account/register-panel.react.js b/native/account/register-panel.react.js --- a/native/account/register-panel.react.js +++ b/native/account/register-panel.react.js @@ -30,6 +30,7 @@ } from 'lib/utils/action-utils'; import SWMansionIcon from '../components/swmansion-icon.react'; +import { commCoreModule } from '../native-modules'; import { NavContext } from '../navigation/navigation-context'; import { useSelector } from '../redux/redux-utils'; import { nativeLogInExtraInfoSelector } from '../selectors/account-selectors'; @@ -51,13 +52,11 @@ }; type Props = { ...BaseProps, - // Redux state +loadingStatus: LoadingStatus, +logInExtraInfo: () => LogInExtraInfo, - // Redux dispatch functions +dispatchActionPromise: DispatchActionPromise, - // async functions that hit server APIs +register: (registerInfo: RegisterInfo) => Promise, + +primaryIdentityPublicKey: ?string, }; type State = { +confirmPasswordFocused: boolean, @@ -330,10 +329,16 @@ async registerAction(extraInfo: LogInExtraInfo) { try { + invariant( + this.props.primaryIdentityPublicKey !== null && + this.props.primaryIdentityPublicKey !== undefined, + 'primaryIdentityPublicKey must exist in logInAction', + ); const result = await this.props.register({ + ...extraInfo, username: this.props.registerState.state.usernameInputText, password: this.props.registerState.state.passwordInputText, - ...extraInfo, + primaryIdentityPublicKey: this.props.primaryIdentityPublicKey, }); this.props.setActiveAlert(false); await setNativeCredentials({ @@ -461,13 +466,26 @@ const dispatchActionPromise = useDispatchActionPromise(); const callRegister = useServerCall(register); + const [ + primaryIdentityPublicKey, + setPrimaryIdentityPublicKey, + ] = React.useState(null); + React.useEffect(() => { + (async () => { + await commCoreModule.initializeCryptoAccount('PLACEHOLDER'); + const { ed25519 } = await commCoreModule.getUserPublicKey(); + setPrimaryIdentityPublicKey(ed25519); + })(); + }, []); + return ( ); },