Back

[Solved] Update Email without Password

  • 0
  • Flutter
Pradhumansinh Padhiyar
31 May, 2023, 18:50

I creating a user session using Create Phone session but now user can able to add/update email from profile section.

Currently, Update Email method needs password to update email.

What do you suggest ? what should i here?

TL;DR
Solution: The user wants to update their email without requiring a password. The suggested solution is to create an Appwrite function. The function should parse the user ID and new email sent from the frontend. On the client side, after the user is logged in, they can input a new email address and send it to Appwrite using the `createExecution` function. The function code should use the `Users` server SDK to update the email. The code snippet provided shows an example of how to update the email using the `users.updateEmail` method.
Binyamin
31 May, 2023, 18:53

The best and fastest solution will be to create an Appwrite function, and let execute by Users only. Within it the function you can use the Users server SDK to set the email, for example

TypeScript
// Beginning the function code.
try {
  const userId = req.variables.APPWRITE_FUNCTION_USER_ID ?? '';
  const email = req.payload ?? '';

  await users.updateEmail(userId, email);
} catch (e) {

}
// rest of the function code.
Pradhumansinh Padhiyar
31 May, 2023, 18:55

I dont get it how?

Binyamin
31 May, 2023, 18:58

First you'll need to create Appwrite function. With that function parse the user ID and the user email that was send to you from the front end.

In your code, in the client side, after the user is logged in. You can let the user input a new email address and send it to Appwrite using a function. For that you'll use the createExecution function https://appwrite.io/docs/client/functions?sdk=web-default#functionsCreateExecution

To learn about functions in general, check these: https://appwrite.io/docs/functions https://appwrite.bool-code.org/guide/functions-module

Pradhumansinh Padhiyar
31 May, 2023, 19:01

So email will be store in auth users ?

Binyamin
31 May, 2023, 19:01

With users.updateEmail yes It will be add to the user object in the Auth collection.

Pradhumansinh Padhiyar
31 May, 2023, 19:03

Alright! Thank You..

Pradhumansinh Padhiyar
31 May, 2023, 19:05

[Solved] Update Email without Password

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