Back

ERROR Error updating user profile: [AppwriteException: Missing required parameter: "password"]"

  • 0
  • React Native
Joe-TVN-MasterMind
29 Oct, 2024, 19:45

Hi guys! I'm a junior react- native dev and I need some help updating data in appetite cloud, my problem is updating profile on parameter updatePassword and all the time I'm getting the same error ERROR Error updating user profile: [AppwriteException: Missing required parameter: "password"]" can you see anything wrong in here to cause the error? Thanks!: export const updateUserProfile = async (userId, newEmail, password, oldPassword, newUsername, newAvatarUrl) => { try { if (newEmail) { await account.updateEmail(newEmail); } if (password) { if(oldPassword){ await account.updatePassword(password, oldPassword);

TypeScript
   } else{
       await account.updatePassword(password);
   }}


   const updatedUser = await databases.updateDocument(
       config.databaseId,
       config.userCollectionId,
       userId,
       {
           username: newUsername,
           avatar: newAvatarUrl,
           email: newEmail,
       }
   );


   return updatedUser;

} catch (error) { console.error('Error updating user profile:', error); throw new Error(error.message); } };

And I'm calling this way : const handleSaveChanges = async () => { if (!newUsername) { Alert.alert('Username cannot be empty'); return; } if (password && !oldPassword) { Alert.alert('To change your password, please enter your current password.'); return; }

setLoading(true);

try { const updatedUser = await updateUserProfile( user.$id, newEmail, password, oldPassword, newUsername, newAvatar); setUser(updatedUser);

TypeScript
 Alert.alert('Success', 'Profile updated successfully');

} catch (error) { Alert.alert('Error', error.message); } finally { setLoading(false); } };

TL;DR
Error message "Missing required parameter: 'password'" is due to missing current password when trying to update email. Solution: Provide current password when updating email. Also, ensure to handle password update correctly.
Kenny
29 Oct, 2024, 19:46

To update an email you need to provide the current password for the user.

Kenny
29 Oct, 2024, 19:47

You should be getting type hints in your IDE that you're missing a param?

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more