问题
Is there any way to turn off more users from signing up on Firebase after I've signed up specific users? For instance, if I only want 10 particular users to be signed up and no more, is there a way to turn off future signups?
回答1:
After some digging, even though this method isn't officially listed in the documentation, I found that you can automatically delete any new user that's created once they have signed up using Cloud Functions and the admin SDK. Here's the code I used to delete any new user the moment they have tried signing up:
exports.deleteNewUser = functions.auth.user().onCreate((event) => {
const uid = event.data.uid; // The Firebase user.
admin.auth().deleteUser(uid)
.then(function() {
console.log("Successfully deleted user");
})
.catch(function(error) {
console.log("Error deleting user:", error);
});
});
来源:https://stackoverflow.com/questions/49162111/how-to-prevent-new-user-registration-on-firebase