aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/register.ts1
-rw-r--r--routes/users.ts15
2 files changed, 15 insertions, 1 deletions
diff --git a/lib/register.ts b/lib/register.ts
index 86a816a8..492e6034 100644
--- a/lib/register.ts
+++ b/lib/register.ts
@@ -79,6 +79,7 @@ export default async (user, ip) => {
max_amount: 10000,
budget_renewal: "weekly",
name: username,
+ created: Date.now(),
};
await s(`app:${app.pubkey}`, app);
diff --git a/routes/users.ts b/routes/users.ts
index 9d133ff3..604bdbf5 100644
--- a/routes/users.ts
+++ b/routes/users.ts
@@ -862,11 +862,24 @@ export default {
const { user } = req;
const uid = user.id;
let app = await g(pubkey);
+
if (app && uid !== app.uid) fail("Unauthorized");
if (secret) pubkey = getPublicKey(secret);
- app = { ...app, pubkey, max_amount, budget_renewal, name, uid, secret };
+
+ app = {
+ ...app,
+ pubkey,
+ max_amount,
+ budget_renewal,
+ name,
+ uid,
+ secret,
+ created: Date.now(),
+ };
+
await s(`app:${pubkey}`, app);
await db.sAdd(`${uid}:apps`, pubkey);
+
res.send({});
} catch (e) {
console.log(e);