mirror of
https://github.com/wassname/talk.git
synced 2026-08-10 12:41:02 +08:00
feat: support new auth methods for Tenants
- New Time scalar type is implemented on the Server - Single Sign-On keys can now be generated - Single Sign-On keys can be regenerated - Single Sign-On keys now store the date they were generated on. - Initial implementation of `AuthenticationTargetFilter`'s
This commit is contained in:
@@ -5,6 +5,7 @@ import { GQLSettingsInput } from "talk-server/graph/tenant/schema/__generated__/
|
||||
import {
|
||||
createTenant,
|
||||
CreateTenantInput,
|
||||
regenerateTenantSSOKey,
|
||||
Tenant,
|
||||
updateTenant,
|
||||
} from "talk-server/models/tenant";
|
||||
@@ -76,3 +77,24 @@ export async function canInstall(cache: TenantCache) {
|
||||
export async function isInstalled(cache: TenantCache) {
|
||||
return (await cache.count()) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* regenerateSSOKey will regenerate the Single Sign-On key for the specified
|
||||
* Tenant and notify all other Tenant's connected that the Tenant was updated.
|
||||
*/
|
||||
export async function regenerateSSOKey(
|
||||
mongo: Db,
|
||||
redis: Redis,
|
||||
cache: TenantCache,
|
||||
tenant: Tenant
|
||||
) {
|
||||
const updatedTenant = await regenerateTenantSSOKey(mongo, tenant.id);
|
||||
if (!updatedTenant) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Update the tenant cache.
|
||||
await cache.update(redis, updatedTenant);
|
||||
|
||||
return updatedTenant;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user