Web Developer
Hey guys,
I searched the docs, but didn't find a solution. Basically I am making a CRUD app, using react native and email auth in app write. I am getting an error: ERROR [AppwriteException: User (role: guests) missing scope (account)]
And from what I can tell, it is because I am using the account method before intiializing a session in order to check active sessions. So, what's a way to check active sessions on a device without using account.get()? I want to redirect user based on active session type to different screens.
Please help
here is the code snippet that I think is relevant:
const handleSignIn = async () => {
try {
// First check if there is already an active session
const sessions = await account.listSessions();
if (sessions.total > 0) {
// If session exists, get user details
const user = await account.get();
const userProfile = await databases.getDocument('', '', user.$id);
navigateBasedOnRole(userProfile);
} else {
// If no session, create one
await account.createEmailPasswordSession(email, password);
const user = await account.get();
const userProfile = await databases.getDocument('', '', user.$id);
navigateBasedOnRole(userProfile);
}
} catch (error) {
console.error(error);
Alert.alert("Error", error.message);
}
};