Skip to content

Commit 2a074e4

Browse files
Merge pull request #405 from appwrite/disallow-personal-data
feat: add password personal data check
2 parents 93fa7d3 + 4902198 commit 2a074e4

File tree

6 files changed

+67
-6
lines changed

6 files changed

+67
-6
lines changed

package-lock.json

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
},
2020
"dependencies": {
2121
"@analytics/google-analytics": "^1.0.5",
22-
"@appwrite.io/console": "0.2.0",
22+
"@appwrite.io/console": "npm:christy-console@^0.3.0",
2323
"@appwrite.io/pink": "^0.0.6-rc.10",
2424
"@analytics/google-tag-manager": "^0.5.3",
2525
"@popperjs/core": "^2.11.6",

src/lib/actions/analytics.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ export enum Submit {
153153
AuthStatusUpdate = 'submit_auth_status_update',
154154
AuthPasswordHistoryUpdate = 'submit_auth_password_history_limit_update',
155155
AuthPasswordDictionaryUpdate = 'submit_auth_password_dictionary_update',
156+
AuthPersonalDataCheckUpdate = 'submit_auth_personal_data_check_update',
156157
SessionsLengthUpdate = 'submit_sessions_length_update',
157158
SessionsLimitUpdate = 'submit_sessions_limit_update',
158159
SessionDelete = 'submit_session_delete',

src/routes/console/project-[project]/auth/security/+page.svelte

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { Container } from '$lib/layout';
33
import UpdatePasswordDictionary from './updatePasswordDictionary.svelte';
44
import UpdatePasswordHistory from './updatePasswordHistory.svelte';
5+
import UpdatePersonalDataCheck from './updatePersonalDataCheck.svelte';
56
import UpdateSessionLength from './updateSessionLength.svelte';
67
import UpdateSessionsLimit from './updateSessionsLimit.svelte';
78
import UpdateUsersLimit from './updateUsersLimit.svelte';
@@ -13,4 +14,5 @@
1314
<UpdateSessionsLimit />
1415
<UpdatePasswordHistory />
1516
<UpdatePasswordDictionary />
17+
<UpdatePersonalDataCheck />
1618
</Container>

src/routes/console/project-[project]/auth/security/updatePasswordHistory.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
<FormList>
4545
<InputSwitch
4646
bind:value={passwordHistoryEnabled}
47-
id="passwordHisotryEnabled"
47+
id="passwordHistoryEnabled"
4848
label="Password History" />
4949
</FormList>
5050
<p class="text">
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<script lang="ts">
2+
import { invalidate } from '$app/navigation';
3+
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
4+
import { CardGrid, Heading } from '$lib/components';
5+
import { Dependencies } from '$lib/constants';
6+
import { Button, Form, InputSwitch } from '$lib/elements/forms';
7+
import { FormList } from '$lib/elements/forms';
8+
import { addNotification } from '$lib/stores/notifications';
9+
import { sdk } from '$lib/stores/sdk';
10+
import { project } from '../../store';
11+
12+
let authPersonalDataCheck = $project.authPersonalDataCheck ?? false;
13+
14+
async function updatePersonalDataCheck() {
15+
try {
16+
await sdk.forConsole.projects.updatePersonalDataCheck(
17+
$project.$id,
18+
authPersonalDataCheck
19+
);
20+
await invalidate(Dependencies.PROJECT);
21+
addNotification({
22+
type: 'success',
23+
message: 'Toggled personal data checks for passwords'
24+
});
25+
trackEvent(Submit.AuthPersonalDataCheckUpdate);
26+
} catch (error) {
27+
addNotification({
28+
type: 'error',
29+
message: error.message
30+
});
31+
trackError(error, Submit.AuthPersonalDataCheckUpdate);
32+
}
33+
}
34+
</script>
35+
36+
<Form onSubmit={updatePersonalDataCheck}>
37+
<CardGrid>
38+
<Heading tag="h2" size="7">Personal Data</Heading>
39+
<svelte:fragment slot="aside">
40+
<FormList>
41+
<InputSwitch
42+
bind:value={authPersonalDataCheck}
43+
id="personalDataCheck"
44+
label="Disallow Personal Data" />
45+
</FormList>
46+
<p class="text">
47+
Do now allow passwords that contain any part of the user's personal data. This
48+
includes the user's <code>name</code>, <code>email</code>, or <code>phone</code>.
49+
</p>
50+
</svelte:fragment>
51+
52+
<svelte:fragment slot="actions">
53+
<Button disabled={authPersonalDataCheck === $project.authPersonalDataCheck} submit
54+
>Update</Button>
55+
</svelte:fragment>
56+
</CardGrid>
57+
</Form>

0 commit comments

Comments
 (0)