component for password history.

This commit is contained in:
Damodar Lohani committed 2022-12-21 06:26:57 +00:00
1 parent 6c5ae08666
commit dd02b1e404
1 file changed
+62 -13
@@ -21,6 +21,7 @@
let period = writable('s');
let btnActive = false;
let maxSessions = $project.authMaxSessions ?? 10;
let passwordHistory = $project.passwordHistory ?? 0;
let options = [
{ label: 'days', value: 'd' },
@@ -84,14 +85,18 @@
}
async function updateSessionsLimit() {
try {
const path = '/projects/' + projectId + '/auth/max-sessions';
const uri = new URL(sdkForConsole.client.config.endpoint + path);
await sdkForConsole.client.call('patch', uri, {
'content-type': 'application/json',
}, {
limit: maxSessions
});
await sdkForConsole.client.call(
'patch',
uri,
{
'content-type': 'application/json'
},
{
limit: maxSessions
}
);
addNotification({
type: 'success',
message: 'Sessions limit has been updated'
@@ -104,6 +109,32 @@
});
}
}
async function updatePasswordHistoryLimit() {
try {
const path = '/projects/' + projectId + '/auth/password-history';
const uri = new URL(sdkForConsole.client.config.endpoint + path);
await sdkForConsole.client.call(
'patch',
uri,
{
'content-type': 'application/json'
},
{
limit: passwordHistory
}
);
addNotification({
type: 'success',
message: 'Password history limit has been updated'
});
trackEvent('submit_password_history_limit_update');
} catch (error) {
addNotification({
type: 'error',
message: error.message
});
}
}
period.subscribe((p) => {
if (p === 'd') {
@@ -225,18 +256,36 @@
<Form on:submit={updateSessionsLimit}>
<CardGrid>
<Heading tag="h2" size="6">Session Limit</Heading>
<p>
Maximum number of active sessions allowed per user.
</p>
<p>Maximum number of active sessions allowed per user.</p>
<svelte:fragment slot="aside">
<ul>
<InputNumber id="max-session" label="Limit" bind:value={maxSessions} />
</ul>
<ul>
<InputNumber id="max-session" label="Limit" bind:value={maxSessions} />
</ul>
</svelte:fragment>
<svelte:fragment slot="actions">
<Button disabled={maxSessions === $project.authMaxSessions} submit>Update</Button>
</svelte:fragment>
</CardGrid>
</Form>
<Form on:submit={updatePasswordHistoryLimit}>
<CardGrid>
<Heading tag="h2" size="6">Password History</Heading>
<p>
Maximum nubmer of password history to save for a user. 0 for disabling the password
history.
</p>
<svelte:fragment slot="aside">
<ul>
<InputNumber id="max-session" label="Limit" bind:value={passwordHistory} />
</ul>
</svelte:fragment>
<svelte:fragment slot="actions">
<Button disabled={passwordHistory === $project.passwordHistory} submit
>Update</Button>
</svelte:fragment>
</CardGrid>
</Form>
</Container>