When I try to login this is the result, but before my login is working properly. I have also User data collection but I already set the permission who can read.
role:guests means you're not logged in. Can you provide more detail about what you're doing and what's going on?
I am trying to login my account
@override
Future<UserProfile> signInWithEmailAndPassword({
required String email,
required String password,
}) async {
try {
await account.createEmailSession(
email: email,
password: password,
);
return currentUser;
} on AppwriteException catch (e, stacktrace) {
_logger.severe(
'Failed to sign in user with email: $email',
e,
);
throw LoginException(
e.message ?? 'Failed to sign in user with email: $email',
stackTrace: stacktrace,
provider: AuthProvider.email,
);
} catch (e, stacktrace) {
_logger.severe(
'Failed to sign in user with email: $email',
e,
);
throw LoginException(
e.toString(),
stackTrace: stacktrace,
provider: AuthProvider.email,
);
}
}
Future<UserProfile> get currentUser async {
_logger.info('Getting current user');
try {
final user = await account.get();
_logger.info('Got current user');
final userProfile = await getUserProfile(userId: user.$id);
return userProfile.copyWith(
data: user,
);
} on AppwriteException catch (e, stacktrace) {
_logger.warning('Failed to get current user', e);
throw AuthException(
e.message ?? 'No user signed in',
stackTrace: stacktrace,
);
} catch (e, stacktrace) {
_logger.severe('Failed to get current user', e);
throw AuthException(
e.toString(),
stackTrace: stacktrace,
);
}
}
@override
Future<UserProfile> getUserProfile({required String userId}) async {
try {
final response = await databases.getDocument(
databaseId: userCredential.databaseId,
collectionId: userCredential.collectionId,
documentId: userId,
);
return UserProfile.appwriteParse(response.data);
} on AppwriteException catch (e, stackTrace) {
_logger.severe(
'''
Failed to get the user information for user $userId''',
e,
stackTrace,
);
throw ProfileUpdateException(
'''
Failed to get the user information for user $userId''',
stackTrace: stackTrace,
);
}
This was my firsst time to encounter this error, Before my login page is working properly
@Mosh Ontong Hmmm I would take a look at if the login failed for some reason
π Did the create session request also fail?
I observe that earlier the login is executed successfully I can see the user session in auth page of appwrite console
Since my method returning a user credential collection. I set the permission to any
so I can test if the collection is the root cause
but still I am receiving this error
Now I refactor my method, I am now returning a account.get(); and I receive this error
I am not familiar with this error
btw I am using flutter
I think we have same issue
I always received this exception:
Flutter web?
flutter window
I found that in my auth console it actually created a session after login
So basicayll if I hot reload my flutter app, it will check first if the user is authenticated by using account.get
Recommended threads
- Edit ID of an existing collection
Hi there. Is it possible to edit an ID of an existing collection? Right now it looks impossible from AppWrite cloud at least.
- Seed db
hello there... is this correct way to seed appwrite
- Query Appwrite
Hello, I have a question regarding Queries in Appwrite. If I have a string "YYYY-MM", how can I query the $createdAt column to match this filter?