2.0.2 • Published 8 years ago

autheus v2.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

autheus NPM version Build status

Image

A generic user auth/session module for front-end web apps.

Installation

Install the package with NPM:

$ npm install autheus

Usage

The package exposes an Autheus singleton class, making it ideal for web browser-based, single-page apps. It has a few utility methods, which can be used like so:

import {Autheus} from "autheus";

console.log(Autheus.isSignedIn); // -> false
console.log(Autheus.token);      // -> null

Autheus.signIn("fake-auth-token");
console.log(Autheus.isSignedIn); // -> true
console.log(Autheus.token);      // -> "fake-auth-token"

Autheus.signOut();
console.log(Autheus.isSignedIn); // -> false
console.log(Autheus.token);      // -> null

Furthermore, for those utilizing react-router, the package provides a getReactRouterHooks function to aide you in managing route transitions. Example:

let [requireSignIn, requireSignOut] = Autheus.getReactRouterHooks("/sign-in", "/sign-out");
let routes = (
  <Router history={hashHistory}>
    <Route path="/" component={App}>
      <IndexRoute component={Home} onEnter={requireSignIn} />
      <Route path="sign-in" component={SignIn} onEnter={requireSignOut} />
      <Route path="sign-out" component={SignOut} onEnter={requireSignIn} />
      <Route path="*" component={NotFound} />
    </Route>
  </Router>
);
2.0.2

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago