some beta stuff
This commit is contained in:
parent
2c480909ee
commit
4eddd1a0c7
7 changed files with 82 additions and 9 deletions
|
@ -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!`, '/');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue