1.0.0 • Published 5 years ago

fake-authentication v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

Fake Authentication

Overview

A Fake Authentication System Using LocalStorage.

Features

  • Handles SignUp, SignIn, SignOut and Persistent Authenticated State
  • Passwords are encrypted with PBKDF2
  • Each user is assigned with an unique id

Usage

If you're using yarn, yarn add fake-authentication

If you're using npm, npm install fake-authentication

import fakeAuth from "fake-authentication";

// For SignUp
fakeAuth
  .signUp("someone@something.com", "password")
  .then(resp => console.log(resp)) // { message: "User Created Successfully", uid: "some-uid" }
  .catch(err => console.log(err)); // { message: "User Already Exists" }

// For SignIn
fakeAuth
  .signIn("someone@something.com", "password")
  .then(resp => console.log(resp)) // { message: "SignIn Successful", uid: "some-uid" }
  .catch(err => console.log(err)); // { message: "Password Did Not Match || User Doesn't Exist" }

// Check AuthState
fakeAuth
  .isAuthenticated()
  .then(resp => console.log(resp)) // { message: "Authenticated", isAuth: true, data: { email: "someone@something.com", uid: "some-uid" } }
  .catch(err => console.log(err)); // { message: "Not Authenticated", isAuth: false, data: "" }

// For SignOut
fakeAuth.signOut();