From e60c01fc33eb15184f0ceeb001811272723d3526 Mon Sep 17 00:00:00 2001 From: Jordan Doyle Date: Thu, 07 Oct 2021 00:51:20 +0100 Subject: [PATCH] UNIQUE constraint on ssh keys --- migrations/2021-08-31-214501_create_crates_table/up.sql | 2 +- chartered-frontend/src/pages/Dashboard.tsx | 2 +- chartered-web/src/endpoints/web_api/ssh_key.rs | 2 +- chartered-web/src/endpoints/web_api/users/info.rs | 2 +- chartered-web/src/endpoints/web_api/users/search.rs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/migrations/2021-08-31-214501_create_crates_table/up.sql b/migrations/2021-08-31-214501_create_crates_table/up.sql index 3992d01..3c136d1 100644 --- a/migrations/2021-08-31-214501_create_crates_table/up.sql +++ a/migrations/2021-08-31-214501_create_crates_table/up.sql @@ -77,7 +77,7 @@ uuid BINARY(128) NOT NULL UNIQUE, name VARCHAR(255) NOT NULL, user_id INTEGER NOT NULL, - ssh_key BLOB NOT NULL, + ssh_key BLOB NOT NULL UNIQUE, created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, last_used_at DATETIME, FOREIGN KEY (user_id) REFERENCES users (id) diff --git a/chartered-frontend/src/pages/Dashboard.tsx b/chartered-frontend/src/pages/Dashboard.tsx index bc5deff..0db2797 100644 --- a/chartered-frontend/src/pages/Dashboard.tsx +++ a/chartered-frontend/src/pages/Dashboard.tsx @@ -37,7 +37,7 @@ permissions are granted to others.

diff --git a/chartered-web/src/endpoints/web_api/ssh_key.rs b/chartered-web/src/endpoints/web_api/ssh_key.rs index d8c7217..b71d96e 100644 --- a/chartered-web/src/endpoints/web_api/ssh_key.rs +++ a/chartered-web/src/endpoints/web_api/ssh_key.rs @@ -82,7 +82,7 @@ #[derive(Error, Debug)] pub enum Error { - #[error("Failed to query database")] + #[error("{0}")] Database(#[from] chartered_db::Error), #[error("Failed to parse SSH key: {0}")] KeyParse(chartered_db::Error), diff --git a/chartered-web/src/endpoints/web_api/users/info.rs b/chartered-web/src/endpoints/web_api/users/info.rs index 221d581..3349b5f 100644 --- a/chartered-web/src/endpoints/web_api/users/info.rs +++ a/chartered-web/src/endpoints/web_api/users/info.rs @@ -39,7 +39,7 @@ #[derive(Error, Debug)] pub enum Error { - #[error("Failed to query database")] + #[error("{0}")] Database(#[from] chartered_db::Error), #[error("User doesn't exist")] NotFound, diff --git a/chartered-web/src/endpoints/web_api/users/search.rs b/chartered-web/src/endpoints/web_api/users/search.rs index 9278150..b422beb 100644 --- a/chartered-web/src/endpoints/web_api/users/search.rs +++ a/chartered-web/src/endpoints/web_api/users/search.rs @@ -37,7 +37,7 @@ #[derive(Error, Debug)] pub enum Error { - #[error("Failed to query database")] + #[error("{0}")] Database(#[from] chartered_db::Error), } -- rgit 0.1.3