export const createUser = async (email, password, username) => {
try {
const newAccount = await account.create(ID.unique(), email, password, username) // try to create new acc
if (!newAccount) throw Error; // if can't create
const avatarUrl = avatars.getInitials(username) // if created new account, create an avatar
await signIn(email, password)
const newUser = await databases.createDocument(
databaseId,
userCollectionId,
ID.unique(),
{
accountId: newAccount.$id,
email,
username,
avatar: avatarUrl
}
)
return newUser;
} catch (error) {
console.log(error);
throw new Error(error)
}
}
This function creates a new user in Auth directory, but it fails to add a user to the database > users folder that i created. I double checked for any errors inside the appwrite folder config but i cant find any… All users are permitted to do anything with the database for now and it’s still not working.