Asako
Hello, I am building an auth function and while I could create an account, users were not stored in the collection. I double-checked that databaseId and userCollectionId were correct. What could be a potential issue?
TypeScript
export async function createUser(email, password, username) {
try {
const newAccount = account.create(ID.unique(), email, password, username);
if (!newAccount) throw Error;
const avatarUrl = avatars.getInitials(username);
await signIn(email, password);
const newUser = await databases.createDocument(
config.databaseId,
config.userCollectionId,
ID.unique(),
{
accountId: newAccount.$id,
email,
username,
avatar: avatarUrl,
}
);
return newUser;
} catch (error) {
throw new Error(error);
}
}
TL;DR
Developers are having an issue where newly created user accounts are not being saved to the collection. While double-checking database IDs and collection IDs, the issue persists. The potential problem might be because the `newAccount` variable is not being properly created. Make sure the account is successfully created before proceeding to save the user to the collection. Evdog
What's the response?
Asako
I see this
Recommended threads
- OAuth SvelteKit SSR tutorial sameSite co...
Hi all, not a question but just want to share my experience. I followed the SSR OAuth tutorial on here: https://appwrite.io/docs/tutorials/sveltekit-ssr-auth/st...
- get document with jwt unauthorized
Hello, I want to implement server side listDocument (listed) and getDocument (detail) with authentication JWT. For listDocument, authentication with JWT succes...
- User (role: guests) missing scope (accou...
Hello! Probably it is something stupid but I can't figure it out. Read a ton of posts already and still need help. Self hosted Appwrite. Simplest login in web a...