Last active
September 14, 2021 18:19
-
-
Save abhiaiyer91/eb33dc7c57fe677eeea234802c803edc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { navigate } from "gatsby-link"; | |
import { useMoralis } from "./useMoralis"; | |
export function useAuth() { | |
const { Moralis } = useMoralis(); | |
return { | |
login: async () => { | |
try { | |
const user = await Moralis?.Web3.authenticate(); | |
navigate("/"); | |
} catch (e) { | |
console.error(e.message, e); | |
} | |
}, | |
logout: async () => { | |
try { | |
await Moralis?.User.logOut(); | |
navigate("/login"); | |
} catch (e) { | |
console.error(e.message, e); | |
} | |
}, | |
currentUser: () => { | |
return Moralis?.User.current(); | |
}, | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment