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
- HTTP POST to function returning "No Appw...
Hi everyone, I’m running into an issue with my self-hosted Appwrite instance. I’ve set up my environment variables (APPWRITE_FUNCTION_PROJECT_ID, APPWRITE_FUNC...
- Can't add dart 3.5 runtime
Modified the `.env` to enable dart 3.5 runtime on my self-hosted instance but still can't find the runtime when creating a new function. I manually pulled the i...
- How to verify an user using AppWrite Fun...
I have seen similar questions but none whose solutions serve me. I have a function to verify a user with their secret and their id: https://blahblah.appwrite.gl...