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 implement mfa creation deletion templates #1252

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/routes/(console)/project-[project]/auth/templates/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
import EmailInviteTemplate from './emailInviteTemplate.svelte';
import Email2FaTemplate from './email2FATemplate.svelte';
import EmailSessionAlertTemplate from './emailSessionAlertTemplate.svelte';
import EmailMfaEnabledTemplate from './emailMfaEnabledTemplate.svelte';
import EmailMfaDisabledTemplate from './emailMfaDisabledTemplate.svelte';

// import SmsVerificationTemplate from './smsVerificationTemplate.svelte';
// import SmsLoginTemplate from './smsLoginTemplate.svelte';
Expand All @@ -72,6 +74,8 @@
$: emailResetPassword = emailOpen === 'recovery';
$: emailInviteUser = emailOpen === 'invitation';
$: email2FAVerificationOpen = emailOpen === 'mfaChallenge';
$: emailMfaEnabledOpen = emailOpen === 'mfaEnabled';
$: emailMfaDisabledOpen = emailOpen === 'mfaDisabled';
$: emailSessionAlertOpen = emailOpen === 'sessionAlert';

// let smsOpen = 'verification';
Expand Down Expand Up @@ -203,6 +207,27 @@
<p class="text">Send a two-factor authentication email to a user.</p>
<Email2FaTemplate />
</CollapsibleItem>
<CollapsibleItem
bind:open={emailMfaEnabledOpen}
on:click={(e) => {
e.preventDefault();
openEmail('mfaEnabled');
}}>
<svelte:fragment slot="title">MFA enabled</svelte:fragment>
<p class="text">Send an email to a user when MFA is enabled.</p>
<EmailMfaEnabledTemplate />
</CollapsibleItem>
<CollapsibleItem
bind:open={emailMfaDisabledOpen}
on:click={(e) => {
e.preventDefault();
openEmail('mfaDisabled');
}}>
<svelte:fragment slot="title">MFA disabled</svelte:fragment>
<p class="text">Send an email to a user when MFA is disabled.</p>
<EmailMfaDisabledTemplate />
</CollapsibleItem>

<CollapsibleItem
bind:open={emailSessionAlertOpen}
on:click={(e) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<script lang="ts">
import EmailTemplate from './emailTemplate.svelte';
import LocaleOptions from './localeOptions.svelte';
import { loadEmailTemplate } from './+page.svelte';
import { page } from '$app/stores';
import { baseEmailTemplate, emailTemplate } from './store';
import { addNotification } from '$lib/stores/notifications';
import { Id } from '$lib/components';
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
const projectId = $page.params.project;
let locale = 'en';
let loading = false;
async function onLocaleChange() {
const timeout = setTimeout(() => {
loading = true;
}, 1000);
try {
const template = await loadEmailTemplate(projectId, 'mfaDisabled', locale);
emailTemplate.set(template);
$baseEmailTemplate = { ...$emailTemplate };
trackEvent(Submit.EmailChangeLocale, { locale, type: 'mfaDisabled' });
} catch (error) {
trackError(error, Submit.EmailChangeLocale);
addNotification({
type: 'error',
message: error.message
});
} finally {
clearTimeout(timeout);
loading = false;
}
}
</script>

<div class="boxes-wrapper u-margin-block-start-16">
<LocaleOptions on:select={onLocaleChange} bind:value={locale} />
<EmailTemplate bind:loading>
<Id value={'{{user}}'}>{'{{user}}'}</Id>
<Id value={'{{project}}'}>{'{{project}}'}</Id>
<Id value={'{{redirect}}'}>{'{{redirect}}'}</Id>
</EmailTemplate>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<script lang="ts">
import EmailTemplate from './emailTemplate.svelte';
import LocaleOptions from './localeOptions.svelte';
import { loadEmailTemplate } from './+page.svelte';
import { page } from '$app/stores';
import { baseEmailTemplate, emailTemplate } from './store';
import { addNotification } from '$lib/stores/notifications';
import { Id } from '$lib/components';
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
const projectId = $page.params.project;
let locale = 'en';
let loading = false;
async function onLocaleChange() {
const timeout = setTimeout(() => {
loading = true;
}, 1000);
try {
const template = await loadEmailTemplate(projectId, 'mfaEnabled', locale);
emailTemplate.set(template);
$baseEmailTemplate = { ...$emailTemplate };
trackEvent(Submit.EmailChangeLocale, { locale, type: 'mfaEnabled' });
} catch (error) {
trackError(error, Submit.EmailChangeLocale);
addNotification({
type: 'error',
message: error.message
});
} finally {
clearTimeout(timeout);
loading = false;
}
}
</script>

<div class="boxes-wrapper u-margin-block-start-16">
<LocaleOptions on:select={onLocaleChange} bind:value={locale} />
<EmailTemplate bind:loading>
<Id value={'{{user}}'}>{'{{user}}'}</Id>
<Id value={'{{project}}'}>{'{{project}}'}</Id>
<Id value={'{{redirect}}'}>{'{{redirect}}'}</Id>
</EmailTemplate>
</div>
Loading