Commit 460fe577 authored by Aral Balkan's avatar Aral Balkan
Browse files

Add status indication to sign in

parent cddb0ecb
......@@ -4,8 +4,6 @@ import nacl from 'tweetnacl'
import naclUtil from 'tweetnacl-util'
import sealedBox from 'tweetnacl-sealedbox-js'
let secretPath = null
// Add sealed box functionality to TweetNaCl.
nacl.sealedBox = sealedBox
......@@ -37,7 +35,7 @@ export async function authenticate (passphrase) {
}
// OK, signed in.
secretPath = naclUtil.encodeUTF8(sealedBoxOpenResult)
const secretPath = naclUtil.encodeUTF8(sealedBoxOpenResult)
console.log('secretPath', secretPath)
return secretPath
}
......
......@@ -99,6 +99,11 @@
"xsalsa20": "^1.1.0"
}
},
"svelte-loading-spinners": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/svelte-loading-spinners/-/svelte-loading-spinners-0.1.4.tgz",
"integrity": "sha512-r/0Hs9cxtRLh2RwBwwEat1V1M1kypaGFPllM7XdZSH299JTed994B6zMHJ1Z5Ug8B9Tl2bs+VOy8Vz5EFWy5Ww=="
},
"svelte-switch": {
"version": "0.0.4",
"resolved": "https://registry.npmjs.org/svelte-switch/-/svelte-switch-0.0.4.tgz",
......
......@@ -3,20 +3,22 @@
import { state } from '../state.js'
import Section from './Section.interface'
import { authenticate } from '../authentication.js'
import { BarLoader } from 'svelte-loading-spinners'
const path = '/sign-in'
let { currentSection } = getContext(state)
let passphraseField
let secretPath = undefined
// Make sure the passphrase field has focus if it’s showing.
$: if (passphraseField != undefined) {
passphraseField.focus()
}
async function handleSignIn () {
const secretPath = await authenticate(passphraseField.value)
alert(`Secret path: ${secretPath}`)
function handleSignIn () {
secretPath = authenticate(passphraseField.value)
}
</script>
......@@ -27,4 +29,22 @@
<input bind:this={passphraseField} name='passphrase' type='password'/>
<button>Sign in</button>
</form>
{#await secretPath}
<p>Authenticating…</p>
<BarLoader />
{:then value}
{#if value !== undefined}
{#if value === null}
<p>Sign in failed. Please try again.</p>
{:else}
<p>Secret path is {value}</p>
{/if}
{/if}
{:catch error}
<p style='color: red'>{error.message}</p>
{/await}
</Section>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment