founderlab / fl-auth-react

Ready made forms for use with fl-auth-redux and fl-auth-server. Part of fl-auth-*, an auth package for frameworkstein apps

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

This package has moved to the Frameworkstein repository


Ready made forms for use with fl-auth-redux and fl-auth-server

Part of fl-auth-*, an auth package for frameworkstein apps

Usage:

    // Ensure that the auth reducer from fl-auth-redux is in place

    import {login, register} from 'fl-auth-redux'
    import {LoginForm, RegisterForm} from 'fl-auth-react'

    ...
    @connect(state => {auth: state.auth}, {login, register})
    class LoginExample extends React.Component {

      handleLogin = data => {
        // data here contains an email & password from LoginForm
        this.props.login('/login', data.email, data.password, err => {
          // Redirect somewhere once logged in
        })
      }

      handleRegister = data => {
        // data here contains an email & password from RegisterForm
        this.props.register('/register', data, err => {
          // Redirect somewhere after registration
        })
      }

      render() {
        const {auth, onSubmit} = this.props

        return (
          <div>
            <LoginForm auth={auth} onSubmit={handleLogin} />
            <RegisterForm auth={auth} onSubmit={handleRegister} />
          </div>
        )
      }
    }

About

Ready made forms for use with fl-auth-redux and fl-auth-server. Part of fl-auth-*, an auth package for frameworkstein apps

License:MIT License


Languages

Language:JavaScript 100.0%