I see AppWrite includes several function samples for adding numbers and some other non-sense, but it does not include the most important samples: email verification and password reset.
I've tried every possible way to create a reset password function in appwrite, using NodeJS and i failed day after day.
Anyone knows how to do it using the Appwrite cloud functions? it would be great to have it as an example.
Also, do we need to setup the snmp and pay for "pro" to be able to verify emails on appwrite cloud?
btw I tried this code and it didn't work. ```import { Client, Databases, Query, ID } from 'node-appwrite'; import querystring from 'node:querystring';
// This is your Appwrite function // It's executed each time we get a request export default async ({ req, res, log, error }) => { // Why not try the Appwrite SDK? // const client = new Client() .setEndpoint('https://cloud.appwrite.io/v1') .setProject(process.env.APPWRITE_FUNCTION_PROJECT_ID) .setKey(process.env.APPWRITE_API_KEY);
const account = new Account(client);
const promise = account.updateRecovery(req.query.userId, req.query.secret, 'password', 'password');
promise.then(function (response) { log(response); return res.send(response); }, function (error) { error(error); return res.send(error); });
return res.send('userid:'+req.query.userId+' secret:'+req.query.secret);```
First off, you don't seem to be importing Account
Second, I see you're using the Server SDK. In the Server SDKs, you can use users.updatePassword('[USER_ID]', 'newpassword') to update a users password
You can set whether or not a user's email address is verified with users.updateEmailVerification()
Note that most Account functions require you to be in a user context. To do this, you either need to be signed into a user (with a Client SDK), or you can generate a JWT (with account.createJWT()) on the client side, pass that to the Function and then use client.setJWT()
Recommended threads
- Tips for Debugging Appwrite Functions Lo...
Hi everyone! 👋 I have an Appwrite Function running locally with Docker, but I’m struggling to debug it because execution doesn’t reach the breakpoints I set. ...
- AttributeError: 'Context' object has no ...
I'm getting an error executing my function. I'm not able to replicate this locally since I have to use a mock context. Is there a way to debug this kind of erro...
- SyntaxError: The requested module 'node-...
I am trying to use appwrite functions and in the function i am creating rows but i got this error when i executed the funtion. As i checked docs there TablesDB...