-
Notifications
You must be signed in to change notification settings - Fork 131
Snippets for new Auth admin features #94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
0fd0398
e6d1833
f6b7fb2
9796c56
8bd6944
9dca306
ade2115
48cc3e0
e8ef8de
5d03a0f
d233439
c469748
435a151
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
const admin = require('firebase-admin'); | ||
admin.initializeApp(); | ||
|
||
const tenantId = 'tenantId'; | ||
|
||
function createTenant() { | ||
// [START auth_create_tenant] | ||
admin.auth().tenantManager().createTenant({ | ||
displayName: 'myTenant1', | ||
emailSignInConfig: { | ||
enabled: true, | ||
// Email link sign-in enabled. | ||
passwordRequired: false, | ||
}, | ||
}) | ||
.then((createdTenant) => { | ||
console.log(createdTenant.toJSON()); | ||
}) | ||
.catch((error) => { | ||
// Handle error. | ||
}); | ||
// [END auth_create_tenant] | ||
} | ||
|
||
function updateTenant() { | ||
// [START auth_update_tenant] | ||
admin.auth().tenantManager().updateTenant(tenantId, { | ||
displayName: 'updatedName', | ||
emailSignInConfig: { | ||
// Disable email provider. | ||
enabled: false, | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Originally, I had thought to just piggy-back the enablement of anon authentication docs into the existing create/update tenant docs. My reasoning was that this is just another parameter, not really much different than (eg) emailSignInConfig. If you did that here, you could get rid of the enableAnonAuth snippet entirely. (No objection to keeping it separate either though.) |
||
// Enable anonymous sign-in | ||
anonymousSignInEnabled: true, | ||
}) | ||
.then((updatedTenant) => { | ||
console.log(updatedTenant.toJSON()); | ||
}) | ||
.catch((error) => { | ||
// Handle error. | ||
}); | ||
// [END auth_update_tenant] | ||
} | ||
|
||
function deleteTenant() { | ||
// [START auth_delete_tenant] | ||
admin.auth().tenantManager().deleteTenant(tenantId) | ||
.then(() => { | ||
// Tenant deleted. | ||
}) | ||
.catch((error) => { | ||
// Handle error. | ||
}); | ||
// [END auth_delete_tenant] | ||
} | ||
|
||
// [START auth_list_all_tenants] | ||
function listAllTenants(nextPageToken) { | ||
return admin.auth().tenantManager().listTenants(100, nextPageToken) | ||
.then((result) => { | ||
result.tenants.forEach((tenant) => { | ||
console.log(tenant.toJSON()); | ||
}); | ||
if (result.pageToken) { | ||
return listAllTenants(result.pageToken); | ||
} | ||
}); | ||
} | ||
samtstern marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
listAllTenants(); | ||
// [END auth_list_all_tenants] |
Uh oh!
There was an error while loading. Please reload this page.