QR code generator, update readme
Added a QR code code generator that might be used for auth. Updated README with better instructions for setting up Tahoe grid.
This commit is contained in:
parent
ec1ed9e487
commit
70a92cb0e6
7 changed files with 75 additions and 236 deletions
|
@ -1,4 +1,3 @@
|
|||
import qrcode from 'qrcode'
|
||||
import { totp } from '$lib/utils'
|
||||
|
||||
export const load = () => {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<script>
|
||||
import { onDestroy } from 'svelte'
|
||||
import encodeQR from '@paulmillr/qr'
|
||||
|
||||
let { data, form } = $props()
|
||||
|
||||
|
@ -7,6 +8,7 @@
|
|||
let count = $state(form?.seconds ?? data.seconds)
|
||||
|
||||
const timer = setInterval(() => count--, 1000)
|
||||
const qrCode = encodeQR(data.uri, 'svg')
|
||||
|
||||
onDestroy(() => {
|
||||
clearInterval(timer)
|
||||
|
@ -30,6 +32,19 @@
|
|||
<p>Token: {form?.token ?? data.token}.</p>
|
||||
<p>Valid for {count}s.</p>
|
||||
|
||||
{#if qrCode}
|
||||
<div class='qr-code'>
|
||||
{@html qrCode}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<form action='?/getTotp' method='post' enctype='form-data' bind:this={totpForm}>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.qr-code {
|
||||
width: 15em;
|
||||
margin: 0 auto;
|
||||
}
|
||||
</style>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue