diff options
| author | Adam Soltys <[email protected]> | 2022-07-26 21:06:01 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2022-07-26 21:06:01 -0700 |
| commit | 12309da2457532d2674aba2e3b02700c5dfeae1d (patch) | |
| tree | dcd873e2a56f2cfc8e5f3bad0c355b3c4a1bb8ed /src/components | |
| parent | 6f2289f358e610a708cdd5d39265889b30b3a7d6 (diff) | |
| download | coinos-ui-12309da2457532d2674aba2e3b02700c5dfeae1d.tar.gz coinos-ui-12309da2457532d2674aba2e3b02700c5dfeae1d.zip | |
register endpoint
Diffstat (limited to 'src/components')
| -rw-r--r-- | src/components/RegisterOrLogin.svelte | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/components/RegisterOrLogin.svelte b/src/components/RegisterOrLogin.svelte index 7cc41709..12d7b8b7 100644 --- a/src/components/RegisterOrLogin.svelte +++ b/src/components/RegisterOrLogin.svelte @@ -2,7 +2,7 @@ import { Icon } from '$comp'; import { post } from '$lib/utils'; import { token } from '$lib/store'; - import { connect } from '$lib/socket'; + import { auth } from '$lib/socket'; import { goto } from '$app/navigation'; export let page; @@ -16,14 +16,13 @@ 'Sign in': '/login' }[page]; - let submit = () => - post(url, { username, password }).then((r) => - r.json().then((r) => { - $token = r.token; - connect(); - goto('/receive'); - }) - ); + let submit = async () => { + let r = await post(url, { username, password }); + if (!r.token) r = await post('/login', { username, password }); + $token = r.token; + auth(); + goto('/receive'); + }; </script> <div class="pt-10"> |
