mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-09-12 09:37:29 +08:00
checking all users when looking for duplicates
This commit is contained in:
parent
78c14b0b59
commit
18fe0097f1
1 changed files with 32 additions and 11 deletions
|
@ -14,19 +14,40 @@ admin.initializeApp({
|
|||
|
||||
const db = admin.firestore();
|
||||
|
||||
function getAllNames() {
|
||||
return admin
|
||||
.auth()
|
||||
.listUsers()
|
||||
.then((data) => {
|
||||
let names = [];
|
||||
data.users.forEach((user) => {
|
||||
names.push(user.displayName);
|
||||
});
|
||||
return names;
|
||||
});
|
||||
async function getAllNames() {
|
||||
// return admin
|
||||
// .auth()
|
||||
// .listUsers()
|
||||
// .then((data) => {
|
||||
// let names = [];
|
||||
// data.users.forEach((user) => {
|
||||
// names.push(user.displayName);
|
||||
// });
|
||||
// return names;
|
||||
// });
|
||||
|
||||
let ret = [];
|
||||
|
||||
async function getAll(nextPageToken) {
|
||||
// List batch of users, 1000 at a time.
|
||||
let listUsersResult = await admin.auth().listUsers(1000, nextPageToken);
|
||||
for (let i = 0; i < listUsersResult.users.length; i++){
|
||||
ret.push(listUsersResult.users[i].displayName);
|
||||
}
|
||||
if (listUsersResult.pageToken) {
|
||||
// List next batch of users.
|
||||
await getAll(listUsersResult.pageToken);
|
||||
}
|
||||
}
|
||||
|
||||
await getAll();
|
||||
return ret;
|
||||
}
|
||||
|
||||
// exports.testGetAllNames = functions.https.onCall(async (request, response) => {
|
||||
// return await getAllNames();
|
||||
// });
|
||||
|
||||
function getAllUsers() {
|
||||
return admin
|
||||
.auth()
|
||||
|
|
Loading…
Add table
Reference in a new issue