Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add password personal data check #405

Merged
merged 11 commits into from
Aug 8, 2023
Merged
9 changes: 5 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"dependencies": {
"@analytics/google-analytics": "^1.0.5",
"@appwrite.io/console": "0.1.0",
"@appwrite.io/console": "npm:christy-appwrite-console@0.0.5",
"@appwrite.io/pink": "^0.0.6-rc.10",
"@popperjs/core": "^2.11.6",
"@sentry/svelte": "^7.44.2",
Expand Down
1 change: 1 addition & 0 deletions src/lib/actions/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export enum Submit {
AuthStatusUpdate = 'submit_auth_status_update',
AuthPasswordHistoryUpdate = 'submit_auth_password_history_limit_update',
AuthPasswordDictionaryUpdate = 'submit_auth_password_dictionary_update',
AuthDisallowPersonalDataUpdate = 'submit_auth_disallow_personal_data_update',
SessionsLengthUpdate = 'submit_sessions_length_update',
SessionsLimitUpdate = 'submit_sessions_limit_update',
SessionDelete = 'submit_session_delete',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { Container } from '$lib/layout';
import UpdatePasswordDictionary from './updatePasswordDictionary.svelte';
import UpdatePasswordHistory from './updatePasswordHistory.svelte';
import UpdatePasswordPersonalData from './updatePasswordPersonalData.svelte';
import UpdateSessionLength from './updateSessionLength.svelte';
import UpdateSessionsLimit from './updateSessionsLimit.svelte';
import UpdateUsersLimit from './updateUsersLimit.svelte';
Expand All @@ -13,4 +14,5 @@
<UpdateSessionsLimit />
<UpdatePasswordHistory />
<UpdatePasswordDictionary />
<UpdatePasswordPersonalData />
</Container>
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<FormList>
<InputSwitch
bind:value={passwordHistoryEnabled}
id="passwordHisotryEnabled"
id="passwordHistoryEnabled"
label="Password History" />
</FormList>
<p class="text">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<script lang="ts">
import { invalidate } from '$app/navigation';
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
import { CardGrid, Heading } from '$lib/components';
import { Dependencies } from '$lib/constants';
import { Button, Form, InputSwitch } from '$lib/elements/forms';
import FormList from '$lib/elements/forms/formList.svelte';
TorstenDittmann marked this conversation as resolved.
Show resolved Hide resolved
import { addNotification } from '$lib/stores/notifications';
import { sdk } from '$lib/stores/sdk';
import { project } from '../../store';

const projectId = $project.$id;
let disallowPersonalData = $project.authDisallowPersonalData ?? false;

async function updateDisallowPersonalData() {
try {
await sdk.forConsole.projects.updateDisallowPersonalData(
projectId,
disallowPersonalData
);
await invalidate(Dependencies.PROJECT);
addNotification({
type: 'success',
message: 'Updated disallow personal data.'
TorstenDittmann marked this conversation as resolved.
Show resolved Hide resolved
});
trackEvent(Submit.AuthDisallowPersonalDataUpdate);
} catch (error) {
addNotification({
type: 'error',
message: error.message
});
trackError(error, Submit.AuthDisallowPersonalDataUpdate);
}
}
</script>

<Form onSubmit={updateDisallowPersonalData}>
<CardGrid>
<Heading tag="h2" size="7">Personal Data</Heading>
<svelte:fragment slot="aside">
<FormList>
<InputSwitch
bind:value={disallowPersonalData}
id="passwordHisotryEnabled"
label="Disallow Personal Data" />
</FormList>
<p class="text">
Do now allow passwords that contain any part of the user's personal data. This
includes the user's <code>name</code>, <code>email</code>, or <code>phone</code>.
</p>
</svelte:fragment>

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