使用React / AWS Amplify / withAuthenticator:成功登录后如何进入应用程序

时间:2018-11-12 20:23:22

标签: reactjs authentication aws-amplify

我目前将App.js文件包装在withAuthenticator较高的组件中,如AWS Amplify的文档所述。我没有使用Amplify的默认登录组件,而是传递了组件LoginPage,该组件有几个用于登录的自定义子窗体组件。

export default withAuthenticator(
    App, true, [<LogInPage />, ]
);

表单本身通过以下方式连接到Amplify import { Auth } from 'aws-amplify';,但是当我完成登录后,我不会进入App.js内容。实际上,我什么都没带。

Auth.signin代码在我的Login组件的代码中,使用有效的用户名和密码进行调用将返回用户数据对象,仅此而已。

submitForm = () => {
    const { username, password } = this.state;
    Auth.signIn(username, password)
        .then(user => console.log(user))
        .catch(err => console.log(err));
};

我还需要做些什么才能使登录页面消失并转到实际的应用程序中?

0 个答案:

没有答案