A simple auth store for your Reazy apps
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
dist
src
.gitignore
.npmignore
LICENSE
README.md
package.json
yarn.lock

README.md

reazy-auth

A simple auth store for your Reazy apps


Installation

1. Using Reazy CLI

$ reazy add auth

2. Manual

  • Install reazy-auth
$ npm install --save reazy-auth
  • Add these lines to your src/app.js.
import reazy from 'reazy';
import auth from 'reazy-auth';                    // <-- import the service
import reactNative from './services/react-native';

const app = reazy();

app.use(auth(), 'auth');                          // <-- Initialize the service
app.use(reactNative(), 'reactNative');

export default app;

Usage

This Reazy plugin is just an authentication store service. For full implementation of authentication, use this with one of the following:

Let's assume you have registered this service with name auth. Then you can access the service in two ways:

const authService = app.auth;
// OR
const authService = app.get('auth');

This service provides the following functions:

  • setUser(user)

    app.auth.setUser({name: 'Sanket', email: 'sanket@reazyframework.io'});
  • getUser()

    const user = app.auth.getUser();
  • user()

    Alias of getUser

  • setToken(token)

    app.auth.setToken('secret-auth-token');
  • getToken()

    const token = app.auth.getToken();