|
| 1 | +<script lang="ts"> |
| 2 | + import { invalidate } from '$app/navigation'; |
| 3 | + import { Submit, trackError, trackEvent } from '$lib/actions/analytics'; |
| 4 | + import { CardGrid } from '$lib/components'; |
| 5 | + import { Dependencies } from '$lib/constants'; |
| 6 | + import { Button, Form, InputSwitch } from '$lib/elements/forms'; |
| 7 | + import { addNotification } from '$lib/stores/notifications'; |
| 8 | + import { sdk } from '$lib/stores/sdk'; |
| 9 | + import { Typography } from '@appwrite.io/pink-svelte'; |
| 10 | + import { project } from '../../store'; |
| 11 | +
|
| 12 | + let sessionInvalidation = $project?.authInvalidateSessions ?? false; |
| 13 | +
|
| 14 | + async function updateSessionInvalidation() { |
| 15 | + try { |
| 16 | + await sdk.forConsole.projects.updateSessionInvalidation( |
| 17 | + $project.$id, |
| 18 | + sessionInvalidation |
| 19 | + ); |
| 20 | + await invalidate(Dependencies.PROJECT); |
| 21 | + addNotification({ |
| 22 | + type: 'success', |
| 23 | + message: 'Updated session invalidation check.' |
| 24 | + }); |
| 25 | + trackEvent(Submit.AuthInvalidateSesssion); |
| 26 | + } catch (error) { |
| 27 | + addNotification({ |
| 28 | + type: 'error', |
| 29 | + message: error.message |
| 30 | + }); |
| 31 | + trackError(error, Submit.AuthInvalidateSesssion); |
| 32 | + } |
| 33 | + } |
| 34 | +</script> |
| 35 | + |
| 36 | +<Form onSubmit={updateSessionInvalidation}> |
| 37 | + <CardGrid> |
| 38 | + <svelte:fragment slot="title">Invalidate sessions</svelte:fragment> |
| 39 | + <svelte:fragment slot="aside"> |
| 40 | + <InputSwitch |
| 41 | + bind:value={sessionInvalidation} |
| 42 | + id="invalidateSessions" |
| 43 | + label="Invalidate sessions" /> |
| 44 | + <Typography.Text> |
| 45 | + Enabling this option will clear all existing sessions when the user changes their |
| 46 | + password. |
| 47 | + </Typography.Text> |
| 48 | + </svelte:fragment> |
| 49 | + |
| 50 | + <svelte:fragment slot="actions"> |
| 51 | + <Button disabled={sessionInvalidation === $project?.authInvalidateSessions} submit> |
| 52 | + Update |
| 53 | + </Button> |
| 54 | + </svelte:fragment> |
| 55 | + </CardGrid> |
| 56 | +</Form> |
0 commit comments