Add optional userInfo param to registerWithProvider (#915)
* Add optional userInfo param to registerWithProvider * Fixes per PR comments
This commit is contained in:
parent
6845157580
commit
94f8d5a891
11
docs/sync.js
11
docs/sync.js
|
@ -1,3 +1,4 @@
|
||||||
|
import {stringify} from 'ini';
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Copyright 2016 Realm Inc.
|
// Copyright 2016 Realm Inc.
|
||||||
|
@ -139,15 +140,17 @@ class User {
|
||||||
static login(server, username, password, callback) {}
|
static login(server, username, password, callback) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Login a sync user using an external login provider.
|
* Register/login a sync user using an external login provider.
|
||||||
* @param {string} server - authentication server
|
* @param {string} server - authentication server
|
||||||
* @param {string} provider - The provider type
|
* @param {object} options - options, containing the following:
|
||||||
* @param {string} providerToken - The access token for the given provider
|
* @param {string} options.provider - The provider type
|
||||||
|
* @param {string} options.providerToken - The access token for the given provider
|
||||||
|
* @param {object} [options.userInfo] - A map containing additional data required by the provider
|
||||||
* @param {function(error, User)} callback - called with the following arguments:
|
* @param {function(error, User)} callback - called with the following arguments:
|
||||||
* - `error` - an Error object is provided on failure
|
* - `error` - an Error object is provided on failure
|
||||||
* - `user` - a valid User object on success
|
* - `user` - a valid User object on success
|
||||||
*/
|
*/
|
||||||
static registerWithProvider(server, provider, providerToken, callback) {}
|
static registerWithProvider(server, options, callback) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a sync user with username and password.
|
* Register a sync user with username and password.
|
||||||
|
|
|
@ -157,11 +157,28 @@ module.exports = {
|
||||||
}, callback);
|
}, callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
registerWithProvider(server, provider, providerToken, callback) {
|
registerWithProvider(server, options, callback) {
|
||||||
_authenticate(this, server, {
|
|
||||||
provider: provider,
|
// Compatibility with previous signature:
|
||||||
data: providerToken
|
// registerWithProvider(server, provider, providerToken, callback)
|
||||||
}, callback);
|
if (arguments.length === 4) {
|
||||||
|
options = {
|
||||||
|
provider: arguments[1],
|
||||||
|
providerToken: arguments[2]
|
||||||
|
};
|
||||||
|
callback = arguments[3];
|
||||||
|
}
|
||||||
|
|
||||||
|
let reqOptions = {
|
||||||
|
provider: options.provider,
|
||||||
|
data: options.providerToken,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (options.userInfo) {
|
||||||
|
reqOptions.user_info = options.userInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
_authenticate(this, server, reqOptions, callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
_refreshAccessToken: refreshAccessToken
|
_refreshAccessToken: refreshAccessToken
|
||||||
|
|
Loading…
Reference in New Issue