I am building my first app with AWS Amplify and React and I'm using withAuthenticator to force users to sign in. When I hit the sign out button it redirects back to the login page but if I refresh the page it logs back in and displays my app again, obviously, this isn't useful as I need it to completely sign the user out of my app and remove all their data from the browser. What am I doing wrong? I've even made a button to trigger Auth.signOut() but I'm still getting the same issue where I just can't log out from my app.
I've even used the global sign out here but it's still signing back in when I refresh the page. https://docs.amplify.aws/lib/auth/emailpassword/q/platform/js#sign-out
my code:
import React from 'react';
import logo from './SE_logo.jpg';
import './App.css';
import Amplify, { API, Auth } from 'aws-amplify';
import {withAuthenticator} from 'aws-amplify-react';
import '@aws-amplify/ui/dist/style.css';
async function onSignOutClick() {
//await Auth.signOut()
// .then(data => console.log(data))
// .catch(err => console.log(err));
console.log(Auth.signOut());
}
function App() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<button onClick={onSignOutClick}>Log Out</button>
</header>
</div>
);
}
export default withAuthenticator(App, true);