Fortmatic
WebsiteDashboardSupport
v1.x
v1.x
  • 🚀Get Started
  • 📦Install with NPM
  • 🧩Examples
  • 💬FAQ
  • Web3 Integration
    • Web3 Provider
    • Network Configuration
    • Get User Account
    • Send Ether Transaction
    • Smart Contract Functions
    • User Signing
    • SDK Error Handling
    • Batch Request
  • Smart Contract
    • ERC20 Transfer
    • ERC20 Approve
    • ERC20 TransferFrom
    • Generic Contract Call
  • Fortmatic Native
    • Log In
    • Log Out
    • Is User Logged In
    • Compose Transaction
    • Deposit Address
    • Configuration
  • Security
    • Domain Verification
Powered by GitBook
On this page

Was this helpful?

  1. Fortmatic Native

Is User Logged In

// Initialize provider
import Fortmatic from 'fortmatic';
import Web3 from 'web3';

const fm = new Fortmatic('YOUR_API_KEY');
window.web3 = new Web3(fm.getProvider());

let isUserLoggedIn = await fm.user.isLoggedIn();
console.log(isUserLoggedIn); // false

fm.user.login().then(() => {
  isUserLoggedIn = await fm.user.isLoggedIn();
  console.log(isUserLoggedIn); // true
});

You may get a user's Fortmatic id and email by calling fm.user.getUser()

let isUserLoggedIn = await fm.user.isLoggedIn(); // false
let userData = await fm.user.getUser(); 
// {
//   id: null
//   email: null
// }

fm.user.login().then(() => {
  userData = await fm.user.getUser(); 
  // {
  //   id: 'FORTMATIC_USER_ID'
  //   email: 'example@fortmatic.com'
  // }
});
PreviousLog OutNextCompose Transaction

Last updated 5 years ago

Was this helpful?