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
- self-hosted auth: /v1/account 404 on saf...
Project created in React/Next.js, Appwrite version 1.6.0. Authentication works in all browsers except Safari (ios), where an attempt to connect to {endpoint}/v1...
- delete document problems
i don't know what's going on but i get an attribute "tournamentid" not found in the collection when i try to delet the document... but this is just the document...
- Update User Error
```ts const { users, databases } = await createAdminClient(); const session = await getLoggedInUser(); const user = await users.get(session.$id); if (!use...