Rank 5: Hypervisor
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.
Votes
9
Replies
24
Participants
Unknown
Messages
25
Rank 5: Hypervisor
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?
Rank 5: Hypervisor
I am trying to login my account
Rank 5: Hypervisor
Rank 5: Hypervisor
@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,
);
}
}
Rank 5: Hypervisor
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,
);
}
}
Rank 5: Hypervisor
@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,
);
}
Rank 5: Hypervisor
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?
Rank 5: Hypervisor
I observe that earlier the login is executed successfully I can see the user session in auth page of appwrite console
Rank 5: Hypervisor
Since my method returning a user credential collection. I set the permission to any
Rank 5: Hypervisor
so I can test if the collection is the root cause
Rank 5: Hypervisor
but still I am receiving this error
Rank 5: Hypervisor
Now I refactor my method, I am now returning a account.get(); and I receive this error
Rank 5: Hypervisor
I am not familiar with this error
Rank 5: Hypervisor
btw I am using flutter
Rank 5: Hypervisor
Rank 5: Hypervisor
I think we have same issue
Rank 5: Hypervisor
I always received this exception:
Flutter web?
Rank 5: Hypervisor
flutter window
Rank 5: Hypervisor
Rank 5: Hypervisor
I found that in my auth console it actually created a session after login
Rank 5: Hypervisor
So basicayll if I hot reload my flutter app, it will check first if the user is authenticated by using account.get