-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
68 lines (56 loc) · 1.83 KB
/
index.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
var sys = require("util");
var admin = require("firebase-admin");
var serviceAccount = require("./serviceAccountKey.json");
admin.initializeApp(
{
credential: admin.credential.cert(
serviceAccount
),
databaseURL: "https://<yourdbname>.firebaseio.com"
});
var say = 0;
//setCustomUserClaims("uId");
function setCustomUserClaims(uid) {
admin.auth().setCustomUserClaims(uid, {roleId: 1}).then(() => {
console.log("İşlem Tamam: " + uid);
});
}
createUser();
function createUser() {
admin.auth().createUser(
{
email: "user@example.com",
emailVerified: false,
phoneNumber: "+11234567890",
password: "123456",
displayName: "John Doe",
photoURL: "http://www.example.com/12345678/photo.png",
disabled: false,
customClaims: { roleId: 1 }
}
).then(() => {
console.log("İşlem Tamam: ");
});
}
function DoSomething(uid){
setTimeout(function() { setCustomUserClaims(uid); }, 1000 * say);
}
function listAllUsers() {
// List batch of users, 1000 at a time.
admin.auth().listUsers(1000)
.then(function(listUsersResult) {
listUsersResult.users.forEach(function(userRecord) {
console.log(userRecord);
console.log("\n-----");
});
console.log("Toplam: " + say);
if (listUsersResult.pageToken) {
// List next batch of users.
//listAllUsers(listUsersResult.pageToken)
}
})
.catch(function(error) {
console.log("Error listing users:", error);
});
}
//listAllUsers();