Merge remote-tracking branch 'origin/dev'

new file:   debug/adduser.mjs
modified:   f0ck.sql
	modified:   package.json
This commit is contained in:
Flummi 2022-05-16 12:58:52 +00:00
commit 77c00de69a
3 changed files with 38 additions and 1 deletions

35
debug/adduser.mjs Normal file
View File

@ -0,0 +1,35 @@
import db from '../src/inc/sql.mjs';
import lib from '../src/inc/lib.mjs';
import readline from 'node:readline/promises';
import stream from 'stream';
const _args = process.argv[2];
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
const newuser = _args?.length ? _args : await rl.question('username: ');
const password = await rl.question('password: ');
const level = +(await rl.question('level (0-100): '));
rl.close();
if(!newuser.length || !password.length) {
console.log('nope lol');
process.exit();
}
const id = (await db`
insert into "user" ${
db({
login: newuser.toLowerCase(),
user: newuser,
password: await lib.hash(password),
level: level >= 0 && level <= 100 ? level : 0
})
}
returning id
`)[0]?.id;
console.log(`created new user ${newuser} with ID ${id}`);
process.exit();

View File

@ -11,6 +11,7 @@ SET xmloption = content;
SET client_min_messages = warning; SET client_min_messages = warning;
SET row_security = off; SET row_security = off;
CREATE EXTENSION unaccent;
CREATE FUNCTION public.delete_unused_tags() RETURNS trigger CREATE FUNCTION public.delete_unused_tags() RETURNS trigger
LANGUAGE plpgsql LANGUAGE plpgsql
AS $$ AS $$

View File

@ -9,7 +9,8 @@
"autotagger": "node --experimental-json-modules debug/autotagger.mjs", "autotagger": "node --experimental-json-modules debug/autotagger.mjs",
"thumbnailer": "node --experimental-json-modules debug/thumbnailer.mjs", "thumbnailer": "node --experimental-json-modules debug/thumbnailer.mjs",
"test": "node --experimental-json-modules debug/test.mjs", "test": "node --experimental-json-modules debug/test.mjs",
"clean": "node --experimental-json-modules debug/clean.mjs" "clean": "node --experimental-json-modules debug/clean.mjs",
"adduser": "node --experimental-json-modules debug/adduser.mjs"
}, },
"author": "Flummi", "author": "Flummi",
"license": "MIT", "license": "MIT",