Skip to content

A user authentication solution for Mantra applications

License

Notifications You must be signed in to change notification settings

remotebase/meteor-auth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

author
Sung Won Cho
Jun 5, 2016
7284f7f · Jun 5, 2016

History

9 Commits
Jun 5, 2016
Mar 28, 2016
Jun 5, 2016
Mar 28, 2016
Mar 28, 2016
Mar 28, 2016
Mar 28, 2016
Mar 28, 2016
Jun 5, 2016
Jun 5, 2016
Jun 5, 2016
Jun 5, 2016

Repository files navigation

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

About

A user authentication solution for Mantra applications

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published