Skip to content

Commit

Permalink
✨ add the delete account option (#200) (#202)
Browse files Browse the repository at this point in the history
* ✨ feat: added delete account button

* ✨ feat: added support email helper

* ✨ feat: added delete account icon

* 🌐 chore: added delete account translations

* ✨ feat: display the delete account option
  • Loading branch information
rezk2ll committed May 23, 2024
1 parent 9ce92e5 commit 4c4d50e
Show file tree
Hide file tree
Showing 10 changed files with 155 additions and 89 deletions.
19 changes: 19 additions & 0 deletions registration/src/lib/components/buttons/DeleteAccountButton.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<script lang="ts">
import { t } from 'svelte-i18n';
import { sendAccountDeletionMail } from '$utils/account';
import DeleteAccountIcon from '$components/icons/DeleteAccountIcon.svelte';
export let username: string;
</script>

<button
type="button"
on:click={() => sendAccountDeletionMail(username)}
class="w-full flex items-center text-disabled-text gap-5 justify-start p-2.5 text-sm transition-colors duration-200 transform hover:bg-red-300"
>
<DeleteAccountIcon />

<div class="mx-1 grow text-left">
<h1 class="text-sm font-semibold">{$t('delete-account')}</h1>
</div>
</button>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512" height="1em">
<path
d="M96 128a128 128 0 1 1 256 0A128 128 0 1 1 96 128zM0 482.3C0 383.8 79.8 304 178.3 304h91.4C368.2 304 448 383.8 448 482.3c0 16.4-13.3 29.7-29.7 29.7H29.7C13.3 512 0 498.7 0 482.3zM471 143c9.4-9.4 24.6-9.4 33.9 0l47 47 47-47c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-47 47 47 47c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0l-47-47-47 47c-9.4 9.4-24.6 9.4-33.9 0s-9.4-24.6 0-33.9l47-47-47-47c-9.4-9.4-9.4-24.6 0-33.9z"
/></svg
>
13 changes: 10 additions & 3 deletions registration/src/lib/components/user/LoggedUser.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import Avatar from '$components/icons/AvatarIcon.svelte';
import { t } from 'svelte-i18n';
import { clickOutside } from '$utils/html';
import DeleteAccountButton from '../buttons/DeleteAccountButton.svelte';
export let username: string;
export let firstName: string;
Expand Down Expand Up @@ -37,16 +38,22 @@
>
</div>
</button>
<div class="z-20 mt-1 overflow-hidden bg-white rounded-md shadow-xl {open ? 'block' : 'hidden'}">
<div
data-sveltekit-preload-data="off"
class="flex flex-col gap-1 z-20 mt-1 overflow-hidden bg-white rounded-md shadow-xl {open
? 'block'
: 'hidden'}"
>
<a
href="/logout"
class="flex items-center justify-center p-2.5 text-sm transition-colors duration-200 transform hover:bg-gray-100"
class="flex items-center gap-5 justify-start p-2.5 text-sm transition-colors duration-200 transform hover:bg-gray-100"
>
<Logout />

<div class="mx-1">
<div class="mx-1 grow text-left">
<h1 class="text-sm font-semibold">{$t('Logout')}</h1>
</div>
</a>
<DeleteAccountButton {username} />
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import CopyIcon from '../icons/CopyIcon.svelte';
import { copyToClipboard } from '$utils/clipboard';
import Toast from '../display/Toast.svelte';
import DeleteAccountButton from '../buttons/DeleteAccountButton.svelte';
export let firstName: string;
export let lastName: string;
Expand Down Expand Up @@ -76,11 +77,16 @@
>
</div>
{/if}
<div
class="px-2 text-[17px] not-italic font-normal leading-6 tracking-[-0.15px] text-disabled-text text-left 0"
>
<DeleteAccountButton {username} />
</div>
</div>
<span
class="text-center text-[17px] not-italic font-medium leading-6 tracking-[-0.15px] text-disabled-text"
>
{$t('logged_twakeid_choose_mobile')}
</span>
</div>
<Toast show={showToast}>{ $t('matrix-id-copied') }</Toast>
<Toast show={showToast}>{$t('matrix-id-copied')}</Toast>
163 changes: 82 additions & 81 deletions registration/src/lib/i18n/ar.json
Original file line number Diff line number Diff line change
@@ -1,83 +1,84 @@
{
"welcome": "معرف توايك هو مدخلك الوحيد إلى جميع خدمات الدردشة والبريد و الملفات",
"Sign up": "التسجيل",
"Sign in": "تسجيل الدخول",
"First Name": "الاسم",
"Last Name": "اسم العائلة",
"Username": "اسم المستخدم",
"Password": "كلمة المرور",
"Confirm password": "تأكيد كلمة المرور",
"Phone number": "رقم الهاتف",
"uela": "أوافق على <a href='#/ue' class='text-primary'> اتفاقية المستخدم </a> و <a href='#/ue' class='text-primary'> استخدام البيانات الشخصية </a> الشروط بموجب الشروط المنصوص عليها في اتفاقية <a href='#/pp' class='text-primary'> سياسة الخصوصية </a> .",
"Cellphone / Username / Email": "رقم الهاتف / اسم المستخدم / البريد الإلكتروني",
"logged_hero": "معرف تويك هو إدخالك الوحيد الوصول إلى جميع خدماتنا الدردشة والبريد الملفات",
"Congratulations": "تهانينا",
"You are all set up": "لقد تم إعداد كل شيء.",
"logged_twakeid_choose": "قم بتسجيل الدخول إلى الدردشة و الملفات و البريد باستخدام معرف تويك الخاص بك",
"logged_twakeid_choose_mobile": "قم بتسجيل الدخول إلى الملفات و البريد باستخدام بيانات اعتماد تويك",
"twake_chat_description": "الاتصالات المؤسسية اللامركزية تبدأ من هنا",
"tdrive_description": "شارك الملفات وتعاون عليها بشكل آمن، في أي مكان",
"tmail_description": "جرب التواصل عبر البريد الإلكتروني كما لم يحدث من قبل",
"Logout": "تسجيل خروج",
"Matrix ID/Email": "معرف ماتريكس/البريد الإلكتروني",
"username_info_tooltip": "سيتم استخدام اسم المستخدم الذي تدخله لتشكيل معرف ماتريكس الخاص بك بالإضافة إلى عنوان بريد تويك الخاص بك.",
"Ok-got-it": "حسنا ، فهمت",
"username_taken": "عذرا، اسم المستخدم مستعمل",
"weak_password": "كلمة مرور ضعيفة. يجب أن يكون طولها 8 أحرف على الأقل وتحتوي على حرف كبير وحرف صغير ورقم",
"password_mismatch": "كلمات المرور غير متطابقة",
"Number is already registered": "الرقم مسجل سابقا",
"instead": "بدلا",
"6-digit": "أدخل الرمز المكون من 6 أرقام الذي أرسلناه إلى",
"Confirm": "أكد",
"Start your journey": "ابدأ رحلتك",
"Your phone number successfully confirmed": "تم تأكيد رقم هاتفك بنجاح.",
"Error": "خطأ",
"Invalid credentials": "بيانات الاعتماد غير صالحة",
"invalid Username": "اسم المستخدم غير صالح",
"accept terms and conditions": "قبول الشروط والأحكام",
"invalid phone number": "الرقم الذي أدخلته غير صالح. حاول ثانية.",
"login": "تسجيل الدخول",
"hide or show": "إخفاء أو إظهار",
"sign-in-instead": "تسجيل الدخول بدلا من ذلك",
"this-number-is-already-registered-sign-in-instead": "هذا الرقم مسجل سابقا. سجل الدخول بدلا من ذلك.",
"too-many-wrong-attempts-has-been-made-try-again-later": "لقد تم إجراء الكثير من المحاولات الخاطئة. حاول مرة أخرى لاحقا.",
"matrix-id-copied": "تم نسخ معرف متريكس إلى الحافظة",
"mobile-app": "تطبيق الجوال",
"open-twake": "افتح تويك",
"available-usernames": "أسماء المستخدمين المتاحة",
"twake-phone-number": "رقم هاتف تويك",
"twake-matrix-id": "معرف مصفوفة تويك",
"sorry-something-went-wrong-please-try-again": "عذرًا، حدث خطأ ما، يرجى المحاولة مرة أخرى.",
"entered-code-is-incorrect-try-again": "الرمز الذي تم إدخاله غير صحيح. حاول ثانية.",
"twake-mail": "بريد تويك",
"Choose-a-country": "اختر بلدا",
"Search": "بحث",
"Your-phone-number": "رقم الهاتف",
"please-confirm": "يرجى تأكيد رمز البلد الخاص بك وإدخال رقم هاتفك.",
"Next": "التالي",
"Confirm-your-code": "قم بتأكيد الرمز الخاص بك",
"Resend": "إعادة إرسال",
"Resend-in": "إعادة الإرسال في",
"continue-sign-up": "متابعة التسجيل",
"Set-your-password": "عين كلمة المرور الخاصة بك",
"Create-Twake-ID": "إنشاء معرف تويك",
"end-to-end-encryption-collaborative-features-for-secure-and-efficient-teamwork": "تشفير شامل وميزات تعاونية للعمل الجماعي الآمن والفعال",
"set-a-strong-password-with-letters-numbers-and-symbols": "قم بتعيين كلمة مرور قوية مكونة من أحرف وأرقام ورموز",
"Faster-and-more-convenient": "أسرع وأكثر ملاءمة",
"download-app": "قم بتنزيل تطبيق {name} الجديد",
"Download": "تحميل",
"failed-to-send-otp": "فشل إرسال كلمة المرور، يرجى المحاولة مرة أخرى لاحقًا",
"otp-check-failed": "فشل التحقق من كلمة المرور، يرجى محاولة إرسال رمز جديد",
"recover-password": "إستعادة كلمة المرور",
"recovery-phone-prompt": "الرجاء إدخال رقم الهاتف المرتبط\n\nمع حسابك. \nسنرسل لك رمز التحقق لإعادة تعيين كلمة المرور الخاصة بك",
"phone-not-found": "رقم الهاتف هذا غير مرتبط بأي حساب",
"no-code-received": "لم تحصل على الرمز؟",
"set-new-password": "قم بتعيين كلمة المرور الجديدة الخاصة بك",
"new-password-policy": "كلمات المرور القوية تبقيك آمنًا! \nمزج الحروف الكبيرة والصغيرة والأرقام والرموز",
"set-password": "ضبط كلمة السر",
"go-sign-in": "اذهب لتسجيل الدخول",
"password-updated": "تم الآن تحديث كلمة المرور الخاصة بك. \nيمكنك الآن تسجيل الدخول باستخدام كلمة المرور الجديدة الخاصة بك",
"forgot-password": "هل نسيت كلمة المرور الخاصة بك؟",
"not-found": "غير موجود",
"404-error-message": "عذرا! لم نتمكن من العثور على ما تبحث عنه."
"welcome": "معرف توايك هو مدخلك الوحيد إلى جميع خدمات الدردشة والبريد و الملفات",
"Sign up": "التسجيل",
"Sign in": "تسجيل الدخول",
"First Name": "الاسم",
"Last Name": "اسم العائلة",
"Username": "اسم المستخدم",
"Password": "كلمة المرور",
"Confirm password": "تأكيد كلمة المرور",
"Phone number": "رقم الهاتف",
"uela": "أوافق على <a href='#/ue' class='text-primary'> اتفاقية المستخدم </a> و <a href='#/ue' class='text-primary'> استخدام البيانات الشخصية </a> الشروط بموجب الشروط المنصوص عليها في اتفاقية <a href='#/pp' class='text-primary'> سياسة الخصوصية </a> .",
"Cellphone / Username / Email": "رقم الهاتف / اسم المستخدم / البريد الإلكتروني",
"logged_hero": "معرف تويك هو إدخالك الوحيد الوصول إلى جميع خدماتنا الدردشة والبريد الملفات",
"Congratulations": "تهانينا",
"You are all set up": "لقد تم إعداد كل شيء.",
"logged_twakeid_choose": "قم بتسجيل الدخول إلى الدردشة و الملفات و البريد باستخدام معرف تويك الخاص بك",
"logged_twakeid_choose_mobile": "قم بتسجيل الدخول إلى الملفات و البريد باستخدام بيانات اعتماد تويك",
"twake_chat_description": "الاتصالات المؤسسية اللامركزية تبدأ من هنا",
"tdrive_description": "شارك الملفات وتعاون عليها بشكل آمن، في أي مكان",
"tmail_description": "جرب التواصل عبر البريد الإلكتروني كما لم يحدث من قبل",
"Logout": "تسجيل خروج",
"Matrix ID/Email": "معرف ماتريكس/البريد الإلكتروني",
"username_info_tooltip": "سيتم استخدام اسم المستخدم الذي تدخله لتشكيل معرف ماتريكس الخاص بك بالإضافة إلى عنوان بريد تويك الخاص بك.",
"Ok-got-it": "حسنا ، فهمت",
"username_taken": "عذرا، اسم المستخدم مستعمل",
"weak_password": "كلمة مرور ضعيفة. يجب أن يكون طولها 8 أحرف على الأقل وتحتوي على حرف كبير وحرف صغير ورقم",
"password_mismatch": "كلمات المرور غير متطابقة",
"Number is already registered": "الرقم مسجل سابقا",
"instead": "بدلا",
"6-digit": "أدخل الرمز المكون من 6 أرقام الذي أرسلناه إلى",
"Confirm": "أكد",
"Start your journey": "ابدأ رحلتك",
"Your phone number successfully confirmed": "تم تأكيد رقم هاتفك بنجاح.",
"Error": "خطأ",
"Invalid credentials": "بيانات الاعتماد غير صالحة",
"invalid Username": "اسم المستخدم غير صالح",
"accept terms and conditions": "قبول الشروط والأحكام",
"invalid phone number": "الرقم الذي أدخلته غير صالح. حاول ثانية.",
"login": "تسجيل الدخول",
"hide or show": "إخفاء أو إظهار",
"sign-in-instead": "تسجيل الدخول بدلا من ذلك",
"this-number-is-already-registered-sign-in-instead": "هذا الرقم مسجل سابقا. سجل الدخول بدلا من ذلك.",
"too-many-wrong-attempts-has-been-made-try-again-later": "لقد تم إجراء الكثير من المحاولات الخاطئة. حاول مرة أخرى لاحقا.",
"matrix-id-copied": "تم نسخ معرف متريكس إلى الحافظة",
"mobile-app": "تطبيق الجوال",
"open-twake": "افتح تويك",
"available-usernames": "أسماء المستخدمين المتاحة",
"twake-phone-number": "رقم هاتف تويك",
"twake-matrix-id": "معرف مصفوفة تويك",
"sorry-something-went-wrong-please-try-again": "عذرًا، حدث خطأ ما، يرجى المحاولة مرة أخرى.",
"entered-code-is-incorrect-try-again": "الرمز الذي تم إدخاله غير صحيح. حاول ثانية.",
"twake-mail": "بريد تويك",
"Choose-a-country": "اختر بلدا",
"Search": "بحث",
"Your-phone-number": "رقم الهاتف",
"please-confirm": "يرجى تأكيد رمز البلد الخاص بك وإدخال رقم هاتفك.",
"Next": "التالي",
"Confirm-your-code": "قم بتأكيد الرمز الخاص بك",
"Resend": "إعادة إرسال",
"Resend-in": "إعادة الإرسال في",
"continue-sign-up": "متابعة التسجيل",
"Set-your-password": "عين كلمة المرور الخاصة بك",
"Create-Twake-ID": "إنشاء معرف تويك",
"end-to-end-encryption-collaborative-features-for-secure-and-efficient-teamwork": "تشفير شامل وميزات تعاونية للعمل الجماعي الآمن والفعال",
"set-a-strong-password-with-letters-numbers-and-symbols": "قم بتعيين كلمة مرور قوية مكونة من أحرف وأرقام ورموز",
"Faster-and-more-convenient": "أسرع وأكثر ملاءمة",
"download-app": "قم بتنزيل تطبيق {name} الجديد",
"Download": "تحميل",
"failed-to-send-otp": "فشل إرسال كلمة المرور، يرجى المحاولة مرة أخرى لاحقًا",
"otp-check-failed": "فشل التحقق من كلمة المرور، يرجى محاولة إرسال رمز جديد",
"recover-password": "إستعادة كلمة المرور",
"recovery-phone-prompt": "الرجاء إدخال رقم الهاتف المرتبط\n\nمع حسابك. \nسنرسل لك رمز التحقق لإعادة تعيين كلمة المرور الخاصة بك",
"phone-not-found": "رقم الهاتف هذا غير مرتبط بأي حساب",
"no-code-received": "لم تحصل على الرمز؟",
"set-new-password": "قم بتعيين كلمة المرور الجديدة الخاصة بك",
"new-password-policy": "كلمات المرور القوية تبقيك آمنًا! \nمزج الحروف الكبيرة والصغيرة والأرقام والرموز",
"set-password": "ضبط كلمة السر",
"go-sign-in": "اذهب لتسجيل الدخول",
"password-updated": "تم الآن تحديث كلمة المرور الخاصة بك. \nيمكنك الآن تسجيل الدخول باستخدام كلمة المرور الجديدة الخاصة بك",
"forgot-password": "هل نسيت كلمة المرور الخاصة بك؟",
"not-found": "غير موجود",
"404-error-message": "عذرا! لم نتمكن من العثور على ما تبحث عنه.",
"delete-account": "حذف حسابك"
}
3 changes: 2 additions & 1 deletion registration/src/lib/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,6 @@
"forgot-password": "Forgot your pasword?",
"not-found": "Not found",
"404-error-message": "Oops! We couldn't find what you're looking for.",
"matrix-id-copied": "Matrix Id copied to clipboard"
"matrix-id-copied": "Matrix Id copied to clipboard",
"delete-account": "Delete account"
}
3 changes: 2 additions & 1 deletion registration/src/lib/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,6 @@
"forgot-password": "Vous avez oublié votre mot de passe ?",
"not-found": "Pas trouvé",
"404-error-message": "Oops! Nous n'avons pas trouvé ce que vous cherchez.",
"matrix-id-copied": "Identifiant Matrix copié dans le presse-papiers"
"matrix-id-copied": "Identifiant Matrix copié dans le presse-papiers",
"delete-account": "Supprimer votre compte"
}
3 changes: 2 additions & 1 deletion registration/src/lib/i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,6 @@
"forgot-password": "Забыли свое пасеновое слово?",
"not-found": "Не найдено",
"404-error-message": "Упс! Мы не смогли найти то, что вы ищете.",
"matrix-id-copied": "Идентификатор Matrix скопирован в буфер обмена."
"matrix-id-copied": "Идентификатор Matrix скопирован в буфер обмена.",
"delete-account": "Удалить свой аккаунт"
}
3 changes: 2 additions & 1 deletion registration/src/lib/i18n/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,6 @@
"forgot-password": "Bạn quên mật khẩu?",
"not-found": "Không tìm thấy",
"404-error-message": "Ối! Chúng tôi không thể tìm thấy những gì bạn đang tìm kiếm.",
"matrix-id-copied": "Đã sao chép Id Matrix vào bảng nhớ tạm"
"matrix-id-copied": "Đã sao chép Id Matrix vào bảng nhớ tạm",
"delete-account": "Xóa tài khoản của bạn"
}
24 changes: 24 additions & 0 deletions registration/src/lib/utils/account.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { browser } from '$app/environment';
import { goto } from '$app/navigation';
import { env } from '$env/dynamic/public';
import logger from '$services/logger';

/**
* Send a support mail to request account deletion.
*
* @param {string} user - User to request account deletion.
*/
export const sendAccountDeletionMail = (user: string) => {
if (!browser) return;

const email = env.PUBLIC_SUPPORT_EMAIL ?? 'software@linagora.com';

try {
const subject = `${user} account deletion request`;
const url = `mailto:${email}?subject=${subject}`;

goto(url);
} catch (error) {
logger.error('Failed to send account deletion email to support', { error });
}
};

0 comments on commit 4c4d50e

Please sign in to comment.