Drop the need for access tokens to have a session
This commit is contained in:
committed by
Stanko K.R.
parent
660fcff558
commit
895b0e13b8
@@ -1,14 +1,6 @@
|
||||
class Identity::AccessToken < ApplicationRecord
|
||||
belongs_to :identity
|
||||
belongs_to :session
|
||||
|
||||
has_secure_token
|
||||
enum :permission, %w[ read write ].index_by(&:itself), default: :read
|
||||
|
||||
before_validation :build_session, on: :create
|
||||
|
||||
private
|
||||
def build_session
|
||||
self.session = identity.sessions.build(user_agent: "Access Token")
|
||||
end
|
||||
end
|
||||
|
||||
+1
-10
@@ -10,14 +10,5 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[8.2].define(version: 1) do
|
||||
create_table "solid_cable_messages", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||
t.binary "channel", limit: 1024, null: false
|
||||
t.bigint "channel_hash", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.binary "payload", size: :long, null: false
|
||||
t.index ["channel"], name: "index_solid_cable_messages_on_channel"
|
||||
t.index ["channel_hash"], name: "index_solid_cable_messages_on_channel_hash"
|
||||
t.index ["created_at"], name: "index_solid_cable_messages_on_created_at"
|
||||
end
|
||||
ActiveRecord::Schema[8.2].define(version: 0) do
|
||||
end
|
||||
|
||||
@@ -2,7 +2,6 @@ class CreateIdentityAccessTokens < ActiveRecord::Migration[8.2]
|
||||
def change
|
||||
create_table :identity_access_tokens, id: :uuid do |t|
|
||||
t.uuid :identity_id, null: false
|
||||
t.uuid :session_id, null: false
|
||||
t.string :token
|
||||
t.string :permission
|
||||
t.text :description
|
||||
|
||||
Generated
-1
@@ -326,7 +326,6 @@ ActiveRecord::Schema[8.2].define(version: 2025_12_05_010536) do
|
||||
t.text "description"
|
||||
t.uuid "identity_id", null: false
|
||||
t.string "permission"
|
||||
t.uuid "session_id", null: false
|
||||
t.string "token"
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["identity_id"], name: "index_access_token_on_identity_id"
|
||||
|
||||
@@ -326,7 +326,6 @@ ActiveRecord::Schema[8.2].define(version: 2025_12_05_010536) do
|
||||
t.text "description", limit: 65535
|
||||
t.uuid "identity_id", null: false
|
||||
t.string "permission", limit: 255
|
||||
t.uuid "session_id", null: false
|
||||
t.string "token", limit: 255
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["identity_id"], name: "index_access_token_on_identity_id"
|
||||
|
||||
-2
@@ -1,13 +1,11 @@
|
||||
jasons_api_token:
|
||||
identity: jason
|
||||
session: jason_api
|
||||
token: 018cf1425682700098f24f0799e3fe20
|
||||
description: My Superscript
|
||||
permission: read
|
||||
|
||||
davids_api_token:
|
||||
identity: david
|
||||
session: david_api
|
||||
token: x18cf1425682700098f24f0799e3fe20
|
||||
description: My Superscript
|
||||
permission: write
|
||||
|
||||
Vendored
-6
@@ -1,9 +1,6 @@
|
||||
david:
|
||||
identity: david
|
||||
|
||||
david_api:
|
||||
identity: david
|
||||
|
||||
kevin:
|
||||
identity: kevin
|
||||
|
||||
@@ -15,6 +12,3 @@ jason:
|
||||
|
||||
mike:
|
||||
identity: mike
|
||||
|
||||
jason_api:
|
||||
identity: jason
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
require "test_helper"
|
||||
|
||||
class Identity::AccessTokenTest < ActiveSupport::TestCase
|
||||
test "new access token comes with a session" do
|
||||
access_token = identities(:david).access_tokens.create!
|
||||
assert_equal "Access Token", identities(:david).sessions.last.user_agent
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user