我已经在我的React-Admin应用程序中创建了一个注册表。
我正在尝试在用户注册后当前拥有以下内容的用户登录:
const Register = props => {
const { staticContext, classes, userLogin, ...rest } = props;
const handleRedirect = (basePath, id, data) => {
props.userLogin(
{
username: data.email,
password: data.password
},
'/'
);
}
return (
<Create basePath="/register" resource="users/register" {...rest}>
<SimpleForm toolbar={<UserCreateToolbar classes={classes} />} redirect={handleRedirect}>
<TextInput fullWidth source="firstName" validate={[required()]} />
<TextInput fullWidth source="lastName" validate={[required()]} />
<TextInput fullWidth source="email" validate={[required()]} />
<TextInput fullWidth type="password" source="password" validate={[required()]} />
</SimpleForm>
</Create>
);
}
export default compose(
withStyles(styles),
connect(undefined, { userLogin }),
)(Register);
不幸的是,handleRedirect()仅接收API返回的数据。这不包括密码。
如何使用用户输入的原始值发送到props.userLogin()?