Moderator
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" }; } }