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
- API key without database.read/write
I had some issues with my previous API key and I deleted it then I wanted to create a new one and discovered the database checkbook has no database.read/write j...
- dynamic key missing scopes for database ...
Here are the scopes listed, I get permission errors for reading row and document. Appears to be missing since last time i checked. Database 6 Scopes policies....
- No server error on selfhosted appwrite
Please help me, my clients is ask what happen on their data? How can i make it up again?