Skip to content

clef/instant2fa-component

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Instant2FAComponent

Installation

npm install --save instant2fa-component

Settings page

// UserSettings.jsx
import React from 'react';
import Instant2FAComponent from 'instant2fa-component';

const UserSettings = () => {
  return (
    <div>
      <Instant2FAComponent
        uri='YOUR_SETTINGS_PAGE_URI'
      ></Instant2FAComponent>
    </div>
  )
};

export default UserSettings;

Verification page

// UserVerification.jsx
import React from 'react';
import Instant2FAComponent from 'instant2fa-component';

const UserVerification = () => {
  const onEvent = (event) => {
    if (event.type === "verificationSuccess") {
      var token = event.payload.token;
      console.log("Verification token is: " + token);

      $.ajax({
          method: 'POST',
          url: '/two-factor-verification',
          data: {
              instant2faToken: event.payload.token
          }
      });
    }
  }

  return (
    <div>
      <Instant2FAComponent
        uri='YOUR_VERIFICATION_PAGE_URI'
        onEvent={onEvent}
      ></Instant2FAComponent>
    </div>
  )
};

export default UserVerification;