From f72cee6774c9328925a3a2dcc118e0da8db74999 Mon Sep 17 00:00:00 2001 From: c0repwn3r Date: Tue, 21 Feb 2023 12:11:28 -0500 Subject: [PATCH] half login flow is working --- tfweb/src/lib/cookie.ts | 22 +++++ tfweb/src/lib/i18n/en.json | 14 +++- tfweb/src/routes/auth/login/+page.svelte | 2 +- tfweb/src/routes/auth/magic-link/+page.svelte | 81 ++++++++++++++++++- 4 files changed, 116 insertions(+), 3 deletions(-) create mode 100644 tfweb/src/lib/cookie.ts diff --git a/tfweb/src/lib/cookie.ts b/tfweb/src/lib/cookie.ts new file mode 100644 index 0000000..01e3063 --- /dev/null +++ b/tfweb/src/lib/cookie.ts @@ -0,0 +1,22 @@ +export function setCookie(name: string, value: string, expires: number) { + const d = new Date(); + d.setTime(d.getTime() + expires); + const expires_at = "expires="+ d.toUTCString(); + document.cookie = name + "=" + value + ";" + expires_at + ";path=/"; +} + +function getCookie(name: string): string { + const name_with_equals = name + "="; + const decodedCookie = decodeURIComponent(document.cookie); + const ca = decodedCookie.split(';'); + for(let i = 0; i
- {#if hasError} {error} diff --git a/tfweb/src/routes/auth/magic-link/+page.svelte b/tfweb/src/routes/auth/magic-link/+page.svelte index 029c025..0ed49b2 100644 --- a/tfweb/src/routes/auth/magic-link/+page.svelte +++ b/tfweb/src/routes/auth/magic-link/+page.svelte @@ -1,8 +1,78 @@
@@ -10,8 +80,17 @@ {#if isLoading}

{t('magiclink.loadtitle')}

-

{t('magiclink.loadsubtitle')}

+

{t('magiclink.loadsubtitle')}

+ {:else} + {#if hasError} +

{t('magiclink.failed')}

+

{error}

+ {t('magiclink.tryAgain')} + {:else} +

{t('magiclink.finished')}

+

{t('magiclink.redirecting')}

+ {/if} {/if}
\ No newline at end of file