davidwparker/programmingtil-rails

Error on logout

ZubinDv opened this issue · 2 comments

while signing out, the session entry from allowlisted_jwts table is supposed to be deleted via call to revoke_jwt method in the module, its fetching the session record fine but gives this error ERROR: column allowlisted_jwts.allowlisted_jwt_id does not exist (PG::UndefinedColumn) on attempting delete

 # @see Warden::JWTAuth::Interfaces::RevocationStrategy#revoke_jwt
        def self.revoke_jwt(payload, user)
            jwt = user.allowlisted_jwts.find_by({"jti"=>payload['jti'], "aud"=>payload['aud'].presence || 'UNKNOWN'})
            jwt.destroy! if jwt
        end

Its looking for non existent allowlisted_jwt_id column in allowlisted_jwts table.

image

@ZubinDv - what episode / branch?
What's your allowlisted_jwts table look like?

@ZubinDv - what episode / branch? What's your allowlisted_jwts table look like?

I cloned the main branch, no changes in the allowedlisted_jwts migrations

class CreateJwtAllowlist < ActiveRecord::Migration[7.0]
  def change
    create_table :allowlisted_jwts do |t|
      t.references :user, foreign_key: { on_delete: :cascade }, null: false
      t.string :jti, null: false
      t.string :aud, null: false
      t.datetime :expiry, null: false
      t.string :remote_ip
      t.string :os_data
      t.string :browser_data
      t.string :device_data
      t.timestamps null: false
    end
    add_index :allowlisted_jwts, :jti, unique: true
  end
end

Here's it from Schema

create_table "allowlisted_jwts", force: :cascade do |t|
    t.bigint "user_id", null: false
    t.string "jti", null: false
    t.string "aud", null: false
    t.datetime "expiry", null: false
    t.string "remote_ip"
    t.string "os_data"
    t.string "browser_data"
    t.string "device_data"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.index ["jti"], name: "index_allowlisted_jwts_on_jti", unique: true
    t.index ["user_id"], name: "index_allowlisted_jwts_on_user_id"
  end