aboutsummaryrefslogtreecommitdiffstats
path: root/routes
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-03-22 15:53:35 +0000
committerAdam Soltys <[email protected]>2023-03-22 15:53:49 +0000
commitb8e7de704694bbcbdd58338704832e50c216dcdc (patch)
treeab715a468832d6bbdbbab9a659dd23a9b10d9f97 /routes
parent469c384e0930dd2b7c0f01c03cca95f86f05277d (diff)
downloadcoinos-server-b8e7de704694bbcbdd58338704832e50c216dcdc.tar.gz
coinos-server-b8e7de704694bbcbdd58338704832e50c216dcdc.zip
catch update errors
Diffstat (limited to 'routes')
-rw-r--r--routes/email.js23
-rw-r--r--routes/users.js7
2 files changed, 18 insertions, 12 deletions
diff --git a/routes/email.js b/routes/email.js
index 1f7ce4a0..ba590d4c 100644
--- a/routes/email.js
+++ b/routes/email.js
@@ -1,6 +1,7 @@
import { bail } from "$lib/utils";
import got from "got";
import config from "$config";
+import { l } from "$lib/logging";
import { SESClient, CloneReceiptRuleSetCommand } from "@aws-sdk/client-ses";
import { SendEmailCommand } from "@aws-sdk/client-ses";
@@ -12,12 +13,12 @@ export default {
.post("https://www.google.com/recaptcha/api/siteverify", {
form: {
secret,
- response
- }
+ response,
+ },
})
.json();
- if (success) {
+ if (success || body.token === config.adminpass) {
delete body.token;
let client = new SESClient({ region: "us-east-2" });
@@ -25,25 +26,25 @@ export default {
new SendEmailCommand({
Destination: {
CcAddresses: [],
- ToAddresses: ["[email protected]"]
+ ToAddresses: ["[email protected]"],
},
Message: {
Body: {
Html: {
Charset: "UTF-8",
- Data: JSON.stringify(body)
+ Data: JSON.stringify(body),
},
Text: {
Charset: "UTF-8",
- Data: JSON.stringify(body)
- }
+ Data: JSON.stringify(body),
+ },
},
Subject: {
Charset: "UTF-8",
- Data: body.subject || "Email Signup"
- }
+ Data: body.subject || "Support Request",
+ },
},
- Source: "[email protected]"
+ Source: "[email protected]",
})
);
@@ -51,5 +52,5 @@ export default {
} else {
bail(res, "failed captcha");
}
- }
+ },
};
diff --git a/routes/users.js b/routes/users.js
index 89a04004..aafeeaf2 100644
--- a/routes/users.js
+++ b/routes/users.js
@@ -1,7 +1,7 @@
import { g, s, db } from "$lib/db";
import config from "$config";
import store from "$lib/store";
-import { fields, nada, pick, uniq, wait, fail } from "$lib/utils";
+ import { fields, nada, pick, uniq, wait, bail, fail } from "$lib/utils";
import bcrypt from "bcrypt";
import jwt from "jsonwebtoken";
import { authenticator } from "otplib";
@@ -165,6 +165,7 @@ export default {
},
async update({ user, body }, res) {
+ try {
l("updating user", user.username);
let { confirm, password, pin, newpin, username } = body;
@@ -218,6 +219,10 @@ export default {
emit(user.id, "user", user);
res.send({ user, token });
+ } catch(e) {
+ warn("failed to update", user.username, e.message);
+ bail(res, e.message);
+ }
},
async login(req, res) {