I have already get the access Token and user information using the API end point but now I want to login into please help me how I can login into and get currentAuthenticatedUser, I have not login with user and pass word because I have using Facebook/Google Web UI login into aws.
Hub.listen("auth", ({ payload: { event, data } }) => {
switch (event) {
case "signIn":
Auth.currentAuthenticatedUser().then(user => {
this.setState({ user, error: null, loading: false });
debugger
});
break;
case "signOut":
this.setState({ user: null, error: null, loading: false });
debugger
break;
}
});
Please try below code, it may be work for you:
`
componentDidMount() {
Hub.listen('auth', this);
}
onHubCapsule(capsule) {
debugger
const { channel, payload, source } = capsule;
if (channel === 'auth' && payload.event === 'signIn') {
this.checkUser();
}else{
this.setState({user : null});
}
}
checkUser() {
Auth.currentAuthenticatedUser().then((user) => {
this.setState(user)
});
}
`