Skip to content

Instantly share code, notes, and snippets.

@abhiaiyer91
Last active Sep 14, 2021
Embed
What would you like to do?
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