fix logout issue
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user