Code Monkey home page Code Monkey logo

meteor-auth's Introduction

meteor-auth

A user authentication solution for Mantra applications

Installation

npm install -s meteor-auth

Usage

This module includes:

  • authComposer
  • EnsureLoggedIn

authComposer

Compose a component with authComposer using composeWithTracker. The component will reactively receive loggedIn and loggingIn props.

container

import {composeAll, composeWithTracker} from 'mantra-core';
import MyComponent from '../components/my_component.jsx';
import {authComposer} from 'meteor-auth';

// ...

return composeAll(
  composeWithTracker(authComposer),
)(MyComponent);

component

import React form 'react'

const MyComponent = ({loggedIn, loggingIn}) => (
  {
    loggedIn ? <div>Welcome</div> :
    loggingIn ? <div>Loading...</div> : <div>Please log in</div>
  }
);

EnsureLoggedIn

Wrap a content with <EnsureLoggedIn> to make sure only logged in users can see the content.

import React form 'react'
import {EnsureLoggedIn} from 'meteor-auth';

const MyComponent = () => (
  <EnsureLoggedIn>
    <div>Welcome</div>
  </EnsureLoggedIn>
);

props

unauthenticatedMessage

  • type: React component
  • Replace the default component displayed when user is not logged in
  • example:
const Dashboard = () => (
  <EnsureLoggedIn unauthenticatedMessage={NotLoggedInMessage}>
    <DashboardView />
  </EnsureLoggedIn>
);

const NotLoggedInMessage = (
  <div>
    Please login. <a href="/">Go back to the main page</a>.
  </div>
);

Production ready

We are using meteor-auth in RemoteBase to serve actual users.

License

MIT

meteor-auth's People

Contributors

guillaumets avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.