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
getUsersetToken(token)
app.auth.setToken('secret-auth-token');getToken()
const token = app.auth.getToken();