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
- education plan not activated
Hi I have an edu id 13103046@iubat.edu but when I am trying to claim my plan and trying to logging with github where education student plan active. the appwrite...
- 500 simultaneous OAuth logins from the s...
Hi, I'd like to ask about rate limiting around Google OAuth login on Appwrite Cloud. **OVERVIEW** Service type: A PWA (web app) for members of a university clu...
- Suspicious access pattern detected when ...
Hello, I am having trouble restoring my project. In the past it worked with no problems, but today I get an error "Suspicious access pattern detected". How can ...