meteor-become
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

Allow a user of a Meteor application to act as another one.

Example

import { Become } from 'meteor-become'

Become.policy(function(fromUser, toUser) {
    return toUser.username.indexOf("quatrava") >= 0
});

if (Meteor.isClient) {
    Template.MyBecomeUserForm.events({
        "submit": function(event, target) {
            Become.become(anotherUserID);
            event.stopPropagation();
        }
    });
}

How It Works

  1. Client code calls Become.become()
  2. Become.become() saves the current session token and calls the Meteor login function
  3. Server checks policy function (set with Become.policy) and returns success or error to client
  4. Upon success, Meteor.userId() etc. get updated on the client as is normal upon Meteor login
  5. Client may now call Become.restore() to restore the previous session token and reconnect

Dependencies

This code only works if called from a Meteor application. Furthermore, the following Meteor core packages are required (add them with meteor add if needed):

  • promise
  • session
  • tracker

API Reference

Start with the Become object (available on client and server)

Readme

Keywords

Package Sidebar

Install

npm i meteor-become

Weekly Downloads

2

Version

0.1.2

License

ISC

Unpacked Size

68.7 kB

Total Files

13

Last publish

Collaborators

  • domq