update tokens

This commit is contained in:
Chris
2025-11-12 01:01:03 -05:00
parent 774d64b98c
commit 43237df2b8
6 changed files with 16 additions and 4 deletions

View File

@@ -6,13 +6,15 @@
# access_token :string not null
# expires_at :datetime
# last_used_at :datetime
# name :string not null
# created_at :datetime not null
# updated_at :datetime not null
# user_id :bigint not null
#
# Indexes
#
# index_api_tokens_on_user_id (user_id)
# index_api_tokens_on_access_token (access_token) UNIQUE
# index_api_tokens_on_user_id (user_id)
#
# Foreign Keys
#

View File

@@ -1,5 +1,9 @@
<%= form_with model: api_token do |form| %>
<%= render "shared/error_messages", resource: form.object %>
<div class="form-group">
<%= form.label :name %>
<%= form.text_field :name, class: "input input-bordered w-full max-w-sm", required: true, placeholder: "my-api-token" %>
</div>
<%= render "api_tokens/expiry_date_field", form: form %>
<div class="form-footer">

View File

@@ -1,6 +1,6 @@
<%= settings_layout do %>
<%= turbo_frame_tag "api_token" do %>
<div class="font-lg font-bold mt-4">
<div class="font-lg font-bold my-4">
Add API Token
</div>
<%= render "api_tokens/form", api_token: @api_token %>

View File

@@ -2,10 +2,12 @@ class CreateApiTokens < ActiveRecord::Migration[7.2]
def change
create_table :api_tokens do |t|
t.references :user, null: false, foreign_key: true
t.string :name, null: false
t.string :access_token, null: false
t.datetime :last_used_at
t.datetime :expires_at
t.timestamps
end
add_index :api_tokens, :access_token, unique: true
end
end

View File

@@ -6,13 +6,15 @@
# access_token :string not null
# expires_at :datetime
# last_used_at :datetime
# name :string not null
# created_at :datetime not null
# updated_at :datetime not null
# user_id :bigint not null
#
# Indexes
#
# index_api_tokens_on_user_id (user_id)
# index_api_tokens_on_access_token (access_token) UNIQUE
# index_api_tokens_on_user_id (user_id)
#
# Foreign Keys
#

View File

@@ -6,13 +6,15 @@
# access_token :string not null
# expires_at :datetime
# last_used_at :datetime
# name :string not null
# created_at :datetime not null
# updated_at :datetime not null
# user_id :bigint not null
#
# Indexes
#
# index_api_tokens_on_user_id (user_id)
# index_api_tokens_on_access_token (access_token) UNIQUE
# index_api_tokens_on_user_id (user_id)
#
# Foreign Keys
#