aboutsummaryrefslogtreecommitdiffstats
path: root/src/components
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2022-07-26 21:06:01 -0700
committerAdam Soltys <[email protected]>2022-07-26 21:06:01 -0700
commit059613490db9be904791686c49851ec1cc095774 (patch)
treedbf229d10d44b19bac1312b5847d75c4c04d0261 /src/components
parentb13d88d63dbd7ce7df9d6847036d3e36d78f97b2 (diff)
downloadcoinos-ui-059613490db9be904791686c49851ec1cc095774.tar.gz
coinos-ui-059613490db9be904791686c49851ec1cc095774.zip
register endpoint
Diffstat (limited to 'src/components')
-rw-r--r--src/components/RegisterOrLogin.svelte17
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">