From 2974af672585da3b91189db9bce5dddc869f28f4 Mon Sep 17 00:00:00 2001 From: Melhaya Date: Tue, 2 Jul 2024 13:58:42 +0200 Subject: [PATCH] Adding an API Key per user Having an API key per user will allow users to utilize the AI capabilities within CodeHarbor (i.e. Unittest generator) This is still a WiP --- app/views/users/show.html.slim | 8 +++++++- config/locales/de/views/users.yml | 1 + config/locales/en/views/users.yml | 1 + .../20240702113838_add_personal_api_key_to_users.rb | 5 +++++ db/schema.rb | 5 +++-- 5 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20240702113838_add_personal_api_key_to_users.rb diff --git a/app/views/users/show.html.slim b/app/views/users/show.html.slim index 17f8945c9..c7cf095ab 100644 --- a/app/views/users/show.html.slim +++ b/app/views/users/show.html.slim @@ -46,6 +46,12 @@ | : .col.row-value = @user.email + .row + .col-auto.row-label + = t('.personal_api_key') + | : + .col.row-value + = @user.personal_api_key .row.vertical .col.row-label = t('.account_links.created') @@ -119,4 +125,4 @@ li = t('users.shared.notification_modal.delete_modal.content.groups_2') li - = t('users.shared.notification_modal.delete_modal.content.groups_3') + = t('users.shared.notification_modal.delete_modal.content.groups_3') \ No newline at end of file diff --git a/config/locales/de/views/users.yml b/config/locales/de/views/users.yml index 8b200eed6..5e3b963c1 100644 --- a/config/locales/de/views/users.yml +++ b/config/locales/de/views/users.yml @@ -34,6 +34,7 @@ de: delete_modal: title: Warnung full_name: Vollständiger Name + personal_api_key: Persönlicher API-Schlüssel private_information: Private Informationen public_information: Öffentliche Informationen send_message: Nachricht senden diff --git a/config/locales/en/views/users.yml b/config/locales/en/views/users.yml index fd68d9d68..1234c0ac1 100644 --- a/config/locales/en/views/users.yml +++ b/config/locales/en/views/users.yml @@ -34,6 +34,7 @@ en: delete_modal: title: Warning full_name: Full name + personal_api_key: Personal API Key private_information: Private Information public_information: Public Information send_message: Send Message diff --git a/db/migrate/20240702113838_add_personal_api_key_to_users.rb b/db/migrate/20240702113838_add_personal_api_key_to_users.rb new file mode 100644 index 000000000..cc18a13dd --- /dev/null +++ b/db/migrate/20240702113838_add_personal_api_key_to_users.rb @@ -0,0 +1,5 @@ +class AddPersonalApiKeyToUsers < ActiveRecord::Migration[7.1] + def change + add_column :users, :personal_api_key, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 872c1c906..d639be9cb 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2024_05_31_160738) do +ActiveRecord::Schema[7.1].define(version: 2024_07_02_113838) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" enable_extension "plpgsql" @@ -326,7 +326,8 @@ t.datetime "locked_at" t.string "preferred_locale" t.boolean "password_set", default: true, null: false - t.integer "status_group", limit: 1, default: 0, null: false, comment: "Used as enum in Rails" + t.integer "status_group", limit: 2, default: 0, null: false, comment: "Used as enum in Rails" + t.string "personal_api_key" t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true t.index ["email"], name: "index_users_on_email", unique: true t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true