Skip to content

Commit

Permalink
Merge pull request #227 from appwrite/feat-user-sessions-limit-final
Browse files Browse the repository at this point in the history
feat (auth): user session limit section on auth secutiry
  • Loading branch information
TorstenDittmann authored Dec 27, 2022
2 parents 1b14f76 + 099c513 commit b6b1ca9
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion src/routes/console/project-[project]/auth/security/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { CardGrid, Heading } from '$lib/components';
import { Pill } from '$lib/elements/';
import { Button, InputNumber, InputSelect } from '$lib/elements/forms';
import { Button, InputNumber, InputSelect, Form } from '$lib/elements/forms';
import { Container } from '$lib/layout';
import { project } from '../../store';
import { addNotification } from '$lib/stores/notifications';
Expand All @@ -20,6 +20,7 @@
let timeInSec = time;
let period = writable('s');
let btnActive = false;
let maxSessions = $project.authSessionsLimit;
let options = [
{ label: 'days', value: 'd' },
Expand Down Expand Up @@ -81,6 +82,22 @@
});
}
}
async function updateSessionsLimit() {
try {
await sdkForConsole.projects.updateAuthSessionsLimit(projectId, maxSessions);
addNotification({
type: 'success',
message: 'Sessions limit has been updated'
});
trackEvent('submit_sessions_limit_update');
} catch (error) {
addNotification({
type: 'error',
message: error.message
});
}
}
period.subscribe((p) => {
if (p === 'd') {
Expand Down Expand Up @@ -198,4 +215,20 @@
</Button>
</svelte:fragment>
</CardGrid>

<Form on:submit={updateSessionsLimit}>
<CardGrid>
<Heading tag="h2" size="6">Session Limit</Heading>
<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>
</svelte:fragment>

<svelte:fragment slot="actions">
<Button disabled={maxSessions === $project.authSessionsLimit} submit>Update</Button>
</svelte:fragment>
</CardGrid>
</Form>
</Container>

1 comment on commit b6b1ca9

@vercel
Copy link

@vercel vercel bot commented on b6b1ca9 Dec 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.