Skip to content

Commit

Permalink
Adding an API Key per user
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Melhaya committed Jul 2, 2024
1 parent 04fc65c commit 2974af6
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
8 changes: 7 additions & 1 deletion app/views/users/show.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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')

Check warning on line 128 in app/views/users/show.html.slim

View workflow job for this annotation

GitHub Actions / Slim-Lint Report

slim-lint

No blank line in the end of file
1 change: 1 addition & 0 deletions config/locales/de/views/users.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions config/locales/en/views/users.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions db/migrate/20240702113838_add_personal_api_key_to_users.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddPersonalApiKeyToUsers < ActiveRecord::Migration[7.1]

Check warning on line 1 in db/migrate/20240702113838_add_personal_api_key_to_users.rb

View workflow job for this annotation

GitHub Actions / lint

[rubocop] reported by reviewdog 🐶 Missing frozen string literal comment. Raw Output: db/migrate/20240702113838_add_personal_api_key_to_users.rb:1:1: C: Style/FrozenStringLiteralComment: Missing frozen string literal comment.

Check warning on line 1 in db/migrate/20240702113838_add_personal_api_key_to_users.rb

View workflow job for this annotation

GitHub Actions / lint

[rubocop] reported by reviewdog 🐶 Missing frozen string literal comment. Raw Output: db/migrate/20240702113838_add_personal_api_key_to_users.rb:1:1: C: Style/FrozenStringLiteralComment: Missing frozen string literal comment.
def change
add_column :users, :personal_api_key, :string
end
end
5 changes: 3 additions & 2 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2974af6

Please sign in to comment.