diff options
author | Ilion Beyst <ilion.beyst@gmail.com> | 2022-04-09 11:03:37 +0200 |
---|---|---|
committer | Ilion Beyst <ilion.beyst@gmail.com> | 2022-04-09 11:03:37 +0200 |
commit | 15e40e47911706bb93c35a06166e699419002281 (patch) | |
tree | 567c7cef24122d56c26fa841b36627ea9ede3580 /web | |
parent | f21182ecdf33d19e0bd39bcae7ed3af243f703a5 (diff) | |
download | planetwars.dev-15e40e47911706bb93c35a06166e699419002281.tar.xz planetwars.dev-15e40e47911706bb93c35a06166e699419002281.zip |
auto login after registration
Diffstat (limited to 'web')
-rw-r--r-- | web/pw-server/src/routes/register.svelte | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/web/pw-server/src/routes/register.svelte b/web/pw-server/src/routes/register.svelte index a303025..f09ccad 100644 --- a/web/pw-server/src/routes/register.svelte +++ b/web/pw-server/src/routes/register.svelte @@ -1,4 +1,7 @@ <script lang="ts"> + import * as auth from "$lib/auth"; + import { goto } from "$app/navigation"; + let username: string | undefined; let password: string | undefined; @@ -26,7 +29,10 @@ }), }); - if (!response.ok) { + if (response.ok) { + await auth.login({ username, password }); + goto("/"); + } else { const resp = await response.json(); const error = resp["error"]; if (response.status == 422 && error["type"] === "validation_failed") { |