HIBP stats

This commit is contained in:
Matej Bačo
2024-01-08 11:41:17 +01:00
parent 0103837d78
commit 394eaed16b
4 changed files with 38 additions and 2 deletions
+23
View File
@@ -209,6 +209,11 @@ export type RegionList = {
total: number;
};
export type UserList = {
users: User[];
total: number;
};
export type Address = {
$id: string;
streetAddress: string;
@@ -958,4 +963,22 @@ export class Billing {
params
);
}
async getHIBP(queries: Query[] = [], search: string = ''): Promise<UserList> {
const path = `/project/users-pwned`;
const params = {
queries,
search
};
const uri = new URL(this.client.config.endpoint + path);
return await this.client.call(
'GET',
uri,
{
'content-type': 'application/json'
},
params
);
}
}
@@ -8,6 +8,9 @@
import UpdateSessionLength from './updateSessionLength.svelte';
import UpdateSessionsLimit from './updateSessionsLimit.svelte';
import UpdateUsersLimit from './updateUsersLimit.svelte';
import type { PageData } from './$types';
export let data: PageData;
</script>
<Container>
@@ -18,6 +21,6 @@
<UpdatePasswordDictionary />
<UpdatePersonalDataCheck />
{#if isCloud}
<UpdatePwned />
<UpdatePwned compromisedUsersCount={data.compromisedUsersCount} />
{/if}
</Container>
@@ -0,0 +1,9 @@
import { sdk } from '$lib/stores/sdk';
import type { PageLoad } from './$types';
import { isCloud } from '$lib/system';
export const load: PageLoad = async ({ url, route }) => {
return {
compromisedUsersCount: !isCloud ? 0 : (await sdk.forConsole.billing.getHIBP()).total
};
};
@@ -7,6 +7,7 @@
import ChangeOrganizationTierCloud from '$routes/console/changeOrganizationTierCloud.svelte';
let value = false;
export let compromisedUsersCount: number;
</script>
<CardGrid>
@@ -20,7 +21,7 @@
{#if isCloud && $organization.billingPlan === 'tier-0'}
<Alert type="warning">
<p class="text">
You have 234 users with compromised passwords. To view the full list of
You have {compromisedUsersCount} users with compromised passwords. To view the full list of
compromised users, upgrade you plan.
</p>
<svelte:fragment slot="buttons">