How To Automatically Delete A User In Firebase?
CODE: app.js setInterval(function() { console.log('1'); var pendingRef = admin.database().ref('pending'); var now = Date.now(); var cutoff = now - 1 * 60 * 60 * 10
Solution 1:
There is no delete
method on the snapshot. Instead, you should just call remove
on the snapshot's ref
:
var listener = old.on('child_added', function (snapshot) {
console.log("EXECUTING...");
console.log("A VALUE:" + snapshot.val());
snapshot.ref
.remove()
.catch(function (error) {
console.log("USER WAS NOT DELETED:" + snapshot.key);
});
});
To delete the user account - in addition to the user data you have stored - you also need to call the deleteUser
method (as you are running this on Node using firebase-admin
):
var listener = old.on('child_added', function (snapshot) {
console.log("EXECUTING...");
console.log("A VALUE:" + snapshot.val());
snapshot.ref
.remove()
.then(function () {
return admin.auth().deleteUser(snapshot.key);
})
.catch(function (error) {
console.log("USER WAS NOT DELETED:" + snapshot.key);
});
});
Post a Comment for "How To Automatically Delete A User In Firebase?"