diff options
| author | Adam Soltys <[email protected]> | 2024-10-31 09:34:16 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2024-10-31 09:34:16 -0700 |
| commit | 243abb0a3d29e8e34e263eec843488e3bdb468a4 (patch) | |
| tree | be55931ba0f3c110c3001f56a5339cb63e78b761 /src/routes/(app)/otpsecret | |
| parent | 4742e72ec25823ceeea7848fb2e1f868bed7f472 (diff) | |
| download | coinos-ui-243abb0a3d29e8e34e263eec843488e3bdb468a4.tar.gz coinos-ui-243abb0a3d29e8e34e263eec843488e3bdb468a4.zip | |
biome
Diffstat (limited to 'src/routes/(app)/otpsecret')
| -rw-r--r-- | src/routes/(app)/otpsecret/+server.ts | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/routes/(app)/otpsecret/+server.ts b/src/routes/(app)/otpsecret/+server.ts index 9102dd51..7226a7c9 100644 --- a/src/routes/(app)/otpsecret/+server.ts +++ b/src/routes/(app)/otpsecret/+server.ts @@ -3,15 +3,15 @@ import Qr from "qrcode-base64"; import { error } from "@sveltejs/kit"; export async function POST({ cookies, request }) { - try { - let body = await request.json(); - let { username, secret } = await post("/otpsecret", body, auth(cookies)); - let uri = `otpauth://totp/coinos:${username}?secret=${secret}&period=30&digits=6&algorithm=SHA1&issuer=coinos`; - return new Response( - JSON.stringify({ secret, uri, qr: Qr.drawImg(uri, { size: 600 }) }), - ); - } catch (e: any) { - if (e.message.includes("pin")) throw e; - error(500, "Problem saving secret"); - } + try { + const body = await request.json(); + const { username, secret } = await post("/otpsecret", body, auth(cookies)); + const uri = `otpauth://totp/coinos:${username}?secret=${secret}&period=30&digits=6&algorithm=SHA1&issuer=coinos`; + return new Response( + JSON.stringify({ secret, uri, qr: Qr.drawImg(uri, { size: 600 }) }), + ); + } catch (e: any) { + if (e.message.includes("pin")) throw e; + error(500, "Problem saving secret"); + } } |
