mirror of
https://github.com/MercuryWorkshop/adrift.git
synced 2025-05-12 22:00:02 -04:00
add account creation and auth error handling
This commit is contained in:
parent
bf7bbbd68a
commit
15160ca408
2 changed files with 64 additions and 21 deletions
|
@ -0,0 +1,9 @@
|
||||||
|
<script lang="ts">
|
||||||
|
import { Card } from "m3-svelte";
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="h-full w-full p-5">
|
||||||
|
<Card type="elevated">
|
||||||
|
<h1>Step 1</h1>
|
||||||
|
</Card>
|
||||||
|
</div>
|
|
@ -13,6 +13,7 @@
|
||||||
CircularProgressIndeterminate,
|
CircularProgressIndeterminate,
|
||||||
Dialog,
|
Dialog,
|
||||||
RadioAnim3,
|
RadioAnim3,
|
||||||
|
SnackbarAnim,
|
||||||
StyleFromScheme,
|
StyleFromScheme,
|
||||||
TextField,
|
TextField,
|
||||||
} from "m3-svelte";
|
} from "m3-svelte";
|
||||||
|
@ -30,12 +31,15 @@
|
||||||
import TrackerList from "tracker-list";
|
import TrackerList from "tracker-list";
|
||||||
import {
|
import {
|
||||||
browserLocalPersistence,
|
browserLocalPersistence,
|
||||||
|
createUserWithEmailAndPassword,
|
||||||
getAuth,
|
getAuth,
|
||||||
setPersistence,
|
setPersistence,
|
||||||
signInWithEmailAndPassword,
|
signInWithEmailAndPassword,
|
||||||
} from "firebase/auth";
|
} from "firebase/auth";
|
||||||
|
|
||||||
import logo from "./logo.png";
|
import logo from "./logo.png";
|
||||||
|
import AccountCreation from "./AccountCreation.svelte";
|
||||||
|
import { SnackbarIn } from "m3-svelte/package/containers/Snackbar.svelte";
|
||||||
|
|
||||||
enum ReadyState {
|
enum ReadyState {
|
||||||
Idle,
|
Idle,
|
||||||
|
@ -60,6 +64,10 @@
|
||||||
|
|
||||||
let showTrackerList = false;
|
let showTrackerList = false;
|
||||||
|
|
||||||
|
let createaccount = false;
|
||||||
|
|
||||||
|
let snackbar: (data: SnackbarIn) => void;
|
||||||
|
|
||||||
async function onTransportOpen() {
|
async function onTransportOpen() {
|
||||||
console.log("Transport opened");
|
console.log("Transport opened");
|
||||||
|
|
||||||
|
@ -168,8 +176,6 @@
|
||||||
|
|
||||||
{#if state == ReadyState.Connected}
|
{#if state == ReadyState.Connected}
|
||||||
<Proxy />
|
<Proxy />
|
||||||
{:else if state == ReadyState.AccountCreation}
|
|
||||||
<AccountCreationScreen />
|
|
||||||
{:else if state == ReadyState.Connecting}
|
{:else if state == ReadyState.Connecting}
|
||||||
<div class="h-full w-full flex justify-center items-center">
|
<div class="h-full w-full flex justify-center items-center">
|
||||||
<Card type="outlined">
|
<Card type="outlined">
|
||||||
|
@ -197,21 +203,9 @@
|
||||||
<Icon icon="material-symbols:sailing" />
|
<Icon icon="material-symbols:sailing" />
|
||||||
<p class="text-2xl ml-3">Adrift</p>
|
<p class="text-2xl ml-3">Adrift</p>
|
||||||
</div>
|
</div>
|
||||||
<!-- <img height="100" width="100" src={logo} /> -->
|
|
||||||
<!-- <h3 class="text-xl">(logo goes here)</h3> -->
|
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
<div id="nav">
|
<div id="nav" />
|
||||||
<!-- <Card type="outlined">
|
|
||||||
<div id="quickmenu">
|
|
||||||
<a href="httsp" class="text-med m-2">About</a>
|
|
||||||
<a
|
|
||||||
href="https://github.com/MercuryWorkshop/adrift"
|
|
||||||
class="text-med m-2">Source</a
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</Card> -->
|
|
||||||
</div>
|
|
||||||
<div id="links">
|
<div id="links">
|
||||||
<Card type="elevated">
|
<Card type="elevated">
|
||||||
<div class="flex">
|
<div class="flex">
|
||||||
|
@ -306,9 +300,9 @@
|
||||||
|
|
||||||
<Dialog headline="WARNING" bind:open={showSwarmWarning}>
|
<Dialog headline="WARNING" bind:open={showSwarmWarning}>
|
||||||
<h2 class="text-2xl">
|
<h2 class="text-2xl">
|
||||||
TLS has not currently been implemented for the Adrift Swarm. Your
|
TLS has not currently been implemented for the Adrift Swarm. It
|
||||||
data will not be private, and you should not sign into any
|
will later, but until then your data will not be private, and you
|
||||||
accounts that you care much about
|
should not enter any sensitive information on any page
|
||||||
</h2>
|
</h2>
|
||||||
<br />
|
<br />
|
||||||
<Button type="filled" on:click={() => (showLogin = false)}
|
<Button type="filled" on:click={() => (showLogin = false)}
|
||||||
|
@ -322,7 +316,7 @@
|
||||||
<Dialog headline="Log in to connect" bind:open={showLogin}>
|
<Dialog headline="Log in to connect" bind:open={showLogin}>
|
||||||
<button
|
<button
|
||||||
class="text-primary my-3"
|
class="text-primary my-3"
|
||||||
on:click={() => (state = ReadyState.AccountCreation)}
|
on:click={() => ((createaccount = true), (showLogin = false))}
|
||||||
>New here? Create an account</button
|
>New here? Create an account</button
|
||||||
>
|
>
|
||||||
<br />
|
<br />
|
||||||
|
@ -340,12 +334,51 @@
|
||||||
<Button
|
<Button
|
||||||
type="filled"
|
type="filled"
|
||||||
on:click={async () => {
|
on:click={async () => {
|
||||||
await signInWithEmailAndPassword(getAuth(), email, password);
|
try {
|
||||||
connectAccount();
|
await signInWithEmailAndPassword(
|
||||||
|
getAuth(),
|
||||||
|
email,
|
||||||
|
password
|
||||||
|
);
|
||||||
|
connectAccount();
|
||||||
|
} catch (e) {
|
||||||
|
snackbar({ message: e, closable: true });
|
||||||
|
}
|
||||||
}}>Connect</Button
|
}}>Connect</Button
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
<Dialog bind:open={createaccount} headline="Create an account">
|
||||||
|
<TextField name="email" bind:value={email} />
|
||||||
|
<TextField
|
||||||
|
name="password"
|
||||||
|
bind:value={password}
|
||||||
|
extraOptions={{ type: "password" }}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Note: to be able to connect, you'll need to download an exit node
|
||||||
|
and run it on a computer with an uncensored internet connection
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="flex mt-5">
|
||||||
|
<Button
|
||||||
|
type="filled"
|
||||||
|
on:click={async () => {
|
||||||
|
try {
|
||||||
|
await createUserWithEmailAndPassword(
|
||||||
|
getAuth(),
|
||||||
|
email,
|
||||||
|
password
|
||||||
|
);
|
||||||
|
createaccount = false;
|
||||||
|
} catch (e) {
|
||||||
|
snackbar({ message: e, closable: true });
|
||||||
|
}
|
||||||
|
}}>Create Account</Button
|
||||||
|
>
|
||||||
|
</div></Dialog
|
||||||
|
>
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex m-4">
|
<div class="flex m-4">
|
||||||
|
@ -389,6 +422,7 @@
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
<svelte:component this={SnackbarAnim} bind:show={snackbar} />
|
||||||
|
|
||||||
<StyleFromScheme
|
<StyleFromScheme
|
||||||
lightScheme={{
|
lightScheme={{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue