Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix resetPassword and callResetPasswordFunction #3079

Merged
merged 4 commits into from
Jul 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ NOTE: This version bumps the Realm file format to version 11. It is not possible
* None.

### Fixed
* A crash when calling `user.apiKeys.fetchAll()`
* Fixed a crash when calling `user.apiKeys.fetchAll()`. ([#3067](https://github.com/realm/realm-js/pull/3067))
* Fixed calling `app.emailPasswordAuth.resetPassword` and `app.emailPasswordAuth.callResetPasswordFunction`, which would throw an error of mismatch in count of arguments. ([#3079](https://github.com/realm/realm-js/pull/3079))

### Compatibility
* MongoDB Realm Cloud.
Expand Down
4 changes: 2 additions & 2 deletions docs/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -415,10 +415,10 @@ class EmailPasswordAuth {
*
* @param {string} email - The email address of the user.
* @param {string} password - The desired new password.
* @param {Array<BSON>} args - A bson array of arguments.
* @param {Array<BSON>} args - Arguments passed onto the function.
* @return {Promose<void>}
*/
callResetPasswordFunction(email, password, args) { }
callResetPasswordFunction(email, password, ...args) { }
}

/**
Expand Down
6 changes: 3 additions & 3 deletions lib/email-password-auth-methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ const instanceMethods = {
},

resetPassword(password, token, token_id) {
return promisify(cb => this._resetPassword(password, token, token_id));
return promisify(cb => this._resetPassword(password, token, token_id, cb));
},

callResetPasswordFunction(email, password, bsonArgs) {
return promisify(cb => this._callResetPasswordFunction(email, password, bsonArgs));
callResetPasswordFunction(email, password, ...bsonArgs) {
return promisify(cb => this._callResetPasswordFunction(email, password, bsonArgs, cb));
},
};

Expand Down
2 changes: 1 addition & 1 deletion packages/realm-web/src/auth-providers/EmailPasswordAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export class EmailPasswordAuth implements Realm.Auth.EmailPasswordAuth {
callResetPasswordFunction(
email: string,
password: string,
args: any[],
...args: any[]
): Promise<void> {
return this.transport.fetch({
method: "POST",
Expand Down
2 changes: 1 addition & 1 deletion src/js_email_password_auth.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ void EmailPasswordAuthClass<T>::call_reset_password_function(ContextType ctx, Ob

auto email = Value::validated_to_string(ctx, args[0], "email");
auto password = Value::validated_to_string(ctx, args[1], "password");
auto call_args_js = Value::validated_to_array(ctx, args[1], "args");
auto call_args_js = Value::validated_to_array(ctx, args[2], "args");
auto callback = Value::validated_to_function(ctx, args[3], "callback");

bson::BsonArray call_args_bson;
Expand Down
2 changes: 1 addition & 1 deletion types/auth-providers.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ declare namespace Realm {
callResetPasswordFunction(
email: string,
password: string,
args: any[],
...args: any[],
): Promise<void>;
}

Expand Down