diff --git a/assets/css/inputs.css b/assets/css/inputs.css index f43e079..5b1d27c 100644 --- a/assets/css/inputs.css +++ b/assets/css/inputs.css @@ -23,17 +23,22 @@ .button { display: inline-flex; - align-items: center; + flex-shrink: 0; + align-items: stretch; box-sizing: border-box; - padding: .5rem 1rem; + padding: .5rem 0 .5rem .5rem; border: none; border-radius: .25rem; - background: var(--grey-light-30); - font-size: 1rem; + background: var(--background); + box-shadow: 0 0 3px var(--shadow-weak-30); + color: var(--shadow-strong-30); + font-size: .9rem; font-weight: bold; .icon { - padding: .5rem; + height: auto; + padding: 0 .75rem 0 .25rem; + fill: var(--shadow-strong-20); } &:hover { @@ -51,9 +56,13 @@ } } +.button-label { + margin-right: .75rem; +} + .button-submit { - background: var(--primary-light-10); - color: var(--text-light); + color: var(--primary); + justify-content: center; &:hover:not(:disabled) { background: var(--primary); diff --git a/components/dialog/dialog.vue b/components/dialog/dialog.vue new file mode 100644 index 0000000..3c737ec --- /dev/null +++ b/components/dialog/dialog.vue @@ -0,0 +1,98 @@ + + + + + + + diff --git a/config/default.cjs b/config/default.cjs index 639f5ea..9afb160 100755 --- a/config/default.cjs +++ b/config/default.cjs @@ -65,6 +65,8 @@ module.exports = { usernamePattern: /^[a-zA-Z0-9_-]+$/, }, stashes: { + nameLength: [2, 24], + namePattern: /^[a-zA-Z0-9_-]+$/, viewRefreshCooldown: 60, // minutes }, media: { diff --git a/pages/users/@username/+Page.vue b/pages/users/@username/+Page.vue index d27a247..2f1338a 100644 --- a/pages/users/@username/+Page.vue +++ b/pages/users/@username/+Page.vue @@ -1,87 +1,168 @@ diff --git a/renderer/container.vue b/renderer/container.vue index 6b66233..3747f32 100644 --- a/renderer/container.vue +++ b/renderer/container.vue @@ -61,8 +61,6 @@ onMounted(() => { events.on('scrollUp', () => { content.value.scrollTop = 0; }); events.on('feedback', async (event) => { - console.log(event); - feedback.value = event; await nextTick(); @@ -87,7 +85,7 @@ onMounted(() => { opacity: 0, }, ], { - duration: 3000, + duration: event.type === 'error' ? 5000 : 3000, easing: 'ease-in-out', }); }); diff --git a/src/auth.js b/src/auth.js index 998db0c..132f27d 100755 --- a/src/auth.js +++ b/src/auth.js @@ -47,6 +47,7 @@ export async function login(credentials, userIp) { const { user, stashes } = await fetchUser(credentials.username.trim(), { email: true, raw: true, + includeStashes: true, }).catch(() => { throw new HttpError('Username or password incorrect', 401); }); diff --git a/src/stashes.js b/src/stashes.js index 7856f6a..2872661 100755 --- a/src/stashes.js +++ b/src/stashes.js @@ -22,9 +22,9 @@ export function curateStash(stash, assets = {}) { primary: stash.primary, public: stash.public, createdAt: stash.created_at, - stashedScenes: stash.stashed_scenes || null, - stashedMovies: stash.stashed_movies || null, - stashedActors: stash.stashed_actors || null, + stashedScenes: stash.stashed_scenes ?? null, + stashedMovies: stash.stashed_movies ?? null, + stashedActors: stash.stashed_actors ?? null, user: assets.user ? { id: assets.user.id, username: assets.user.username, @@ -99,6 +99,22 @@ export async function createStash(newStash, sessionUser) { throw new HttpError('You are not authenthicated', 401); } + if (!newStash.name) { + throw new HttpError('Stash name required', 400); + } + + if (newStash.name.length < config.stashes.nameLength[0]) { + throw new HttpError('Stash name is too short', 400); + } + + if (newStash.name.length > config.stashes.nameLength[1]) { + throw new HttpError('Stash name is too long', 400); + } + + if (!config.stashes.namePattern.test(newStash.name)) { + throw new HttpError('Stash name contains invalid characters', 400); + } + try { const stash = await knex('stashes') .insert(curateStashEntry(newStash, sessionUser)) diff --git a/src/users.js b/src/users.js index 32286d3..be038ec 100755 --- a/src/users.js +++ b/src/users.js @@ -53,7 +53,7 @@ export async function fetchUser(userId, options = {}, reqUser) { const stashes = await knex('stashes') .where('user_id', user.id) .modify((builder) => { - if (reqUser?.id !== user.id) { + if (reqUser?.id !== user.id && !options.includeStashes) { builder.where('public', true); } }) diff --git a/src/web/server.js b/src/web/server.js index 9c6b698..27e22f8 100644 --- a/src/web/server.js +++ b/src/web/server.js @@ -25,7 +25,7 @@ import { } from './auth.js'; import { - fetchUserApi + fetchUserApi, } from './users.js'; import {