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
- Synchronous function execution timeout w...
I am calling server functions with xasync = true and I still get this error message. Synchronous function execution timed out. Use asynchronous execution inste...
- Function running for more than 2 hours i...
This is my projectID: 669fe01b003800dd0503 Cloud functionID is 696ea05400147eb8eb3b I hope this doesn't count against my GB-hours?
- Session not found. Please run appwrite l...
I have encounter an issue with appwrite CLI They asking for a login session but in the doc, itβs mention that only setup client with endpoint / api key is enou...