I have this app and when user opens it I would like to make them authenticate with metamask. In this case, it says authenticated when user first gets there and I think it’s because moralis already recognizes them as a user. How can I prevent this? Should I force a logout upon entry ?
code;
import { Stack } from "@chakra-ui/layout";
import { Box, Button, HStack, Image } from "@chakra-ui/react";
import { useMoralis } from "react-moralis";
import { CheckIcon } from "@chakra-ui/icons";
import React from "react";
export default function Authentication() {
const { user } = useMoralis();
//const [username, setUsername] = React.useState<string>("");
const {
authenticate,
authError,
isAuthenticated,
isAuthenticating,
logout
} = useMoralis();
console.log(
user,
isAuthenticated,
isAuthenticating,
authError);
return (
<div>
<Stack spacing={6}>
<Image src="bankXheader.jpg" alt="" />
<div>
<Image width="50%" src="giveaway7.png" alt="" />
</div>
<Box>
{isAuthenticated ? (
<>Authenticated with Metamask!<CheckIcon ml={2} w={8} h={8} color="green.500"/>
<Button onClick={() => logout()}>Logout</Button></>
) : (
<HStack>
<Button onClick={() => authenticate()}>Authenticate w Metamask</Button>
<Button onClick={() => authenticate({ provider: "walletconnect" })}>Authenticate Walletconnect</Button>
</HStack>
)}
</Box>
</Stack>
</div>
);
}