aboutsummaryrefslogtreecommitdiffstats
path: root/routes/users.ts
diff options
context:
space:
mode:
Diffstat (limited to 'routes/users.ts')
-rw-r--r--routes/users.ts15
1 files changed, 14 insertions, 1 deletions
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);