meteor-become
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -1,2 +0,2 @@ | ||
[meteor-become](../README.md) › [Globals](../globals.md) › ["become"](_become_.md) › ["meteor/tracker"](_become_._meteor_tracker_.md) | ||
[meteor-become](../README.md) › ["become"](_become_.md) › ["meteor/tracker"](_become_._meteor_tracker_.md) | ||
@@ -3,0 +3,0 @@ # Module: "meteor/tracker" |
@@ -1,2 +0,2 @@ | ||
[meteor-become](../README.md) › [Globals](../globals.md) › ["become"](_become_.md) › ["meteor/tracker"](_become_._meteor_tracker_.md) › [Tracker](_become_._meteor_tracker_.tracker.md) | ||
[meteor-become](../README.md) › ["become"](_become_.md) › ["meteor/tracker"](_become_._meteor_tracker_.md) › [Tracker](_become_._meteor_tracker_.tracker.md) | ||
@@ -17,3 +17,3 @@ # Module: Tracker | ||
*Defined in [become.ts:17](https://github.com/epfl-idevelop/meteor-become/blob/rewrite/as-npm-package/become.ts#L17)* | ||
*Defined in [become.ts:17](https://github.com/epfl-idevelop/meteor-become/blob/master/become.ts#L17)* | ||
@@ -20,0 +20,0 @@ **Type parameters:** |
@@ -1,2 +0,2 @@ | ||
[meteor-become](../README.md) › [Globals](../globals.md) › ["become"](_become_.md) | ||
[meteor-become](../README.md) › ["become"](_become_.md) | ||
@@ -37,3 +37,3 @@ # External module: "become" | ||
*Defined in [become.ts:35](https://github.com/epfl-idevelop/meteor-become/blob/rewrite/as-npm-package/become.ts#L35)* | ||
*Defined in [become.ts:35](https://github.com/epfl-idevelop/meteor-become/blob/master/become.ts#L35)* | ||
@@ -57,3 +57,3 @@ #### Type declaration: | ||
*Defined in [become.ts:12](https://github.com/epfl-idevelop/meteor-become/blob/rewrite/as-npm-package/become.ts#L12)* | ||
*Defined in [become.ts:12](https://github.com/epfl-idevelop/meteor-become/blob/master/become.ts#L12)* | ||
@@ -66,3 +66,3 @@ ___ | ||
*Defined in [become.ts:11](https://github.com/epfl-idevelop/meteor-become/blob/rewrite/as-npm-package/become.ts#L11)* | ||
*Defined in [become.ts:11](https://github.com/epfl-idevelop/meteor-become/blob/master/become.ts#L11)* | ||
@@ -75,3 +75,3 @@ ___ | ||
*Defined in [become.ts:13](https://github.com/epfl-idevelop/meteor-become/blob/rewrite/as-npm-package/become.ts#L13)* | ||
*Defined in [become.ts:13](https://github.com/epfl-idevelop/meteor-become/blob/master/become.ts#L13)* | ||
@@ -84,3 +84,3 @@ ___ | ||
*Defined in [become.ts:9](https://github.com/epfl-idevelop/meteor-become/blob/rewrite/as-npm-package/become.ts#L9)* | ||
*Defined in [become.ts:9](https://github.com/epfl-idevelop/meteor-become/blob/master/become.ts#L9)* | ||
@@ -93,3 +93,3 @@ ## Functions | ||
*Defined in [become.ts:36](https://github.com/epfl-idevelop/meteor-become/blob/rewrite/as-npm-package/become.ts#L36)* | ||
*Defined in [become.ts:36](https://github.com/epfl-idevelop/meteor-become/blob/master/become.ts#L36)* | ||
@@ -111,3 +111,3 @@ **Parameters:** | ||
*Defined in [become.ts:38](https://github.com/epfl-idevelop/meteor-become/blob/rewrite/as-npm-package/become.ts#L38)* | ||
*Defined in [become.ts:38](https://github.com/epfl-idevelop/meteor-become/blob/master/become.ts#L38)* | ||
@@ -118,3 +118,3 @@ ### become | ||
*Defined in [become.ts:51](https://github.com/epfl-idevelop/meteor-become/blob/rewrite/as-npm-package/become.ts#L51)* | ||
*Defined in [become.ts:51](https://github.com/epfl-idevelop/meteor-become/blob/master/become.ts#L51)* | ||
@@ -140,3 +140,3 @@ Become another user. | ||
*Defined in [become.ts:108](https://github.com/epfl-idevelop/meteor-become/blob/rewrite/as-npm-package/become.ts#L108)* | ||
*Defined in [become.ts:108](https://github.com/epfl-idevelop/meteor-become/blob/master/become.ts#L108)* | ||
@@ -157,3 +157,3 @@ Set the policy. | ||
*Defined in [become.ts:73](https://github.com/epfl-idevelop/meteor-become/blob/rewrite/as-npm-package/become.ts#L73)* | ||
*Defined in [become.ts:73](https://github.com/epfl-idevelop/meteor-become/blob/master/become.ts#L73)* | ||
@@ -168,3 +168,3 @@ The user the client was originally logged in as. A reactive data source. | ||
*Defined in [become.ts:93](https://github.com/epfl-idevelop/meteor-become/blob/rewrite/as-npm-package/become.ts#L93)* | ||
*Defined in [become.ts:93](https://github.com/epfl-idevelop/meteor-become/blob/master/become.ts#L93)* | ||
@@ -194,3 +194,3 @@ Log out of the account one has become, and back to the main identity. | ||
*Defined in [become.ts:21](https://github.com/epfl-idevelop/meteor-become/blob/rewrite/as-npm-package/become.ts#L21)* | ||
*Defined in [become.ts:21](https://github.com/epfl-idevelop/meteor-become/blob/master/become.ts#L21)* | ||
@@ -201,3 +201,3 @@ ### get | ||
*Defined in [become.ts:22](https://github.com/epfl-idevelop/meteor-become/blob/rewrite/as-npm-package/become.ts#L22)* | ||
*Defined in [become.ts:22](https://github.com/epfl-idevelop/meteor-become/blob/master/become.ts#L22)* | ||
@@ -210,3 +210,3 @@ **Returns:** *string | null* | ||
*Defined in [become.ts:28](https://github.com/epfl-idevelop/meteor-become/blob/rewrite/as-npm-package/become.ts#L28)* | ||
*Defined in [become.ts:28](https://github.com/epfl-idevelop/meteor-become/blob/master/become.ts#L28)* | ||
@@ -219,3 +219,3 @@ **Returns:** *void* | ||
*Defined in [become.ts:25](https://github.com/epfl-idevelop/meteor-become/blob/rewrite/as-npm-package/become.ts#L25)* | ||
*Defined in [become.ts:25](https://github.com/epfl-idevelop/meteor-become/blob/master/become.ts#L25)* | ||
@@ -222,0 +222,0 @@ **Parameters:** |
@@ -1,46 +0,9 @@ | ||
[meteor-become](README.md) › [Globals](globals.md) | ||
[meteor-become](README.md) | ||
# meteor-become | ||
Allow a user of a Meteor application to act as another one. | ||
## Index | ||
# Example | ||
### External modules | ||
``` | ||
import { Become } from 'meteor/become' | ||
Become.policy(function(fromUserID, toUserID) { | ||
return Meteor.user.findOne({id: fromUserID}).isSuperUser; | ||
}); | ||
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 | ||
2. Server checks policy function (set with `Become.policy`) and returns success or error to client | ||
3. Upon success, Meteor.userId() etc. get updated on the client as is normal upon Meteor login | ||
4. 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](docs/modules/_become_.md#const-become) (available on client and server) | ||
* ["become"](modules/_become_.md) |
{ | ||
"name": "meteor-become", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Allow a user of a Meteor application to act as another one", | ||
@@ -9,3 +9,3 @@ "main": "lib/become.js", | ||
"build-js": "set -e -x; tsc ; sed -i '' -e 's_require(\"meteor/_require(\"meteor-package-import\")(\"_' lib/become.js", | ||
"build-docs": "set -e -x ; rm -rf docs ; typedoc --plugin typedoc-plugin-markdown --out docs *.ts; if [ -z \"$branch_name\" ]; then branch_name=\"$(git symbolic-ref --short -q HEAD 2>/dev/null || true)\"; fi; if [ -n \"$branch_name\" ]; then sed -i '' -e 's_/blob/[a-f0-9]\\{7,9\\}/_/blob/'\"$branch_name\"'/_' docs/modules/*.md; fi" | ||
"build-docs": "set -e -x ; rm -rf docs ; typedoc --plugin typedoc-plugin-markdown --readme none --out docs *.ts; if [ -z \"$branch_name\" ]; then branch_name=\"$(git symbolic-ref --short -q HEAD 2>/dev/null || true)\"; fi; if [ -n \"$branch_name\" ]; then sed -i '' -e 's_/blob/[a-f0-9]\\{7,9\\}/_/blob/'\"$branch_name\"'/_' docs/modules/*.md; fi" | ||
}, | ||
@@ -12,0 +12,0 @@ "repository": { |
@@ -6,6 +6,6 @@ Allow a user of a Meteor application to act as another one. | ||
``` | ||
import { Become } from 'meteor/become' | ||
import { Become } from 'meteor-become' | ||
Become.policy(function(fromUserID, toUserID) { | ||
return Meteor.user.findOne({id: fromUserID}).isSuperUser; | ||
Become.policy(function(fromUser, toUser) { | ||
return toUser.username.indexOf("quatrava") >= 0 | ||
}); | ||
@@ -44,2 +44,2 @@ | ||
Start with [the Become object](docs/modules/_become_.md#const-become) (available on client and server) | ||
Start with [the Become object](https://github.com/epfl-idevelop/meteor-become/blob/rewrite/as-npm-package/docs/modules/_become_.md#const-become) (available on client and server) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32677
13