Add support for getting user id

For #1090
This commit is contained in:
blagoev 2017-07-03 16:55:18 +03:00
parent 95da5a29f0
commit 42e03e038d
2 changed files with 27 additions and 3 deletions

View File

@ -35,7 +35,8 @@ export default class User {
createMethods(User.prototype, objectTypes.USER, [
'logout',
'_sessionForOnDiskPath'
'_sessionForOnDiskPath',
'retrieveAccount'
]);
export function createUser(realmId, info) {

View File

@ -229,6 +229,29 @@ module.exports = {
url: url.href
}
});
}
}
},
retrieveAccount(provider, provider_id) {
checkTypes(arguments, ['string', 'string']);
let url = url_parse(this.server);
url.set('pathname', `/api/providers/${provider}/accounts/${provider_id}`);
let headers = {
Authorization : this.token
};
const options = {
method: 'GET',
headers: headers,
open_timeout: 5000
};
return performFetch(url.href, options)
.then((response) => {
if (response.status !== 200) {
return response.json().then((body) => callback(new AuthError(body)));
} else {
return response.json();
}
});
},
},
};