We have a function that runs when a user is created. This function creates a profile for them in a collection in the DB.
I just added in MagicURL options. If a user does not exist with that email a new one is created via the createMagicURLToken.
here is the function:
export const createMagicURLToken = async (
email: IUser['email'],
): Promise<void> => {
try {
await account.createMagicURLToken(
ID.unique(),
email,
'http://localhost:3000/auth/magicURL',
);
} catch (error) {
console.error(error);
throw new Error('Error creating magic URL token');
}
};
and then when the user clicks the link in their email it uses this function:
export const createSessionFromMagicURLToken = async ({
userId,
secret,
}: {
userId: IUser['id'];
secret: string;
}): Promise<void> => {
try {
await account.createSession(userId, secret);
} catch (error) {
console.error(error);
throw new Error('Error creating session from magic URL token');
}
};
so the idea is if the user doesn't exist, and is created, then the Appwrite Function runs. This works on registering with email/password. But does not work with magicURL.
Thougts?
Recommended threads
- Project is currently blocked
When accessing the Appwrite console, I receive the message: "Project is currently blocked. Access to this project is restricted. Contact support if the issue pe...
- {"code": 1008, "message": "Invalid Origi...
Nothing has changed in my application or console settings so I'm curious as to what I need to do to fix this. I already have the client registered so I'm not en...
- ClientException with SocketException: Cl...
hi <@564158268319203348> i have noticed this 500 status code in my function requests, it seems its not able to connect to the internet in the function as reque...