Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class User < ApplicationRecord
has_many :events, dependent: :destroy
has_one :account_reset_request, dependent: :destroy
has_one :phone_configuration, dependent: :destroy, inverse_of: :user
has_many :webauthn_configurations, dependent: :destroy

validates :x509_dn_uuid, uniqueness: true, allow_nil: true

Expand Down
7 changes: 7 additions & 0 deletions app/models/webauthn_configuration.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class WebauthnConfiguration < ApplicationRecord
belongs_to :user, inverse_of: :webauthn_configuration
validates :user_id, presence: true
validates :name, presence: true
validates :credential_id, presence: true
validates :credential_public_key, presence: true
end
13 changes: 13 additions & 0 deletions db/migrate/20180827225542_create_webauthn_configurations_table.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class CreateWebauthnConfigurationsTable < ActiveRecord::Migration[5.1]
def change
create_table :webauthn_configurations do |t|
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something Jon mentioned the other day that would be good to have is a name for the configuration. I haven't added that to the phone configurations table yet, but plan to "soon."

t.references :user, null: false
t.string :name, null: false
t.text :credential_id, null: false
t.text :credential_public_key, null: false
t.timestamps

t.index ['user_id'], name: "index_webauthn_configurations_on_user_id"
end
end
end
12 changes: 11 additions & 1 deletion 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.define(version: 20180728122856) do
ActiveRecord::Schema.define(version: 20180827225542) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -251,5 +251,15 @@
t.datetime "updated_at", null: false
end

create_table "webauthn_configurations", force: :cascade do |t|
t.bigint "user_id", null: false
t.string "name", null: false
t.text "credential_id", null: false
t.text "credential_public_key", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["user_id"], name: "index_webauthn_configurations_on_user_id"
end

add_foreign_key "events", "users"
end
1 change: 1 addition & 0 deletions spec/models/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
it { is_expected.to have_many(:events) }
it { is_expected.to have_one(:account_reset_request) }
it { is_expected.to have_one(:phone_configuration) }
it { is_expected.to have_many(:webauthn_configurations) }
end

it 'does not send an email when #create is called' do
Expand Down