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.

meteor-ddp-login's People

Contributors

aaronjudd avatar aldeed avatar jankapunkt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

meteor-ddp-login's Issues

How to get the logged in userId

Hello,
I am using this package to connect a client only Meteor app to a preexisting meteor server.

Once I login, how can I get the userId?

Currently on startup I do

Meteor.disconnect()
conn = DDP.connect(remoteServerURL)

conn.subscribe and stuff works

but conn.userId() and conn.user() does not work.

how can I get the userId() ? Do I just have to call a meteor function and have it return the userId for the logged in user?

Staying logged in across sections

Hi, nice useful package, thanks!

I wonder if it is possible to stay logged in after opening a new session.

Traditional Accounts section stores userid in localstorage. Do you have in mind to implement anything similar?

Re-login with every Method call?

from what I am gathering, in order to make any method calls to the server that uses the UserId I have to login with every call?

is there no way to keep the user logged in so the server can reference the user to make method calls with meteor user.

so confusing that it wouldn't work this way.

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.