some beta stuff

This commit is contained in:
biglyderv 2025-02-26 22:12:46 -05:00
parent 2c480909ee
commit 4eddd1a0c7
Signed by: biglyderv
GPG key ID: 0E2EB0B4CD7397B5
7 changed files with 82 additions and 9 deletions

View file

@ -3,6 +3,7 @@ import { apiStat } from "../lib.js";
import { hash, compare } from "bcrypt";
import { initDb } from "../db.js";
import { randomBytes } from 'node:crypto';
import { rename } from 'node:fs/promises';
let db = await initDb();
@ -14,6 +15,21 @@ function legalName(user) {
return user.search(/[^A-Za-z0-9\-\_]/g) == -1;
}
router.post('/settings', async (req, res, next) => {
let {file} = req;
let {username, valid} = res.auth;
console.log(file)
if (!valid) return;
if (file) {
await rename(file.path,`./uploads/pfp_${username}.png`);
}
next();
});
router.post('/logout', (req, res, next) => {
res.clearCookie('token');
apiStat(res, next, `Goodbye!`, '/');