开发者社区> 镜像站> NPM> @accounts/meteor-adapter
@accounts/meteor-adapter
MeteorJS wrapper for using AccountsJS with the original Meteor Accounts package
Last updated 3 years ago by davidyaha .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @accounts/meteor-adapter 
SYNC missed versions from official npm registry.

@accounts/meteor-adapter

JSAccounts adapter for MeteorJS: override and extends Meteor methods and publication with JSAccounts authentication.

Installing

Start by installing and adding to your Meteor project:

meteor npm install --save @accounts/meteor-adapter

Use in Meteor client-side

To use with Meteor client-side, use your AccountsClient instance and Meteor instance, and use this package on your Meteor's client-side entry point (usually client/main.js):

import { Meteor } from 'meteor/meteor';
import AccountsClient from '@accounts/client';
import { wrapMeteorClient } from '@accounts/meteor-adapter';

AccountsClient.config({}); // Config your accounts client

wrapMeteorClient(Meteor, AccountsClient);

Now, each time you call Meteor.call or Meteor.subscribe - the JSAccounts accessToken will be appended to your request, and your server will be able to validate it.

Use in Meteor server-side

To use with Meteor client-side, use your AccountsServer instance and Meteor instance, and use this package on your Meteor's client-side entry point (usually server/main.js):

import { Meteor } from 'meteor/meteor';
import AccountsServer from '@accounts/server';
import { wrapMeteorServer } from '@accounts/meteor-adapter';

AccountsServer.config({}); // Config your accounts server

wrapMeteorServer(Meteor, AccountsServer);

Meteor.startup(() => {
    // ...
});

Now, each time you call Meteor.methods or Meteor.publish - the JSAccounts accessToken will parsed and validated, and the user and userId will be available for use inside your callback, for example:

Meteor.publish('myPulication', function() {
    const user = this.user(); // JSAccounts user, or null if there is no user at all
    const userId = this.userId(); // JSAccounts user id, or null if there is no user at all
});

Meteor.methods({
    myFunc: function() {
        const user = this.user(); // JSAccounts user, or null if there is no user at all
        const userId = this.userId(); // JSAccounts user id, or null if there is no user at all
    }
});

Note that if there method is called without an authenticated use in the client side, the user and userId will return null values - so you should check it inside your method. If the user specified a token but it's not valid - the method/pulication will fail with the JSAccounts error.

Current Tags

  • 0.1.1-1                                ...           alpha (3 years ago)
  • 0.1.1                                ...           latest (3 years ago)

97 Versions

  • 0.1.1                                ...           3 years ago
  • 0.1.1-1                                ...           3 years ago
  • 0.1.1-0                                ...           3 years ago
  • 0.1.0                                ...           4 years ago
  • 0.0.21                                ...           4 years ago
  • 0.0.20                                ...           4 years ago
  • 0.0.20-alpha.1                                ...           4 years ago
  • 0.0.20-alpha.0                                ...           4 years ago
  • 0.0.11-alpha.0                                ...           4 years ago
  • 0.0.19                                ...           4 years ago
  • 0.0.18                                ...           4 years ago
  • 0.0.17                                ...           4 years ago
  • 0.0.16                                ...           4 years ago
  • 0.0.15                                ...           4 years ago
  • 0.0.14                                ...           4 years ago
  • 0.0.13                                ...           4 years ago
  • 0.0.12                                ...           4 years ago
  • 0.0.11                                ...           4 years ago
  • 0.0.10                                ...           4 years ago
  • 0.0.10-alpha.11                                ...           4 years ago
  • 0.0.10-alpha.10                                ...           4 years ago
  • 0.0.10-alpha.9                                ...           4 years ago
  • 0.0.10-alpha.8                                ...           4 years ago
  • 0.0.10-alpha.7                                ...           4 years ago
  • 0.0.10-alpha.6                                ...           4 years ago
  • 0.0.10-alpha.5                                ...           4 years ago
  • 0.0.10-alpha.4                                ...           4 years ago
  • 0.0.10-alpha.3                                ...           4 years ago
  • 0.0.10-alpha.2                                ...           4 years ago
  • 0.0.10-alpha.1                                ...           4 years ago
  • 0.0.10-alpha.0                                ...           4 years ago
  • 0.0.9                                ...           4 years ago
  • 0.0.8                                ...           4 years ago
  • 0.0.7                                ...           4 years ago
  • 0.0.6-alpha.75                                ...           4 years ago
  • 0.0.6-alpha.74                                ...           4 years ago
  • 0.0.6-alpha.73                                ...           4 years ago
  • 0.0.6-alpha.71                                ...           4 years ago
  • 0.0.6-alpha.70                                ...           4 years ago
  • 0.0.6-alpha.69                                ...           4 years ago
  • 0.0.6-alpha.68                                ...           4 years ago
  • 0.0.6-alpha.67                                ...           4 years ago
  • 0.0.6-alpha.66                                ...           4 years ago
  • 0.0.6-alpha.65                                ...           4 years ago
  • 0.0.6-alpha.64                                ...           4 years ago
  • 0.0.6-alpha.63                                ...           4 years ago
  • 0.0.6-alpha.62                                ...           4 years ago
  • 0.0.6-alpha.61                                ...           4 years ago
  • 0.0.6-alpha.60                                ...           4 years ago
  • 0.0.6-beta.0                                ...           4 years ago
  • 0.0.6-alpha.42                                ...           4 years ago
  • 0.0.6-alpha.41                                ...           4 years ago
  • 0.0.6-alpha.40                                ...           4 years ago
  • 0.0.6-alpha.39                                ...           4 years ago
  • 0.0.6-alpha.38                                ...           4 years ago
  • 0.0.6-alpha.37                                ...           4 years ago
  • 0.0.6-alpha.36                                ...           4 years ago
  • 0.0.6-alpha.35                                ...           4 years ago
  • 0.0.6-alpha.34                                ...           4 years ago
  • 0.0.6-alpha.33                                ...           4 years ago
  • 0.0.6-alpha.32                                ...           4 years ago
  • 0.0.6-alpha.31                                ...           4 years ago
  • 0.0.6-alpha.30                                ...           4 years ago
  • 0.0.6-alpha.29                                ...           4 years ago
  • 0.0.6-alpha.28                                ...           4 years ago
  • 0.0.6-alpha.27                                ...           4 years ago
  • 0.0.6-alpha.26                                ...           4 years ago
  • 0.0.6-alpha.25                                ...           4 years ago
  • 0.0.6-alpha.24                                ...           4 years ago
  • 0.0.6-alpha.23                                ...           4 years ago
  • 0.0.6-alpha.22                                ...           4 years ago
  • 0.0.6-alpha.21                                ...           4 years ago
  • 0.0.6-alpha.20                                ...           4 years ago
  • 0.0.6-alpha.19                                ...           4 years ago
  • 0.0.6-alpha.18                                ...           4 years ago
  • 0.0.6-alpha.17                                ...           4 years ago
  • 0.0.6-alpha.16                                ...           4 years ago
  • 0.0.6-alpha.15                                ...           4 years ago
  • 0.0.6-alpha.14                                ...           4 years ago
  • 0.0.6-alpha.13                                ...           4 years ago
  • 0.0.6-alpha.12                                ...           4 years ago
  • 0.0.6-alpha.11                                ...           4 years ago
  • 0.0.6-alpha.10                                ...           4 years ago
  • 0.0.6-alpha.9                                ...           4 years ago
  • 0.0.6-alpha.8                                ...           4 years ago
  • 0.0.6-alpha.7                                ...           4 years ago
  • 0.0.6-alpha.5                                ...           4 years ago
  • 0.0.6-alpha.4                                ...           4 years ago
  • 0.0.6-alpha.3                                ...           4 years ago
  • 0.0.6-alpha.2                                ...           4 years ago
  • 0.0.6-alpha.1                                ...           4 years ago
  • 0.0.6-alpha.0                                ...           4 years ago
  • 0.0.5                                ...           4 years ago
  • 0.0.4                                ...           4 years ago
  • 0.0.3                                ...           4 years ago
  • 0.0.2                                ...           4 years ago
  • 0.0.1                                ...           4 years ago
Downloads
Today 0
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 291
Dependencies (1)
Dependents (0)
None