So I have this Auth function that runs to log a user in, and after it runs createEmailSession, I check the database for the users member document, which is just an associated document every user has that has some extra info about them in there. My question is, I get a Document not found error on first try with auth, after I log in a second time (because the error makes the function fail) it works fine, which makes me think it is authenticated but not authenticated, is that possible? If so, would a setTimeout or something fix that?
const login = async (email: string, password: string): Promise<{ type: string, message: string, data?: Models.User<Models.Preferences> }> => {
try {
const userSession = await appwrite.account.createEmailSession(email, password);
localStorage.setItem("pvauser", JSON.stringify(userSession));
const user = await getUser();
$user.value = user;
const memberTry = await getUserMember();
if ($user.value && memberTry && memberTry.data) {
$member.value = memberTry.data;
const teams = await appwrite.listUserTeams();
if (teams.data && teams.data.total > 0) {
const membership = await appwrite.getMembershipFromUserId(teams.data.teams[0].$id, $user.value.$id);
$membership.value = membership.data;
}
}
return { type: "success", message: "Login successful", data: user };
} catch (e) {
console.error(e);
return { type: "error", message: "Login failed" };
}
}
So which part throws an error?
The checkUserMember which is just a list documents with query of the users ID relative to the member
listDocuments returning document not found? That's odd... 🧐 does the collection have relationships?
Hello sir. I also face this problem
I have add the test data in the collection which have the relationship but i can not get both listDocuemnt and get
Please create a separate post and provide all your details
oke thank you sir
No relationships
Filtering by using the same member ID as the Auth User ID
Would you please share the code? And you're saying it's throwing an error?
Yes will do, one moment
Recommended threads
- Invalid token passed in the request
Hello, I have an issue using updateMagicURLSession. I send the email using sendMagicLink, which works fine. When i click the link in the email i get the invali...
- how can i make a relationship between a ...
i want to relate the $id from users auth table in appwrite with other column in my table user_profile. because is the same user... how can i have exactly the s...
- Google login on mobile not working
Hi the gg login auth in mobile not working. No error show. But the user couldnt login in Attached is the video. Desktop is working well and im using custom doma...