-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathadmin-scripts.js
88 lines (74 loc) · 2.32 KB
/
admin-scripts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
var admin = require('firebase-admin');
admin.initializeApp({
credential: admin.credential.applicationDefault(),
databaseURL: "https://aumt-website.firebaseio.com"
});
console.log(admin)
// ============
// UPDATE EMAIL
// ============
// admin.auth().updateUser('<uid>', // uid
// {
// email: '<new email>'
// })
// .then((res) => {
// console.log('response', res)
// })
// .catch((err) => {
// console.log(err)
// })
// ============
// DELETE ALL USERS OTHER THAN SPECIFIED UIDS
// ============
// admin
// .auth()
// .listUsers(250)
// .then((listUsersResult) => {
// allUids = []
// listUsersResult.users.forEach((userRecord) => {
// allUids.push(userRecord.toJSON().uid);
// });
// return allUids
// })
// .then((allUids) => {
// saveUids = [
// '<uid-here>',
// '<uid-here>',
// '<uid-here>',
// '<uid-here>',
// '<uid-here>',
// '<uid-here>',
// '<uid-here>',
// '<uid-here>',
// '<uid-here>',
// ]
// deleteUids = allUids.filter(uid => saveUids.indexOf(uid) === -1)
// return deleteUids
// })
// .then((deleteUids) => {
// return admin.auth().deleteUsers(deleteUids).then((result) => {
// console.log('Successfully deleted ' + result.successCount + ' users');
// console.log('Failed to delete ' + result.failureCount + ' users');
// result.errors.forEach(function(err) {
// console.log(err.error.toJSON());
// });
// })
// })
// .catch((error) => {
// console.log('Error:', error);
// });
// ============
// DELETE MULTIPLE USERS BY UID
// ============
// const uidArray = ['<uid1>', '<uid2>', '<uid3>']
// admin.auth().deleteUsers(uidArray)
// .then(function(deleteUsersResult) {
// console.log('Successfully deleted ' + deleteUsersResult.successCount + ' users');
// console.log('Failed to delete ' + deleteUsersResult.failureCount + ' users');
// deleteUsersResult.errors.forEach(function(err) {
// console.log(err.error.toJSON());
// });
// })
// .catch(function(error) {
// console.log('Error deleting users:', error);
// });