fix logout issue

This commit is contained in:
tzw
2024-02-23 17:05:51 +06:30
parent 421bcf0a11
commit 5496bae681
23 changed files with 144 additions and 84 deletions

View File

@@ -85,4 +85,29 @@ class UserDataProvider {
return await requestAPI("/enable_user", "PUT",
payload: {"id": userID, "enabled": enabled}, token: await getToken());
}
Future<User?> getUser(String userID) async {
if (userID == "") return null;
String path = "/$user_collection";
try {
var snap = await FirebaseFirestore.instance
.collection(path)
.doc(userID)
.get(const GetOptions(source: Source.server));
if (snap.data() == null) return null;
Map<String, dynamic>? data = snap.data() as Map<String, dynamic>;
if (data['delete_time'] == 0) {
User user = User.fromMap(data, snap.id);
return user;
} else {
return null;
}
} catch (e) {
log.warning("Error!! $e");
}
return null;
}
}