From 733a4c9b2d7bf9ac7c564adf11e6acc815f93a01 Mon Sep 17 00:00:00 2001 From: Brian Ginsburg Date: Fri, 22 Jul 2022 13:13:20 -0700 Subject: [PATCH] Add username check at registration Co-authored-by: Jess Martin --- src/components/auth/Register.svelte | 58 +++++++++++++++++++++++------ src/lib/common/webnative.ts | 8 ++++ 2 files changed, 54 insertions(+), 12 deletions(-) diff --git a/src/components/auth/Register.svelte b/src/components/auth/Register.svelte index 71953de..bac8070 100644 --- a/src/components/auth/Register.svelte +++ b/src/components/auth/Register.svelte @@ -1,17 +1,25 @@ @@ -22,12 +30,33 @@

Choose a username

-
+ + {#if !(username.length === 0)} + + {/if} +
Back - +
diff --git a/src/lib/common/webnative.ts b/src/lib/common/webnative.ts index c563617..d8270ae 100644 --- a/src/lib/common/webnative.ts +++ b/src/lib/common/webnative.ts @@ -4,6 +4,7 @@ import type FileSystem from 'webnative/fs/index' import { USE_WNFS_IMPLEMENTATION } from 'webnative/auth/implementation/use-wnfs' import { setup } from 'webnative' +// runfission.net = staging setup.endpoints({ api: 'https://runfission.net', user: 'fissionuser.net' }) setup.setImplementations({ auth: USE_WNFS_IMPLEMENTATION.auth }) @@ -56,6 +57,13 @@ export const initialize = async (): Promise => { } } +export const isUsernameValid = async (username: string): Promise => { + return webnative.account.isUsernameValid(username) +} + +export const isUsernameAvailable = async (username: string): Promise => { + return webnative.account.isUsernameAvailable(username) +} // interface StateFS { // fs?: FileSystem // }