Rank 3: Container
Am using provider to deal with functions linked to appwrite.
Here is my login.
Future<String?> login(String email, String password) async {
try {
await account.createEmailPasswordSession(
email: email,
password: password,
);
print("Account est créé avec emails");
late dynamic user;
try {
user = await account.get();
} catch (e) {
debugPrint("Impossible de récupérer l'utilisateur : $e");
}
print("user : $user)");
if (user.labels.contains("admin")) {
await fetchAdminData();
return "admin";
} else {
await fetchCurrentOffreurData(email);
return "offreur";
}
} catch (e) {
debugPrint("Erreur login: $e");
return null;
}
}
I always get :
Impossible de récupérer l'utilisateur : AppwriteException: general_unauthorized_scope, User (role: guests) missing scopes (["account"]) (401)
The session is created. But for some reason, user is considered GUEST even though session was created with email & password. So authentified.