From be98a77fcf09f43d4faa68cacf24c784a8a87601 Mon Sep 17 00:00:00 2001 From: Kenneth Geisshirt Date: Mon, 24 Sep 2018 12:43:44 +0200 Subject: [PATCH] Logging in using an admin token should be synchronous (#2040) * Logging in using an admin token should be synchronous --- CHANGELOG.md | 9 ++++----- lib/user-methods.js | 2 +- tests/js/user-tests.js | 10 +++------- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 894dff63..8a84230e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,14 +4,13 @@ x.x.x Release notes (yyyy-MM-dd) * None ### Fixes -* ([#????](https://github.com/realm/realm-js/issues/????), since v?.?.?) -* None +* Fixed a bug where logging in using an admin token returned a promise. The correct behavior is to be synchronous. (related to [#2037](https://github.com/realm/realm-js/issues/2037), since v2.16.1) ### Compatibility * File format: ver. 7 (upgrades automatically from previous formats) -* Realm Object Server: 3.11.0 or later. +* Realm Object Server: 3.0.0 or later. * APIs are backwards compatible with all previous release of realm in the 2.x.y series. - + ### Internal * None @@ -25,7 +24,7 @@ x.x.x Release notes (yyyy-MM-dd) ### Compatibility * File format: ver. 7 (upgrades automatically from previous formats) -* Realm Object Server: 3.11.0 or later. +* Realm Object Server: 3.0.0 or later. * APIs are backwards compatible with all previous release of realm in the 2.x.y series. ### Internal diff --git a/lib/user-methods.js b/lib/user-methods.js index 6fa550b6..b26d96e6 100644 --- a/lib/user-methods.js +++ b/lib/user-methods.js @@ -382,7 +382,7 @@ const staticMethods = { checkTypes(arguments, ['string', 'object']); if (credentials.identityProvider === 'adminToken') { let u = this._adminUser(server, credentials.token); - return Promise.resolve(u); + return u; } return _authenticate(this, server, credentials); diff --git a/tests/js/user-tests.js b/tests/js/user-tests.js index 93a7952e..b2644f4b 100644 --- a/tests/js/user-tests.js +++ b/tests/js/user-tests.js @@ -29,7 +29,7 @@ function node_require(module) { return require_method(module); } - let fs; +let fs; if (isNodeProcess) { fs = node_require('fs'); } @@ -206,12 +206,8 @@ module.exports = { let token = obj['ADMIN_TOKEN']; let credentials = Realm.Sync.Credentials.adminToken(token); - return Realm.Sync.User.login('http://localhost:9080', credentials) - .then((user) => { - TestCase.assertTrue(user.isAdmin); - Promise.resolve(); - }) - .catch((e) => { Promise.reject(e) } ); + let user = Realm.Sync.User.login('http://localhost:9080', credentials); + TestCase.assertTrue(user.isAdmin); }, testAll() {