isAdmin method
Implementation
Future<bool> isAdmin() async {
final currentUserUid = ref
.read(firebaseAuthRepositoryProvider().notifier)
.getCurrentUser()
?.uid;
if (currentUserUid != null) {
try {
QuerySnapshot querySnapshot = await _firebaseFirestoreInstance
.collection('Authorizations')
.doc('Admins')
.collection('FirestoreUsers')
.where('uid', isEqualTo: currentUserUid)
.get();
if (querySnapshot.docs.isNotEmpty) {
// debugPrint("querySnapshot.docs: ${querySnapshot.docs.first.data()}");
debugPrint("[*] 슈퍼관리자(와이즈댓)입니다.");
return true;
} else {
debugPrint("[*] 슈퍼관리자(와이즈댓)가 아닙니다.");
return false;
}
} catch (e) {
debugPrint("Error checking admin status: $e");
return false;
}
} else {
return false;
}
}