1.0.7 • Published 3 years ago

@shaddyshad/auth_utils v1.0.7

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

auth_utils

MongoDB realm auth utils

NPM JavaScript Style Guide

Install

npm install --save @shaddyshad/auth_utils

yarn add @shaddyshad/auth_utils

Usage

import React, { Component } from 'react'

import {AuthContextProvider} from 'auth_utils'

// declare the app id from mongo db realm
const appId = "YOUR_REALM_APP_ID"

class Example extends Component {
  render() {
    return (
      <AuthContextProvider appId={appId} >
          <OtherComponents />
      </AuthContextProvider>
    )
  }
}

In the login page

import React, {useState} from 'react'
import {useAuth} from 'auth_utils'

const Signin = (props) => {
  const [email, setEmail] = useState("")
  const [password, setPassword] = useState("")

  const auth = useAuth()

  const onSignin = () => {
    auth.login(email, password)
      .then(() => {
        // succesfully signed in
      }).catch(err => {
        // handle the error 
        // {error: str, error_code: str...}
      })
  }


  return (
    <SigninUi onSigin={onSigin} />
  )
}

License

MIT © shaddyshad

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.4

3 years ago

1.0.0

3 years ago