diff --git a/CHANGELOG.md b/CHANGELOG.md index cd13bc5668..2c680b650f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ NOTE: This version bumps the Realm file format to version 11. It is not possible * `Realm.Auth.UserAPIKeyProvider` has been replaced by `Realm.Auth.ApiKeyProvider`. * `user.auth.apiKeys` has been replaced by `user.apiKeys`. * The instance methods on the ApiKeyAuth instance (`user.apiKeys`) have gotten their APIKey(s) suffix removed: Ex. `apiKeys.createAPIKey` has been replaced by `apiKeys.create`. +* `Realm.Auth.EmailPasswordProvider` has been replaced by `Realm.Auth.EmailPasswordAuth`. +* `app.auth.emailPassword` has been replaced by `user.emailPasswordAuth`. ### Enhancements * None. diff --git a/binding.gyp b/binding.gyp index 67cd533764..b78b824639 100644 --- a/binding.gyp +++ b/binding.gyp @@ -27,7 +27,7 @@ "src/js_app_credentials.hpp", "src/js_user.hpp", "src/js_network_transport.hpp", - "src/js_email_password_provider.hpp", + "src/js_email_password_auth.hpp", "src/node/sync_logger.cpp", "src/node/sync_logger.hpp", ] diff --git a/docs/sync.js b/docs/sync.js index 1820216004..cb9b9b510a 100644 --- a/docs/sync.js +++ b/docs/sync.js @@ -133,18 +133,18 @@ removeUser(user) { } /** - * Auth providers. Currently only `emailPassword` provider is support + * Client for the email/password authentication provider. * * @example * { - * let app = new Realm.App(config); - * let provider = app.auth.emailPassword; + * // Creating a new user, by registering via email & password + * const app = new Realm.App(config); + * await app.emailPasswordAuth.registerEmail('john@example.com', 'some-secure-password'); * } * - * @see Realm.Auth - * @see Realm.Auth.EmailPassword + * @type {Realm.Auth.EmailPasswordAuth} */ - get auth() { } + get emailPasswordAuth() { } } @@ -351,8 +351,8 @@ class Credentials { /** * A namespace for auth providers - * @see Realm.Auth.EmailPassword - * @see Realm.Auth.UserAPIKey + * @see Realm.Auth.EmailPasswordAuth + * @see Realm.Auth.ApiKeyAuth * @memberof Realm */ class Auth { @@ -363,7 +363,7 @@ class Auth { * Class for managing email/password for users * @memberof Realm.Auth */ -class EmailPassword { +class EmailPasswordAuth { /** * Registers a new email identity with the username/password provider, diff --git a/lib/app.js b/lib/app.js index 9540c2e713..c585fc19c8 100644 --- a/lib/app.js +++ b/lib/app.js @@ -28,17 +28,6 @@ const instanceMethods = { removeUser() { return promisify(cb => this._removeUser(cb)); }, - - get auth() { - const app = this; - return new Proxy({}, { - get(target, name) { - if (name === "emailPassword") { - return app._authEmailPassword; - } - } - }); - } }; const staticMethods = { diff --git a/lib/extensions.js b/lib/extensions.js index 6b8dc28f6a..1c5ea54cbe 100644 --- a/lib/extensions.js +++ b/lib/extensions.js @@ -16,11 +16,11 @@ // //////////////////////////////////////////////////////////////////////////// -'use strict'; +"use strict"; /* global navigator */ -const URL = require('url-parse'); +const URL = require("url-parse"); let getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors || function(obj) { return Object.getOwnPropertyNames(obj).reduce(function (descriptors, name) { @@ -31,7 +31,7 @@ let getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors || function(obj function setConstructorOnPrototype(klass) { if (klass.prototype.constructor !== klass) { - Object.defineProperty(klass.prototype, 'constructor', { value: klass, configurable: true, writable: true }); + Object.defineProperty(klass.prototype, "constructor", { value: klass, configurable: true, writable: true }); } } @@ -67,17 +67,17 @@ function openLocalRealm(realmConstructor, config) { module.exports = function(realmConstructor, context) { // Add the specified Array methods to the Collection prototype. - Object.defineProperties(realmConstructor.Collection.prototype, require('./collection-methods')); + Object.defineProperties(realmConstructor.Collection.prototype, require("./collection-methods")); setConstructorOnPrototype(realmConstructor.Collection); setConstructorOnPrototype(realmConstructor.List); setConstructorOnPrototype(realmConstructor.Results); setConstructorOnPrototype(realmConstructor.Object); - realmConstructor._bson = require('bson'); + realmConstructor._bson = require("bson"); realmConstructor._Decimal128 = realmConstructor._bson.Decimal128; realmConstructor._ObjectId = realmConstructor._bson.ObjectId; - const { DefaultNetworkTransport } = require('realm-network-transport'); + const { DefaultNetworkTransport } = require("realm-network-transport"); realmConstructor._networkTransport = new DefaultNetworkTransport(); Object.defineProperty(realmConstructor.Object.prototype, "toJSON", { @@ -139,10 +139,10 @@ module.exports = function(realmConstructor, context) { if (config.sync[behavior] !== undefined) { const type = config.sync[behavior].type; switch (type) { - case 'downloadBeforeOpen': + case "downloadBeforeOpen": openLocalRealmImmediately = false; break; - case 'openImmediately': + case "openImmediately": openLocalRealmImmediately = true; break; default: @@ -162,7 +162,7 @@ module.exports = function(realmConstructor, context) { let openPromises = []; if (config.sync[behavior] !== undefined && config.sync[behavior].timeOut !== undefined) { let timeOut = config.sync[behavior].timeOut; - if (typeof timeOut !== 'number') { + if (typeof timeOut !== "number") { throw new Error(`'timeOut' must be a number: '${timeOut}'`); } @@ -171,10 +171,10 @@ module.exports = function(realmConstructor, context) { if (config.sync[behavior] !== undefined && config.sync[behavior].timeOutBehavior) { const timeOutBehavior = config.sync[behavior].timeOutBehavior; switch (timeOutBehavior) { - case 'throwException': + case "throwException": throwOnTimeOut = true; break; - case 'openLocal': + case "openLocal": throwOnTimeOut = false; break; default: @@ -241,7 +241,7 @@ module.exports = function(realmConstructor, context) { for (let key in objectSchema.properties) { let type; - if (typeof objectSchema.properties[key] === 'string' || objectSchema.properties[key] instanceof String) { + if (typeof objectSchema.properties[key] === "string" || objectSchema.properties[key] instanceof String) { // Simple declaration of the type type = objectSchema.properties[key]; } else { @@ -265,13 +265,13 @@ module.exports = function(realmConstructor, context) { // Set the default value for all required primitive types. // Lists are always treated as empty if not specified and references to objects are always optional switch (type) { - case 'bool': obj[key] = false; break; - case 'int': obj[key] = 0; break; - case 'float': obj[key] = 0.0; break; - case 'double': obj[key] = 0.0; break; - case 'string': obj[key] = ""; break; - case 'data': obj[key] = new ArrayBuffer(0); break; - case 'date': obj[key] = new Date(0); break; + case "bool": obj[key] = false; break; + case "int": obj[key] = 0; break; + case "float": obj[key] = 0.0; break; + case "double": obj[key] = 0.0; break; + case "string": obj[key] = ""; break; + case "data": obj[key] = new ArrayBuffer(0); break; + case "date": obj[key] = new Date(0); break; } } return obj; @@ -287,7 +287,7 @@ module.exports = function(realmConstructor, context) { schemas.forEach(schema => { // a schema must be an object and have 'name' and 'properties' // we let object store's schema parser produce the error messages - if (!(schema instanceof Object) || !schema.hasOwnProperty('name') || !schema.hasOwnProperty('properties')) { + if (!(schema instanceof Object) || !schema.hasOwnProperty("name") || !schema.hasOwnProperty("properties")) { newSchema.push(schema); return; } @@ -314,13 +314,13 @@ module.exports = function(realmConstructor, context) { os.properties = {}; for (let key in schema.properties) { let prop = schema.properties[key]; - if (prop instanceof Object && prop.hasOwnProperty('name') && prop.hasOwnProperty('properties')) { + if (prop instanceof Object && prop.hasOwnProperty("name") && prop.hasOwnProperty("properties")) { let embeddedSchema = {}; embeddedSchema.name = prop.name; embeddedSchema.embedded = true; embeddedSchema.properties = prop.properties; - if (prop.hasOwnProperty('type') && prop.type === 'list') { - os.properties[key] = { type: 'list', objectType: prop.name }; + if (prop.hasOwnProperty("type") && prop.type === "list") { + os.properties[key] = { type: "list", objectType: prop.name }; } else { os.properties[key] = { type: prop.name }; } @@ -338,13 +338,13 @@ module.exports = function(realmConstructor, context) { // Add static properties to Realm Object const updateModeType = { - All: 'all', - Modified: 'modified', - Never: 'never', + All: "all", + Modified: "modified", + Never: "never", }; if (!realmConstructor.UpdateMode) { - Object.defineProperty(realmConstructor, 'UpdateMode', { + Object.defineProperty(realmConstructor, "UpdateMode", { value: updateModeType, configurable: false, }); @@ -363,8 +363,8 @@ module.exports = function(realmConstructor, context) { let credentialMethods = require("./credentials"); Object.defineProperties(realmConstructor.Credentials, getOwnPropertyDescriptors(credentialMethods.static)) - let emailPasswordProviderMethods = require("./email_password_provider_client_methods"); - Object.defineProperties(realmConstructor.Auth.EmailPasswordProvider.prototype, getOwnPropertyDescriptors(emailPasswordProviderMethods.instance)); + let emailPasswordAuthMethods = require("./email_password_provider_client_methods"); + Object.defineProperties(realmConstructor.Auth.EmailPasswordAuth.prototype, getOwnPropertyDescriptors(emailPasswordAuthMethods.instance)); let apiKeyAuthMethods = require("./user_apikey_provider_client"); Object.defineProperties(realmConstructor.Auth.ApiKeyAuth.prototype, getOwnPropertyDescriptors(apiKeyAuthMethods.instance)); @@ -393,13 +393,13 @@ module.exports = function(realmConstructor, context) { realmConstructor.Sync.openLocalRealmBehavior = { - type: 'openImmediately' + type: "openImmediately" }; realmConstructor.Sync.downloadBeforeOpenBehavior = { - type: 'downloadBeforeOpen', + type: "downloadBeforeOpen", timeOut: 30 * 1000, - timeOutBehavior: 'throwException' + timeOutBehavior: "throwException" }; realmConstructor.Sync.Session.prototype.uploadAllLocalChanges = function(timeout) { return waitForCompletion(this, this._waitForUploadCompletion, timeout, `Uploading changes did not complete in ${timeout} ms.`); @@ -416,9 +416,9 @@ module.exports = function(realmConstructor, context) { }; realmConstructor.Sync.ClientResyncMode = { - Discard: 'discard', - Manual: 'manual', - Recover: 'recover' + Discard: "discard", + Manual: "manual", + Recover: "recover" }; Object.defineProperties(realmConstructor, getOwnPropertyDescriptors({ @@ -429,10 +429,10 @@ module.exports = function(realmConstructor, context) { // Credit: https://stackoverflow.com/questions/39468022/how-do-i-know-if-my-code-is-running-as-react-native try { var userAgent = "RealmJS/"; - userAgent = userAgent + require('../package.json').version + " (" + context + ", "; - if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') { + userAgent = userAgent + require("../package.json").version + " (" + context + ", "; + if (typeof navigator !== "undefined" && navigator.product === "ReactNative") { // Running on ReactNative - const Platform = require('react-native').Platform; + const Platform = require("react-native").Platform; userAgent += Platform.OS + ", v" + Platform.Version; } else { // Running on a normal machine @@ -448,23 +448,23 @@ module.exports = function(realmConstructor, context) { // TODO: Remove this now useless object. var types = Object.freeze({ - 'BOOL': 'bool', - 'INT': 'int', - 'FLOAT': 'float', - 'DOUBLE': 'double', - 'STRING': 'string', - 'DATE': 'date', - 'DATA': 'data', - 'OBJECT': 'object', - 'LIST': 'list', + "BOOL": "bool", + "INT": "int", + "FLOAT": "float", + "DOUBLE": "double", + "STRING": "string", + "DATE": "date", + "DATA": "data", + "OBJECT": "object", + "LIST": "list", }); - Object.defineProperty(realmConstructor, 'Types', { + Object.defineProperty(realmConstructor, "Types", { get: function() { - if (typeof console != 'undefined') { + if (typeof console != "undefined") { /* global console */ /* eslint-disable no-console */ var stack = new Error().stack.split("\n").slice(2).join("\n"); - var msg = '`Realm.Types` is deprecated! Please specify the type name as lowercase string instead!\n'+stack; + var msg = "`Realm.Types` is deprecated! Please specify the type name as lowercase string instead!\n"+stack; if (console.warn != undefined) { console.warn(msg); } diff --git a/src/RealmJS.xcodeproj/project.pbxproj b/src/RealmJS.xcodeproj/project.pbxproj index 17e39b5e15..fb9fe63fe2 100644 --- a/src/RealmJS.xcodeproj/project.pbxproj +++ b/src/RealmJS.xcodeproj/project.pbxproj @@ -185,7 +185,7 @@ 3FCE2A991F58BE3600D4855B /* feature_checks.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = feature_checks.hpp; path = "object-store/src/feature_checks.hpp"; sourceTree = SOURCE_ROOT; }; 42BD57A824640A94008679D5 /* js_app.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = js_app.hpp; sourceTree = ""; }; 42BD57A924640A94008679D5 /* js_app_credentials.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = js_app_credentials.hpp; sourceTree = ""; }; - 42BD57AA24640A94008679D5 /* js_email_password_provider.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = js_email_password_provider.hpp; sourceTree = ""; }; + 42BD57AA24640A94008679D5 /* js_email_password_auth.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = js_email_password_auth.hpp; sourceTree = ""; }; 42BD57AB24640A94008679D5 /* js_user.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = js_user.hpp; sourceTree = ""; }; 42BD57AC24640A94008679D5 /* js_network_transport.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = js_network_transport.hpp; sourceTree = ""; }; 42BD57AD24640A95008679D5 /* js_sync_util.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = js_sync_util.hpp; sourceTree = ""; }; @@ -362,7 +362,7 @@ 42BD57AD24640A95008679D5 /* js_sync_util.hpp */, 42BD57AE24640A95008679D5 /* js_api_key_auth.hpp */, 42BD57AB24640A94008679D5 /* js_user.hpp */, - 42BD57AA24640A94008679D5 /* js_email_password_provider.hpp */, + 42BD57AA24640A94008679D5 /* js_email_password_auth.hpp */, F62A35131C18E6E2004A917D /* iOS */, F6874A441CAD2ACD00EEEE36 /* JSC */, F6BCCFDF1C83809A00FE31AE /* lib */, diff --git a/src/js_app.hpp b/src/js_app.hpp index 0f23769f64..e0ef666d5f 100644 --- a/src/js_app.hpp +++ b/src/js_app.hpp @@ -29,7 +29,7 @@ #include "js_user.hpp" #include "js_app_credentials.hpp" #include "js_network_transport.hpp" -#include "js_email_password_provider.hpp" +#include "js_email_password_auth.hpp" using SharedApp = std::shared_ptr; using SharedUser = std::shared_ptr; @@ -60,11 +60,11 @@ class AppClass : public ClassDefinition { static FunctionType create_constructor(ContextType); static void get_app_id(ContextType, ObjectType, ReturnValue &); - static void get_auth_email_password(ContextType, ObjectType, ReturnValue &); + static void get_email_password_auth(ContextType, ObjectType, ReturnValue &); PropertyMap const properties = { {"id", {wrap, nullptr}}, - {"_authEmailPassword", {wrap, nullptr}}, + {"emailPasswordAuth", {wrap, nullptr}}, }; static void login(ContextType, ObjectType, Arguments&, ReturnValue&); @@ -296,9 +296,9 @@ void AppClass::remove_user(ContextType ctx, ObjectType this_object, Arguments } template -void AppClass::get_auth_email_password(ContextType ctx, ObjectType this_object, ReturnValue &return_value) { +void AppClass::get_email_password_auth(ContextType ctx, ObjectType this_object, ReturnValue &return_value) { auto app = *get_internal>(ctx, this_object); - return_value.set(EmailPasswordProviderClientClass::create_instance(ctx, app)); + return_value.set(EmailPasswordAuthClass::create_instance(ctx, app)); } } diff --git a/src/js_email_password_provider.hpp b/src/js_email_password_auth.hpp similarity index 68% rename from src/js_email_password_provider.hpp rename to src/js_email_password_auth.hpp index f3931d6279..09ab7a303e 100644 --- a/src/js_email_password_provider.hpp +++ b/src/js_email_password_auth.hpp @@ -27,7 +27,7 @@ namespace realm { namespace js { template -class EmailPasswordProviderClientClass : public ClassDefinition { +class EmailPasswordAuthClass : public ClassDefinition { using GlobalContextType = typename T::GlobalContext; using ContextType = typename T::Context; using FunctionType = typename T::Function; @@ -41,7 +41,7 @@ class EmailPasswordProviderClientClass : public ClassDefinition; public: - std::string const name = "EmailPasswordProviderClient"; + std::string const name = "EmailPasswordAuth"; static FunctionType create_constructor(ContextType); static ObjectType create_instance(ContextType, SharedApp); @@ -65,21 +65,21 @@ class EmailPasswordProviderClientClass : public ClassDefinition -inline typename T::Function EmailPasswordProviderClientClass::create_constructor(ContextType ctx) { - FunctionType constructor = ObjectWrap>::create_constructor(ctx); +inline typename T::Function EmailPasswordAuthClass::create_constructor(ContextType ctx) { + FunctionType constructor = ObjectWrap>::create_constructor(ctx); return constructor; } template -typename T::Object EmailPasswordProviderClientClass::create_instance(ContextType ctx, SharedApp app) { - return create_object>(ctx, new app::App::UsernamePasswordProviderClient(app->provider_client())); +typename T::Object EmailPasswordAuthClass::create_instance(ContextType ctx, SharedApp app) { + return create_object>(ctx, new app::App::UsernamePasswordProviderClient(app->provider_client())); } template -void EmailPasswordProviderClientClass::register_email(ContextType ctx, ObjectType this_object, Arguments& args, ReturnValue& return_value) { +void EmailPasswordAuthClass::register_email(ContextType ctx, ObjectType this_object, Arguments& args, ReturnValue& return_value) { args.validate_count(3); - auto& client = *get_internal>(ctx, this_object); + auto& client = *get_internal>(ctx, this_object); auto email = Value::validated_to_string(ctx, args[0], "email"); auto password = Value::validated_to_string(ctx, args[1], "password"); @@ -89,10 +89,10 @@ void EmailPasswordProviderClientClass::register_email(ContextType ctx, Object } template -void EmailPasswordProviderClientClass::confirm_user(ContextType ctx, ObjectType this_object, Arguments& args, ReturnValue& return_value) { +void EmailPasswordAuthClass::confirm_user(ContextType ctx, ObjectType this_object, Arguments& args, ReturnValue& return_value) { args.validate_count(3); - auto& client = *get_internal>(ctx, this_object); + auto& client = *get_internal>(ctx, this_object); auto token = Value::validated_to_string(ctx, args[0], "token"); auto token_id = Value::validated_to_string(ctx, args[1], "token_id"); @@ -102,10 +102,10 @@ void EmailPasswordProviderClientClass::confirm_user(ContextType ctx, ObjectTy } template -void EmailPasswordProviderClientClass::resend_confirmation_email(ContextType ctx, ObjectType this_object, Arguments& args, ReturnValue& return_value) { +void EmailPasswordAuthClass::resend_confirmation_email(ContextType ctx, ObjectType this_object, Arguments& args, ReturnValue& return_value) { args.validate_count(2); - auto& client = *get_internal>(ctx, this_object); + auto& client = *get_internal>(ctx, this_object); auto email = Value::validated_to_string(ctx, args[0], "email"); auto callback = Value::validated_to_function(ctx, args[1], "callback"); @@ -114,10 +114,10 @@ void EmailPasswordProviderClientClass::resend_confirmation_email(ContextType } template -void EmailPasswordProviderClientClass::send_reset_password_email(ContextType ctx, ObjectType this_object, Arguments& args, ReturnValue& return_value) { +void EmailPasswordAuthClass::send_reset_password_email(ContextType ctx, ObjectType this_object, Arguments& args, ReturnValue& return_value) { args.validate_count(2); - auto& client = *get_internal>(ctx, this_object); + auto& client = *get_internal>(ctx, this_object); auto email = Value::validated_to_string(ctx, args[0], "email"); auto callback = Value::validated_to_function(ctx, args[1], "callback"); @@ -126,10 +126,10 @@ void EmailPasswordProviderClientClass::send_reset_password_email(ContextType } template -void EmailPasswordProviderClientClass::reset_password(ContextType ctx, ObjectType this_object, Arguments& args, ReturnValue& return_value) { +void EmailPasswordAuthClass::reset_password(ContextType ctx, ObjectType this_object, Arguments& args, ReturnValue& return_value) { args.validate_count(4); - auto& client = *get_internal>(ctx, this_object); + auto& client = *get_internal>(ctx, this_object); auto password = Value::validated_to_string(ctx, args[0], "password"); auto token = Value::validated_to_string(ctx, args[1], "token"); diff --git a/src/js_realm.hpp b/src/js_realm.hpp index f891080ac2..06bd7c1e13 100644 --- a/src/js_realm.hpp +++ b/src/js_realm.hpp @@ -33,7 +33,7 @@ #include "js_app.hpp" #include "js_auth.hpp" #include "js_app_credentials.hpp" -#include "js_email_password_provider.hpp" +#include "js_email_password_auth.hpp" #include "js_api_key_auth.hpp" #include "sync/async_open_task.hpp" #include "sync/sync_config.hpp" @@ -467,8 +467,8 @@ inline typename T::Function RealmClass::create_constructor(ContextType ctx) { FunctionType auth_constructor = AuthClass::create_constructor(ctx); Object::set_property(ctx, realm_constructor, "Auth", auth_constructor, attributes); - FunctionType email_password_provider_client_constructor = EmailPasswordProviderClientClass::create_constructor(ctx); - Object::set_property(ctx, auth_constructor, "EmailPasswordProvider", email_password_provider_client_constructor, attributes); + FunctionType email_password_provider_client_constructor = EmailPasswordAuthClass::create_constructor(ctx); + Object::set_property(ctx, auth_constructor, "EmailPasswordAuth", email_password_provider_client_constructor, attributes); FunctionType user_apikey_provider_client_constructor = ApiKeyAuthClass::create_constructor(ctx); Object::set_property(ctx, auth_constructor, "ApiKeyAuth", user_apikey_provider_client_constructor, attributes); diff --git a/tests/js/user-tests.js b/tests/js/user-tests.js index e24a92579a..bdf07c53e5 100644 --- a/tests/js/user-tests.js +++ b/tests/js/user-tests.js @@ -91,7 +91,7 @@ function randomNonVerifiableEmail() { async function registerAndLogInEmailUser(app) { const validEmail = randomVerifiableEmail(); const validPassword = "test1234567890"; - await app.auth.emailPassword.registerEmail(validEmail, validPassword); + await app.emailPasswordAuth.registerEmail(validEmail, validPassword); let user = await app.logIn(Realm.Credentials.emailPassword(validEmail, validPassword)) assertIsUser(user); assertIsSameUser(user, app.currentUser()); @@ -140,10 +140,10 @@ module.exports = { }); }, - async testEmailPasswordProvider() { + async testEmailPasswordAuth() { let app = new Realm.App(appConfig); - let provider = app.auth.emailPassword; - TestCase.assertTrue(provider instanceof Realm.Auth.EmailPasswordProvider); + let provider = app.emailPasswordAuth; + TestCase.assertTrue(provider instanceof Realm.Auth.EmailPasswordAuth); }, async testRegisterAutoVerifyEmailPassword() { @@ -157,7 +157,7 @@ module.exports = { let credentials = Realm.Credentials.emailPassword(invalidEmail, invalidPassword); let err = await TestCase.assertThrowsAsync(async() => app.logIn(credentials)); TestCase.assertEqual(err.message, "invalid username/password"); // this user does not exist yet - err = await TestCase.assertThrowsAsync(async() => app.auth.emailPassword.registerEmail(invalidEmail, invalidPassword)); + err = await TestCase.assertThrowsAsync(async() => app.emailPasswordAuth.registerEmail(invalidEmail, invalidPassword)); TestCase.assertEqual(err.message, "password must be between 6 and 128 characters"); err = await TestCase.assertThrowsAsync(async() => app.logIn(credentials)); TestCase.assertEqual(err.message, "invalid username/password"); // this user did not register @@ -166,7 +166,7 @@ module.exports = { let credentials = Realm.Credentials.emailPassword(invalidEmail, validPassword); let err = await TestCase.assertThrowsAsync(async() => app.logIn(credentials)); TestCase.assertEqual(err.message, "invalid username/password"); // this user does not exist yet - err = await TestCase.assertThrowsAsync(async() => app.auth.emailPassword.registerEmail(invalidEmail, validPassword)); + err = await TestCase.assertThrowsAsync(async() => app.emailPasswordAuth.registerEmail(invalidEmail, validPassword)); TestCase.assertEqual(err.message, `failed to confirm user ${invalidEmail}`); err = await TestCase.assertThrowsAsync(async() => app.logIn(credentials)); TestCase.assertEqual(err.message, "invalid username/password"); // this user did not register @@ -175,7 +175,7 @@ module.exports = { let credentials = Realm.Credentials.emailPassword(validEmail, invalidPassword); let err = await TestCase.assertThrowsAsync(async() => app.logIn(credentials)); TestCase.assertEqual(err.message, "invalid username/password"); // this user does not exist yet - err = await TestCase.assertThrowsAsync(async() => app.auth.emailPassword.registerEmail(validEmail, invalidPassword)); + err = await TestCase.assertThrowsAsync(async() => app.emailPasswordAuth.registerEmail(validEmail, invalidPassword)); TestCase.assertEqual(err.message, "password must be between 6 and 128 characters"); err = await TestCase.assertThrowsAsync(async() => app.logIn(credentials)); TestCase.assertEqual(err.message, "invalid username/password"); // this user did not register @@ -184,7 +184,7 @@ module.exports = { let credentials = Realm.Credentials.emailPassword(validEmail, validPassword); let err = await TestCase.assertThrowsAsync(async() => app.logIn(credentials)); TestCase.assertEqual(err.message, "invalid username/password"); // this user does not exist yet - await app.auth.emailPassword.registerEmail(validEmail, validPassword); + await app.emailPasswordAuth.registerEmail(validEmail, validPassword); let user = await app.logIn(credentials) assertIsUser(user); assertIsSameUser(user, app.currentUser());