npm.io
0.0.20 • Published 6 years ago

loginplify

Licence
MIT
Version
0.0.20
Deps
5
Size
172 kB
Vulns
25
Weekly
0

Getting Started

NOTE: Please make sure you have deployed your Loginplify server before using this component library

Installation

$ npm i loginplify

Add authentication on a page on your React application

import * as React from 'react'
import { withAuthenticator } from 'loginplify'

const settings = {
  endpoint: 'https://loginplify.mydomain.se/graphql'
}

const ProtectedPage = () => {
  return (
    <div>
      <h1>This is private content</h1>
    </div>
  )
}

export default withAuthenticator(ProtectedPage, settings)

Logout

import * as React from 'react'
import { withAuthenticator, useLoginServiceContext } from 'loginplify'

const settings = {
  endpoint: 'https://loginplify.mydomain.se/graphql'
}

const ProtectedPage = () => {
  const { actions } = useLoginServiceContext()

  return (
    <div>
      <h1>This is private content</h1>
      <button onClick={() => actions.logout()}>Logout</button>
    </div>
  )
}

export default withAuthenticator(ProtectedPage, settings)