Added functional stash button on scene tiles.

This commit is contained in:
2024-03-03 02:33:35 +01:00
parent 082d4fc154
commit f56e22230b
13 changed files with 657 additions and 73 deletions

View File

@@ -5,7 +5,7 @@ import fs from 'fs/promises';
import { createAvatar } from '@dicebear/core';
import { shapes } from '@dicebear/collection';
import knex from './knex.js';
import { knexOwner as knex } from './knex.js';
import { curateUser, fetchUser } from './users.js';
import { HttpError } from './errors.js';
@@ -38,7 +38,7 @@ async function generateAvatar(user) {
export async function login(credentials) {
if (!config.auth.login) {
throw new HttpError('Authentication is disabled', 405);
throw new HttpError('Logins are currently disabled', 405);
}
const user = await fetchUser(credentials.username.trim(), {
@@ -46,6 +46,8 @@ export async function login(credentials) {
raw: true,
});
console.log('login user', user);
if (!user) {
throw new HttpError('Username or password incorrect', 401);
}
@@ -60,12 +62,13 @@ export async function login(credentials) {
await generateAvatar(user);
}
// fetched the raw user for password verification, don't return directly to user
return curateUser(user);
}
export async function signup(credentials) {
if (!config.auth.signup) {
throw new HttpError('Authentication is disabled', 405);
throw new HttpError('Sign-ups are currently disabled', 405);
}
const curatedUsername = credentials.username.trim();