0.0.7 • Published 7 years ago

reazy-auth v0.0.7

Weekly downloads
4
License
Apache-2.0
Repository
github
Last release
7 years ago

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();
0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago