From a948cb05285e5fb994c3e40c571201919c476737 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Mon, 10 Apr 2023 07:21:37 +0545 Subject: [PATCH 001/513] smtp update --- src/lib/actions/analytics.ts | 1 + .../project-[project]/settings/header.svelte | 5 + .../settings/smtp/+page.svelte | 121 ++++++++++++++++++ 3 files changed, 127 insertions(+) create mode 100644 src/routes/console/project-[project]/settings/smtp/+page.svelte diff --git a/src/lib/actions/analytics.ts b/src/lib/actions/analytics.ts index 04d74c94aa..612a46096e 100644 --- a/src/lib/actions/analytics.ts +++ b/src/lib/actions/analytics.ts @@ -132,6 +132,7 @@ export enum Submit { ProjectDelete = 'submit_project_delete', ProjectUpdateName = 'submit_project_update_name', ProjectService = 'submit_project_service', + ProjectUpdateSMTP = 'submit_project_update_smtp', MemberCreate = 'submit_member_create', MemberDelete = 'submit_member_delete', MembershipUpdateStatus = 'submit_membership_update_status', diff --git a/src/routes/console/project-[project]/settings/header.svelte b/src/routes/console/project-[project]/settings/header.svelte index b6c51f014b..514b720208 100644 --- a/src/routes/console/project-[project]/settings/header.svelte +++ b/src/routes/console/project-[project]/settings/header.svelte @@ -21,6 +21,11 @@ href: `${path}/webhooks`, title: 'Webhooks', event: 'webhooks' + }, + { + href: `${path}/smtp`, + title: 'SMTP Settings', + event: 'smtp' } ]; diff --git a/src/routes/console/project-[project]/settings/smtp/+page.svelte b/src/routes/console/project-[project]/settings/smtp/+page.svelte new file mode 100644 index 0000000000..e95f7d0bc2 --- /dev/null +++ b/src/routes/console/project-[project]/settings/smtp/+page.svelte @@ -0,0 +1,121 @@ + + + +
+ + SMTP Server +

+ You can customize the email service by providing your own SMTP server. View your + email templates here +

+ + + +

+ Enabling this option allows customizing email templates and prevents emails + from being labeled as spam. +

+ + {#if enabled} + + + + + + {/if} +
+
+ + + + +
+
+
From 2116a7f67eb12ddbd0b704011acaf276eb1d3219 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Mon, 10 Apr 2023 07:40:33 +0545 Subject: [PATCH 002/513] auth templates component --- .../project-[project]/auth/header.svelte | 6 ++++ .../auth/templates/+page.svelte | 29 +++++++++++++++++++ .../settings/smtp/+page.svelte | 5 +++- 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 src/routes/console/project-[project]/auth/templates/+page.svelte diff --git a/src/routes/console/project-[project]/auth/header.svelte b/src/routes/console/project-[project]/auth/header.svelte index 1e43c859b4..8b2bd602d1 100644 --- a/src/routes/console/project-[project]/auth/header.svelte +++ b/src/routes/console/project-[project]/auth/header.svelte @@ -19,6 +19,12 @@ hasChildren: true, event: 'teams' }, + { + href: `${path}/templates`, + title: 'Templates', + hasChildren: false, + event: 'templates' + }, { href: `${path}/usage`, title: 'Usage', diff --git a/src/routes/console/project-[project]/auth/templates/+page.svelte b/src/routes/console/project-[project]/auth/templates/+page.svelte new file mode 100644 index 0000000000..d8cf08d0b7 --- /dev/null +++ b/src/routes/console/project-[project]/auth/templates/+page.svelte @@ -0,0 +1,29 @@ + + + + {#if !$project.smtpEnabled} + { + goto(base + '/console/project-' + $project.$id + '/settings/smtp'); + } + } + ]}> + + Custom SMTP server is required for customizing emails + + Configure a custom SMTP server to enable custom email templates and prevent emails from being + labeled as spam. + + {/if} + diff --git a/src/routes/console/project-[project]/settings/smtp/+page.svelte b/src/routes/console/project-[project]/settings/smtp/+page.svelte index e95f7d0bc2..b203b8c097 100644 --- a/src/routes/console/project-[project]/settings/smtp/+page.svelte +++ b/src/routes/console/project-[project]/settings/smtp/+page.svelte @@ -11,6 +11,7 @@ import { addNotification } from '$lib/stores/notifications'; import { Submit, trackError, trackEvent } from '$lib/actions/analytics'; import InputNumber from '$lib/elements/forms/inputNumber.svelte'; + import { base } from '$app/paths'; let enabled = false; let sender: string; @@ -68,7 +69,9 @@ SMTP Server

You can customize the email service by providing your own SMTP server. View your - email templates here + email templates here

From e24bd15ebb844fcef93a03067696405584609610 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Thu, 13 Apr 2023 11:01:53 +0545 Subject: [PATCH 003/513] basic flow setup --- .../auth/templates/+page.svelte | 126 +++++++++++++++++- .../auth/templates/emailTemplate.svelte | 56 ++++++++ .../auth/templates/localeOptions.svelte | 14 ++ .../auth/templates/smsTemplate.svelte | 13 ++ .../settings/smtp/+page.svelte | 3 +- 5 files changed, 208 insertions(+), 4 deletions(-) create mode 100644 src/routes/console/project-[project]/auth/templates/emailTemplate.svelte create mode 100644 src/routes/console/project-[project]/auth/templates/localeOptions.svelte create mode 100644 src/routes/console/project-[project]/auth/templates/smsTemplate.svelte diff --git a/src/routes/console/project-[project]/auth/templates/+page.svelte b/src/routes/console/project-[project]/auth/templates/+page.svelte index d8cf08d0b7..cc16b21e4b 100644 --- a/src/routes/console/project-[project]/auth/templates/+page.svelte +++ b/src/routes/console/project-[project]/auth/templates/+page.svelte @@ -1,16 +1,71 @@ {#if !$project.smtpEnabled} {/if} + + + Email Templates +

+ Use templates to send and process account management emails. + Learn more about Email templates + . +

+ + + + + Verification +

+ Send a verification email to users that sign in with their email and + password. +

+ saveEmailTemplate('verification', data)} /> +
+ + Magic URL + saveEmailTemplate('verification', data)} /> + + + Reset Password + + + + Invite User + + +
+
+
+ + + SMS Templates +

+ Use templates to send and process account management mobile messages. + Learn more about SMS templates + . +

+ + + + + Verification +

+ Send a verification SMS to users that sign in with their phone +

+ +
+ + Login + + +
+
+
diff --git a/src/routes/console/project-[project]/auth/templates/emailTemplate.svelte b/src/routes/console/project-[project]/auth/templates/emailTemplate.svelte new file mode 100644 index 0000000000..f2e143e772 --- /dev/null +++ b/src/routes/console/project-[project]/auth/templates/emailTemplate.svelte @@ -0,0 +1,56 @@ + + + +
+ + + + + + + + + +
+
diff --git a/src/routes/console/project-[project]/auth/templates/localeOptions.svelte b/src/routes/console/project-[project]/auth/templates/localeOptions.svelte new file mode 100644 index 0000000000..66f1b7c90d --- /dev/null +++ b/src/routes/console/project-[project]/auth/templates/localeOptions.svelte @@ -0,0 +1,14 @@ + + + diff --git a/src/routes/console/project-[project]/auth/templates/smsTemplate.svelte b/src/routes/console/project-[project]/auth/templates/smsTemplate.svelte new file mode 100644 index 0000000000..688bbae44e --- /dev/null +++ b/src/routes/console/project-[project]/auth/templates/smsTemplate.svelte @@ -0,0 +1,13 @@ + + + +
+ + + +
+
diff --git a/src/routes/console/project-[project]/settings/smtp/+page.svelte b/src/routes/console/project-[project]/settings/smtp/+page.svelte index b203b8c097..c98f34a839 100644 --- a/src/routes/console/project-[project]/settings/smtp/+page.svelte +++ b/src/routes/console/project-[project]/settings/smtp/+page.svelte @@ -26,6 +26,7 @@ host = $project.smtpHost; port = $project.smtpPort; username = $project.smtpUsername; + password = $project.smtpPassword; }); async function updateSmtp() { @@ -37,7 +38,7 @@ host, port, username, - password: password ? password : $project.smtpPassword + password }; try { await sdk.forConsole.client.call( From 6c9ae9a4d2b8ff73689b6b8afc5c0e7fc403cd2f Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Sat, 15 Apr 2023 13:58:29 +0400 Subject: [PATCH 004/513] feat: add password personal data check --- .../auth/security/+page.svelte | 2 + .../updatePasswordPersonalData.svelte | 62 +++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 src/routes/console/project-[project]/auth/security/updatePasswordPersonalData.svelte diff --git a/src/routes/console/project-[project]/auth/security/+page.svelte b/src/routes/console/project-[project]/auth/security/+page.svelte index c9c4119104..477deb0f13 100644 --- a/src/routes/console/project-[project]/auth/security/+page.svelte +++ b/src/routes/console/project-[project]/auth/security/+page.svelte @@ -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'; @@ -13,4 +14,5 @@ + diff --git a/src/routes/console/project-[project]/auth/security/updatePasswordPersonalData.svelte b/src/routes/console/project-[project]/auth/security/updatePasswordPersonalData.svelte new file mode 100644 index 0000000000..de1bfab900 --- /dev/null +++ b/src/routes/console/project-[project]/auth/security/updatePasswordPersonalData.svelte @@ -0,0 +1,62 @@ + From d77cc751fe8f6a3c46fda8ee54e31126ebf16e30 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Sat, 15 Apr 2023 14:18:02 +0400 Subject: [PATCH 005/513] feat: add password personal data check --- package-lock.json | 9 +++--- package.json | 2 +- src/lib/actions/analytics.ts | 1 + .../security/updatePasswordHistory.svelte | 2 +- .../updatePasswordPersonalData.svelte | 30 ++++++++----------- 5 files changed, 21 insertions(+), 23 deletions(-) diff --git a/package-lock.json b/package-lock.json index 46a8434389..2d242e6edb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,7 +7,7 @@ "name": "@appwrite/console", "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", @@ -147,9 +147,10 @@ "integrity": "sha512-1Yw7u/COtxx06BfwlI+kVhsa/upKYzmCNrT4c8QDeCY2KMYlnijkUjtHiPU08HxyTIVB5j6d75O0YWVIHwQS8g==" }, "node_modules/@appwrite.io/console": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/@appwrite.io/console/-/console-0.1.0.tgz", - "integrity": "sha512-GzCRUmaXAVgpGwxBNI3PrtCLHz7CM+epBHDDTHw8B2u61KbijGBO3GrwreXy91fy00RJiEzGlMSRzDgwsF3Tsg==", + "name": "christy-appwrite-console", + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/christy-appwrite-console/-/christy-appwrite-console-0.0.5.tgz", + "integrity": "sha512-9OHfJW1Tys4xeJh/p3kzNb92oqDT3zrz6Iu8ob6maKupyhb5ghWIa1ev0bowiYvJTDGkNVfDVXXHoXYbBbrmmQ==", "dependencies": { "cross-fetch": "3.1.5", "isomorphic-form-data": "2.0.0" diff --git a/package.json b/package.json index 0e7ec8d6e1..f25008dc86 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/lib/actions/analytics.ts b/src/lib/actions/analytics.ts index 84c178cc46..066eb70090 100644 --- a/src/lib/actions/analytics.ts +++ b/src/lib/actions/analytics.ts @@ -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', diff --git a/src/routes/console/project-[project]/auth/security/updatePasswordHistory.svelte b/src/routes/console/project-[project]/auth/security/updatePasswordHistory.svelte index 27a28b5d14..e370787975 100644 --- a/src/routes/console/project-[project]/auth/security/updatePasswordHistory.svelte +++ b/src/routes/console/project-[project]/auth/security/updatePasswordHistory.svelte @@ -44,7 +44,7 @@

diff --git a/src/routes/console/project-[project]/auth/security/updatePasswordPersonalData.svelte b/src/routes/console/project-[project]/auth/security/updatePasswordPersonalData.svelte index de1bfab900..0c6aab2e4a 100644 --- a/src/routes/console/project-[project]/auth/security/updatePasswordPersonalData.svelte +++ b/src/routes/console/project-[project]/auth/security/updatePasswordPersonalData.svelte @@ -1,4 +1,4 @@ - + From ea4fee20d5ee03280d1ee89a6f9b05e159b2eb8b Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Mon, 17 Apr 2023 14:02:11 +0545 Subject: [PATCH 006/513] basic working version of email templates --- .../auth/templates/+page.svelte | 64 +++++++++++++++---- .../project-[project]/auth/templates/+page.ts | 17 +++++ .../auth/templates/emailInviteTemplate.svelte | 38 +++++++++++ .../templates/emailMagicUrlTemplate.svelte | 37 +++++++++++ .../templates/emailRecoveryTemplate.svelte | 38 +++++++++++ .../auth/templates/emailTemplate.svelte | 57 ++++++----------- .../emailVerificationTemplate.svelte | 38 +++++++++++ .../auth/templates/localeOptions.svelte | 13 ++-- 8 files changed, 245 insertions(+), 57 deletions(-) create mode 100644 src/routes/console/project-[project]/auth/templates/+page.ts create mode 100644 src/routes/console/project-[project]/auth/templates/emailInviteTemplate.svelte create mode 100644 src/routes/console/project-[project]/auth/templates/emailMagicUrlTemplate.svelte create mode 100644 src/routes/console/project-[project]/auth/templates/emailRecoveryTemplate.svelte create mode 100644 src/routes/console/project-[project]/auth/templates/emailVerificationTemplate.svelte diff --git a/src/routes/console/project-[project]/auth/templates/+page.svelte b/src/routes/console/project-[project]/auth/templates/+page.svelte index cc16b21e4b..1beae6bcff 100644 --- a/src/routes/console/project-[project]/auth/templates/+page.svelte +++ b/src/routes/console/project-[project]/auth/templates/+page.svelte @@ -6,22 +6,43 @@ import { Container } from '$lib/layout'; import { sdk } from '$lib/stores/sdk'; import { project } from '../../store'; - import EmailTemplate from './emailTemplate.svelte'; - import SmsTemplate from './smsTemplate.svelte'; import { addNotification } from '$lib/stores/notifications'; import { onMount } from 'svelte'; + import type { PageData } from './$types'; + import EmailVerificationTemplate from './emailVerificationTemplate.svelte'; + import EmailMagicUrlTemplate from './emailMagicUrlTemplate.svelte'; + import EmailRecoveryTemplate from './emailRecoveryTemplate.svelte'; + import EmailInviteTemplate from './emailInviteTemplate.svelte'; + export let data: PageData; const projectId = $page.params.project; + interface EmailTemplate { + senderName: string; + senderEmail: string; + locale: string; + subject: string; + message: string; + } + let emailTemplates: + | { + verification: EmailTemplate; + magicSession: EmailTemplate; + recovery: EmailTemplate; + invitation: EmailTemplate; + } + | any = {}; - let template: any; onMount(() => { - loadEmailTemplate('verification', 'en_us'); + loadEmailTemplate('verification', 'en-us'); + loadEmailTemplate('magicSession', 'en-us'); + loadEmailTemplate('recovery', 'en-us'); + loadEmailTemplate('invitation', 'en-us'); }); async function loadEmailTemplate(type: string, locale: string) { const path = '/projects/' + projectId + '/templates/email/' + type + '/' + locale; try { - template = await sdk.forConsole.client.call( + emailTemplates[type] = await sdk.forConsole.client.call( 'GET', new URL(sdk.forConsole.client.config.endpoint + path) ); @@ -34,10 +55,11 @@ } async function saveEmailTemplate(type: string, data: any) { + console.log(data); const path = '/projects/' + projectId + '/templates/email/' + type + '/' + data.locale; try { - template = await sdk.forConsole.client.call( + emailTemplates[type] = await sdk.forConsole.client.call( 'PATCH', new URL(sdk.forConsole.client.config.endpoint + path), { 'content-type': 'application/json' }, @@ -100,21 +122,35 @@ Send a verification email to users that sign in with their email and password.

- saveEmailTemplate('verification', data)} /> + Magic URL - saveEmailTemplate('verification', data)} /> + Reset Password - + Invite User - +
@@ -137,11 +173,11 @@

Send a verification SMS to users that sign in with their phone

- + Login - + diff --git a/src/routes/console/project-[project]/auth/templates/+page.ts b/src/routes/console/project-[project]/auth/templates/+page.ts new file mode 100644 index 0000000000..ba12ccdb9a --- /dev/null +++ b/src/routes/console/project-[project]/auth/templates/+page.ts @@ -0,0 +1,17 @@ +import { sdk } from '$lib/stores/sdk'; +import type { PageLoad } from './$types'; + +export const load: PageLoad = async () => { + let codes = { localeCodes: [] }; + try { + codes = await sdk.forProject.client.call( + 'GET', + new URL(sdk.forProject.client.config.endpoint + '/locale/codes') + ); + } catch (e) { + console.log(e); + } + return { + localeCodes: codes.localeCodes + }; +}; diff --git a/src/routes/console/project-[project]/auth/templates/emailInviteTemplate.svelte b/src/routes/console/project-[project]/auth/templates/emailInviteTemplate.svelte new file mode 100644 index 0000000000..29f6e45bd0 --- /dev/null +++ b/src/routes/console/project-[project]/auth/templates/emailInviteTemplate.svelte @@ -0,0 +1,38 @@ + + + + + saveEmailTemplate('invitation', { ...data, locale })} /> + diff --git a/src/routes/console/project-[project]/auth/templates/emailMagicUrlTemplate.svelte b/src/routes/console/project-[project]/auth/templates/emailMagicUrlTemplate.svelte new file mode 100644 index 0000000000..62fc237458 --- /dev/null +++ b/src/routes/console/project-[project]/auth/templates/emailMagicUrlTemplate.svelte @@ -0,0 +1,37 @@ + + + + + saveEmailTemplate('magicSession', { ...data, locale })} /> + diff --git a/src/routes/console/project-[project]/auth/templates/emailRecoveryTemplate.svelte b/src/routes/console/project-[project]/auth/templates/emailRecoveryTemplate.svelte new file mode 100644 index 0000000000..993a1a51c7 --- /dev/null +++ b/src/routes/console/project-[project]/auth/templates/emailRecoveryTemplate.svelte @@ -0,0 +1,38 @@ + + + + + saveEmailTemplate('recovery', { ...data, locale })} /> + diff --git a/src/routes/console/project-[project]/auth/templates/emailTemplate.svelte b/src/routes/console/project-[project]/auth/templates/emailTemplate.svelte index f2e143e772..9fd9b2f4f1 100644 --- a/src/routes/console/project-[project]/auth/templates/emailTemplate.svelte +++ b/src/routes/console/project-[project]/auth/templates/emailTemplate.svelte @@ -1,5 +1,4 @@ - -
- - - - - - - - - -
-
+
+ + + + + + + + +
diff --git a/src/routes/console/project-[project]/auth/templates/emailVerificationTemplate.svelte b/src/routes/console/project-[project]/auth/templates/emailVerificationTemplate.svelte new file mode 100644 index 0000000000..b9384afc93 --- /dev/null +++ b/src/routes/console/project-[project]/auth/templates/emailVerificationTemplate.svelte @@ -0,0 +1,38 @@ + + + + + saveEmailTemplate('verification', { ...data, locale })} /> + diff --git a/src/routes/console/project-[project]/auth/templates/localeOptions.svelte b/src/routes/console/project-[project]/auth/templates/localeOptions.svelte index 66f1b7c90d..0a5395aa9e 100644 --- a/src/routes/console/project-[project]/auth/templates/localeOptions.svelte +++ b/src/routes/console/project-[project]/auth/templates/localeOptions.svelte @@ -1,14 +1,17 @@ ({ + label: code.name, + value: code.code + })) ]} /> From 8b52804241615b7ad4d6dc941d5fd6a1aeafd213 Mon Sep 17 00:00:00 2001 From: Arman Date: Mon, 17 Apr 2023 16:18:56 +0200 Subject: [PATCH 007/513] feat: add inputSearchSelect, add modal on textareaclick, small fixes --- .../elements/forms/inputSelectSearch.svelte | 7 +-- src/lib/elements/forms/inputTextarea.svelte | 3 +- .../auth/templates/+page.svelte | 5 +- .../auth/templates/editMessage.svelte | 60 +++++++++++++++++++ .../auth/templates/emailInviteTemplate.svelte | 4 +- .../templates/emailMagicUrlTemplate.svelte | 4 +- .../templates/emailRecoveryTemplate.svelte | 4 +- .../auth/templates/emailTemplate.svelte | 21 ++++++- .../emailVerificationTemplate.svelte | 9 ++- .../auth/templates/localeOptions.svelte | 43 +++++++++---- 10 files changed, 126 insertions(+), 34 deletions(-) create mode 100644 src/routes/console/project-[project]/auth/templates/editMessage.svelte diff --git a/src/lib/elements/forms/inputSelectSearch.svelte b/src/lib/elements/forms/inputSelectSearch.svelte index 50c435a29a..c7fa41ba8f 100644 --- a/src/lib/elements/forms/inputSelectSearch.svelte +++ b/src/lib/elements/forms/inputSelectSearch.svelte @@ -22,7 +22,7 @@ export let disabled = false; export let autofocus = false; export let interactiveOutput = false; - // Input value + export let stretch = true; export let search = ''; // The actual selected value export let value: Option['value']; @@ -82,9 +82,8 @@ value = option.value; search = option.label; // It's not working without this line. - !$$slots.output && (element.value = search); + $$slots.output ? (search = '') : (element.value = search); hasFocus = false; - search = ''; dispatch('select', option); } @@ -99,7 +98,7 @@ $: showClearBtn = (hasFocus && search) || value; -
  • +
  • -
    +