Git Product home page Git Product logo

meteor-ddp-login's Introduction

ddp-login

meteor add ongoworks:ddp-login

Meteor package that allows you to securely log in to a non-primary DDP connection from a browser or another server using password authentication.

In the Meteor app that needs to connect to another Meteor app, in either client code or server code, do something like the following:

// Get the connection
var conn = DDP.connect(Meteor.absoluteUrl());

// Pass the connection to `DDP.loginWithPassword`, which is otherwise similar to
// the core `Meteor.loginWithPassword` method.
DDP.loginWithPassword(conn, {username: 'admin'}, 'admin', function (error) {
	if (!error) {
	  console.log("Logged in!");
	  conn.call('methodTheRequiresBeingLoggedIn', function () {
	    console.log(arguments);
	  });
	} else {
	  console.log(error);
	}
});

On the server, you can also log in synchronously by omitting the callback argument.

NOTE: There is code to handle both pre-0.8.2 Meteor and 0.8.2+ Meteor. However, there are some caveats:

  • You can only connect from a pre-0.8.2 app to another pre-0.8.2 app, or from a 0.8.2+ app to another 0.8.2+ app. This is due to the way Meteor implemented the login method change.
  • If you try to add the latest commit of ddp-login as a package in a pre-0.8.2 app, it will not work. Even though the code is backwards compatible, the package.js file has an api.use call for sha, which did not exist before 0.8.2. So you will have to remove that package dependency, or just use an older commit of ddp-login.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.