New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@app-masters/react-auth-container

Package Overview
Dependencies
Maintainers
3
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@app-masters/react-auth-container

auth component

  • 1.0.22
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
17
increased by41.67%
Maintainers
3
Weekly downloads
 
Created
Source

Auth Container

Every action now serves as a callback, the Auth Component will be responsible to handle the whole authentication process and return callback values so that the outter setup know how to handle the data it resolves.

Installation

npm install --save @app-masters/react-auth-container

Props

PropType
baseUrlString
clientString
appVersionNumber
onLoginSuccessFunction
onLoginFailFunction
onSignupSuccessFunction
onSignupFailFunction
loginComponent
signupComponent

Usage

Component (PublicRoutes)

import React, {Component} from 'react';
import { connect } from 'react-redux';
import Login from '../views/Login';
import Auth from '@app-masters/react-auth-container';
import { onLoginSuccess, onLoginFail, onSignupFail, onSignupSucess } from '../actions/authActions';

class PublicRoutes extends Component {
    render () {
        return (
            <div>
                <Auth
                    login={<Login />}
                    signup={null}
                    onLoginSuccess={(response) => {
                        this.props.onLoginSuccess(response);
                    }}
                    onLoginFail={(response) => {
                        this.props.onLoginFail(response); //
                    }}
                    onSignupSucess={(response) => {
                        this.props.onSignupSucess(response);
                    }}
                    onSignupFail={(response) => {
                        this.props.onSignupFail(response);
                    }}
                    client={'admin'}
                    appVersion={process.env.APP_VERSION}
                    baseUrl={'http://localhost:3000/api'} />
            </div>
        );
    }
}
const mapState = (state) => ({});
const mapActions = (dispatch) => ({
    onLoginSuccess: (res) => dispatch(onLoginSuccess(res)),
    onSignupFail: (res) => dispatch(onSignupFail(res)),
    onSignupSucess: (res) => dispatch(onSignupSucess(res)),
    onLoginFail: (res) => dispatch(onLoginFail(res))
});
export default connect(mapState, mapActions)(PublicRoutes);


Actions


import { AUTH_LOGIN_SUCCESS, AUTH_LOGOUT } from './types';
import { Http } from '@app-masters/js-lib';
export const onLoginSuccess = (userData) => dispatch => {
    console.log('LOGIN SUCCESS:', userData);
    Http.setHeaders({
        'Accept': 'application/json',
        'Content-Type': 'application/json',
        'client': 'admin',
        'Authorization': userData.token
    });
    Http.setEndpointParam('{_id}', userData.user._id);
    dispatch({type: AUTH_LOGIN_SUCCESS, payload: userData});
};


FAQs

Package last updated on 22 Dec 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc