There's definitely no way of doing this for Clients. You will have to use the NodeJS Firebase Admin SDK for this.
I don't think there's a straight-forward way of doing this. You could try chaining the listUsers
method along with deleteUser
method. Before deleting a user, you could check if the user is not verified.
Once this script is ready, just deploy it as a Firebase Cloud Function.
I'm not sure how to run this every 2 days.
I'm not sure if even this would work. But you might want to give this a try:
function listAllUsers(nextPageToken) {
// List batch of users, 1000 at a time.
admin.auth().listUsers(1000, nextPageToken)
.then(function(listUsersResult) {
listUsersResult.users.forEach(function(userRecord) {
const user = userRecord.toJSON();
if (!user.emailVerified) {
admin.auth().deleteUser(user.uid)
.then(function() {
console.log("Successfully deleted user");
})
.catch(function(error) {
console.log("Error deleting user:", error);
});
}
});
if (listUsersResult.pageToken) {
// List next batch of users.
listAllUsers(listUsersResult.pageToken)
}
})
.catch(function(error) {
console.log("Error listing users:", error);
});
}
// Start listing users from the beginning, 1000 at a time.
listAllUsers();