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.
|
||||
|
@ -139,15 +140,17 @@ class User {
|
|||
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} provider - The provider type
|
||||
* @param {string} providerToken - The access token for the given provider
|
||||
* @param {object} options - options, containing the following:
|
||||
* @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:
|
||||
* - `error` - an Error object is provided on failure
|
||||
* - `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.
|
||||
|
|
|
@ -157,11 +157,28 @@ module.exports = {
|
|||
}, callback);
|
||||
},
|
||||
|
||||
registerWithProvider(server, provider, providerToken, callback) {
|
||||
_authenticate(this, server, {
|
||||
provider: provider,
|
||||
data: providerToken
|
||||
}, callback);
|
||||
registerWithProvider(server, options, callback) {
|
||||
|
||||
// Compatibility with previous signature:
|
||||
// registerWithProvider(server, provider, providerToken, 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
|
||||
|
|
Loading…
Reference in New Issue