accounts is a simple User Management module for Node.js.
Current version supports logins only with providers(Google, Yahoo, Facebook, etc.).
All you need to do is to create an application, and then use appId for managing users.
var Accounts = require('accounts')(storage, options);
var appId;
Accounts.apps.create({
name: 'Test app'
}).then(function(app) {
appId = app.id;
});
var Accounts = require('accounts')(storage);
var appId = process.env.ACCOUNTS_APP_ID;
var App = Accounts.app(appId);
App.login('social', profile)
.then(function(user) {
if (user) {
console.log(user);
}
else {
console.log('login faild');
}
});
Where Profile
is a Passport User Profile
var profile = {
provider: 'facebook',
id: '123124234235123',
displayName: 'Dumitru K',
accessData: {
accessToken:'dsgsgs', refreshToken:'gerge'
}
};
Creates a new Client.
- sync() - Syncronize DB tables.
- drop(secret) - Drop DB tables. Useful for tests.
- create(data) - Create a new application.
- getById(id) - Get an application by id.
Creates a new Application Client for a given app id.
- create(data, options) - Create a new user.
- getById(id, options) - Get an user object by id.
- update(data, options) - Update user fields.
- deleteById(id, options) - Delete an user by id.
- create(data, options) - Create a new identity.
- getById(id, options) - Get an user identity by id.
- findByUserId(userId, options) - Find user identities by user id.
- update(data, options) - Update an identity.
- deleteById(id, options) - Delete an user identity by id.
- deleteByUserId(userId, options) - Delete user identities by user id.
- DynamoDB: dynamo-accounts;
- MongoDB: mongo-accounts;