From 216a600224fde22ce76b367557a02094ec693886 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 1 Dec 2023 20:04:13 -0800 Subject: prettier --- src/routes/(app)/otpsecret/+server.js | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'src/routes/(app)/otpsecret/+server.js') diff --git a/src/routes/(app)/otpsecret/+server.js b/src/routes/(app)/otpsecret/+server.js index 7d5c1ad9..63d06849 100644 --- a/src/routes/(app)/otpsecret/+server.js +++ b/src/routes/(app)/otpsecret/+server.js @@ -1,15 +1,17 @@ -import { auth, post } from '$lib/utils'; -import Qr from 'qrcode-base64'; -import { error } from '@sveltejs/kit'; +import { auth, post } from "$lib/utils"; +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) { - if (e.message.includes('pin')) throw e; - throw new error(500, 'Problem saving secret'); - } + 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) { + if (e.message.includes("pin")) throw e; + throw new error(500, "Problem saving secret"); + } } -- cgit v1.2.3