Lakshay GoyalOriginal post
Web Developer
// ============================== GET ACCOUNT
export async function getAccount() {
try {
const currentAccount = await account.get();
console.log(currentAccount);
return currentAccount;
} catch (error) {
console.log(error); // error here
}
}
// ============================== GET USER
export async function getCurrentUser() {
try {
const currentAccount = await getAccount();
if (!currentAccount) throw Error;
const currentUser = await databases.listDocuments(
config.databaseId!,
config.userCollectionId!,
[Query.equal("userId", currentAccount.$id)]
);
if (!currentUser) throw Error;
return currentUser.documents[0];
} catch (error) {
console.log(error);
return null;
}
}
Summary
Developers are encountering an error where users with the 'guest' role are missing the 'account' scope. The issue lies in the authentication process for retrieving user information. To resolve this, make sure that the 'account' scope is properly assigned to guest users to allow them access to account-related data.