Skip to content

Commit

Permalink
remove black list cloud function call
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonIsAzn committed Sep 9, 2024
1 parent e684bc1 commit 9c0a91a
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 114 deletions.
1 change: 0 additions & 1 deletion functions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ export { zipResume } from "./resume";
export { updateUserRole } from "./roles";
export { checkUsernameUniqueness } from "./checkUsername";
export { eventSignIn, eventSignOut, eventLogDelete, addInstagramPoints } from "./events";
export { isUserInBlacklist } from "./restriction";
export { calculateMOTM } from "./points";
export { scheduledFirestoreExport, httpFirestoreExport, resetPointsWithPassword } from "./backup"
27 changes: 0 additions & 27 deletions functions/src/restriction.ts

This file was deleted.

12 changes: 0 additions & 12 deletions src/api/firebaseUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1509,18 +1509,6 @@ export const removeFromBlacklist = async (userToRemove: PublicUserInfo) => {
await setDoc(doc(db, "restrictions/blacklist"), { list: updatedBlacklist }, { merge: true });
};

export const isUserInBlacklist = async (uid: string): Promise<boolean> => {
const blacklistDocRef = doc(db, "restrictions/blacklist");
const docSnap = await getDoc(blacklistDocRef);

if (docSnap.exists()) {
const blacklist = docSnap.data().list;
return blacklist.some((user: PublicUserInfo) => user.uid === uid);
} else {
// Blacklist document does not exist or has no data
return false;
}
};


export const submitFeedback = async (feedback: string, userInfo: User) => {
Expand Down
26 changes: 0 additions & 26 deletions src/navigation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,32 +76,6 @@ const RootNavigator = () => {
// }
// }, [userInfo]);


useEffect(() => {
const handleBannedUser = async () => {
if (!auth.currentUser?.uid) {
return;
}

const functions = getFunctions();
const isUserInBlacklist = httpsCallable<{ uid: string }, { isInBlacklist: boolean }>(functions, 'isUserInBlacklist');
try {
const checkBlackListResponse = await isUserInBlacklist({ uid: auth.currentUser?.uid! });

if (checkBlackListResponse.data.isInBlacklist) {
signOutUser(true);
alert("You have been banned from the app");
return;
}
} catch (error) {
console.error('Error during user authentication:', error);
}

}

handleBannedUser();
}, [auth.currentUser?.uid])

if (userLoading) {
return <RenderUserLoading />;
}
Expand Down
19 changes: 1 addition & 18 deletions src/screens/admin/AdminDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -207,24 +207,7 @@ const AdminDashboard = ({ navigation }: NativeStackScreenProps<HomeStackParams>)
<Text className='text-xl font-semibold text-black text-center'>App Feedback</Text>
</TouchableOpacity>
</View>
<View className='flex-row justify-between mt-4'>
<TouchableOpacity
className={`bg-secondary-blue-2 items-center justify-center h-20 rounded-lg w-[48%]`}
style={{
shadowColor: "#000",
shadowOffset: {
width: 0,
height: 2,
},
shadowOpacity: 0.25,
shadowRadius: 3.84,
elevation: 5,
}}
onPress={() => navigation.navigate('RestrictionsEditor')}
>
<Text className='text-xl font-semibold text-black text-center'>App Restriction</Text>
</TouchableOpacity>
</View>


<Text className={`mt-8 font-bold text-2xl ${darkMode ? "text-white" : "text-black"}`}>Developer Tools</Text>
<View>
Expand Down
15 changes: 0 additions & 15 deletions src/screens/onboarding/LoginGuest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,6 @@ const LoginGuest = ({ navigation }: NativeStackScreenProps<AuthStackParams>) =>
setLoading(true);
initializeCurrentUserData()
.then(async userFromFirebase => {
const functions = getFunctions();
const isUserInBlacklist = httpsCallable<{ uid: string }, { isInBlacklist: boolean }>(functions, 'isUserInBlacklist');

try {
const checkBlackListResponse = await isUserInBlacklist({ uid: auth.currentUser?.uid! });

if (checkBlackListResponse.data.isInBlacklist) {
signOut(auth);
setError("You have been banned from the app");
return;
}
} catch (error) {
console.error('Error during user authentication:', error);
}

AsyncStorage.setItem("@user", JSON.stringify(userFromFirebase))
.then(() => {
setUserInfo(userFromFirebase);
Expand Down
15 changes: 0 additions & 15 deletions src/screens/onboarding/LoginStudent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,6 @@ const LoginStudent = ({ navigation }: NativeStackScreenProps<AuthStackParams>) =
setLoading(true);
initializeCurrentUserData()
.then(async (userFromFirebase) => {
const functions = getFunctions();
const isUserInBlacklist = httpsCallable<{ uid: string }, { isInBlacklist: boolean }>(functions, 'isUserInBlacklist');

try {
const checkBlackListResponse = await isUserInBlacklist({ uid: auth.currentUser?.uid! });

if (checkBlackListResponse.data.isInBlacklist) {
signOut(auth);
setError("You have been banned from the app");
return;
}
} catch (error) {
console.error('Error during user authentication:', error);
}

AsyncStorage.setItem("@user", JSON.stringify(userFromFirebase))
.then(() => {
setUserInfo(userFromFirebase);
Expand Down

0 comments on commit 9c0a91a

Please sign in to comment.