0.1.2 • Published 4 years ago

meteor-become v0.1.2

Weekly downloads
3
License
ISC
Repository
github
Last release
4 years ago

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)

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0-rc3

4 years ago

0.1.0-rc1

4 years ago

0.1.0-rc2

4 years ago

0.1.0

4 years ago