appwrite / sdk-for-web

[READ-ONLY] Official Appwrite Web SDK ๐Ÿงก
https://appwrite.io
BSD 3-Clause "New" or "Revised" License
271 stars 58 forks source link

๐Ÿ› Bug Report: Appwrite Rest endpoint expects 'passwordAgain' param when calling account.updateRecovery #92

Closed clnmcgrw closed 2 weeks ago

clnmcgrw commented 2 months ago

๐Ÿ‘Ÿ Reproduction steps

Install appwrite web sdk, configure w/ v1 endpoint (https://cloud.appwrite.io/v1), and attempt to call account.updateRecovery. The method accepts 3 args (userId, secret, and password), but the endpoint is expecting a separate "passwordAgain" param. Also, docs still show that the method accepts a 4th "paswordAgain" arg, but in v14.0.0 of sdk it does not support that argument.

๐Ÿ‘ Expected behavior

I'm able to use the updateRecovery method to confirm password reset by passing 3 arguments - userId, secret, and password.

๐Ÿ‘Ž Actual Behavior

I get an error saying that "passwordAgain" param is required, but updateRecovery method does not support it.

๐ŸŽฒ Appwrite version

Different version (specify in environment)

๐Ÿ’ป Operating system

MacOS

๐Ÿงฑ Your Environment

Local environment, node 20.5.1, appwrite 14.0.0 configured with v1 endpoint

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

๐Ÿข Have you read the Code of Conduct?

dorji-dev commented 2 months ago

@clnmcgrw Faced same issue, looks like there is a mismatch between actual implementation and the latest package code. Had to downgrade the version to 13 for the time being where the updateRecovery method actually supports the passwordAgain argument and is working currently.

clnmcgrw commented 2 months ago

In case anyone else runs into this or a similar api/sdk mismatch - you can always just use the client instance to hit the rest api or shim the account method that's not working, ie:

account.updateRecovery = (
  userId: string,
  secret: string,
  password: string,
  passwordAgain: string,
): Promise<Models.Token> => {
  if (!userId || !secret || !password || !passwordAgain) {
    throw new Error('Missing argument');
  }
  const uri = new URL(client.config.endpoint + '/account/recovery');
  return await client.call('put', uri, {
    'content-type': 'application/json',
  }, { userId, secret, password, passwordAgain });
};
stnguyen90 commented 2 weeks ago

@clnmcgrw, you were probably using an SDK meant for Appwrite version 1.5 while Appwrite Cloud was on version 1.4. It's important to make sure you use a version of the SDK that is compatible with Appwrite. The readme will mention. For example:

Version 15.0.0 of the web SDK:

https://github.com/appwrite/sdk-for-web/blob/eab8856a36f1df682c832a66a63cb0e84c75befd/README.md?plain=1#L9

Version 13.0.2 of the web SDK

https://github.com/appwrite/sdk-for-web/blob/bf13f876b75ff590f4b0921770cf6fc027d4622a/README.md?plain=1#L9