From 65daeb0247b49e1f7dd85ed28543041c242d31ca Mon Sep 17 00:00:00 2001 From: Zutatensuppe Date: Sun, 11 Jul 2021 18:44:59 +0200 Subject: [PATCH] only let uploader edit image --- src/common/Types.ts | 1 + src/dbpatches/03_users.sqlite | 45 +++++++++++++++++++++++++ src/frontend/components/ImageTeaser.vue | 10 ++++-- src/frontend/main.ts | 8 +++-- src/frontend/views/NewGame.vue | 10 ++++-- src/server/Images.ts | 3 ++ src/server/main.ts | 45 +++++++++++++++++++++++++ 7 files changed, 115 insertions(+), 7 deletions(-) create mode 100644 src/dbpatches/03_users.sqlite diff --git a/src/common/Types.ts b/src/common/Types.ts index 71840bf..acf0d7b 100644 --- a/src/common/Types.ts +++ b/src/common/Types.ts @@ -155,6 +155,7 @@ export interface PieceChange { export interface ImageInfo { id: number + uploaderUserId: number|null filename: string url: string title: string diff --git a/src/dbpatches/03_users.sqlite b/src/dbpatches/03_users.sqlite new file mode 100644 index 0000000..c71908f --- /dev/null +++ b/src/dbpatches/03_users.sqlite @@ -0,0 +1,45 @@ +CREATE TABLE users ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + + created TIMESTAMP NOT NULL, + + client_id TEXT NOT NULL, + client_secret TEXT NOT NULL +); + +CREATE TABLE images_new ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + uploader_user_id INTEGER, + + created TIMESTAMP NOT NULL, + + filename TEXT NOT NULL UNIQUE, + filename_original TEXT NOT NULL, + title TEXT NOT NULL, + + width INTEGER NOT NULL, + height INTEGER NOT NULL +); + +CREATE TABLE image_x_category_new ( + image_id INTEGER NOT NULL, + category_id INTEGER NOT NULL +); + +INSERT INTO images_new +SELECT id, NULL, created, filename, filename_original, title, width, height +FROM images; + +INSERT INTO image_x_category_new +SELECT image_id, category_id +FROM image_x_category; + +PRAGMA foreign_keys = OFF; + +DROP TABLE images; +DROP TABLE image_x_category; + +ALTER TABLE images_new RENAME TO images; +ALTER TABLE image_x_category_new RENAME TO image_x_category; + +PRAGMA foreign_keys = ON; diff --git a/src/frontend/components/ImageTeaser.vue b/src/frontend/components/ImageTeaser.vue index 770de91..a5fd78d 100644 --- a/src/frontend/components/ImageTeaser.vue +++ b/src/frontend/components/ImageTeaser.vue @@ -3,7 +3,7 @@ class="imageteaser" :style="style" @click="onClick"> -
✏️
+
✏️