Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #76 from Shopify/webauthn-verification-model
Add WebauthnVerification model
- Loading branch information
Showing
9 changed files
with
485 additions
and
395 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class WebauthnVerification < ApplicationRecord | ||
belongs_to :user | ||
|
||
validates :user_id, uniqueness: true | ||
validates :path_token, presence: true, uniqueness: true | ||
validates :path_token_expires_at, presence: true | ||
end |
13 changes: 13 additions & 0 deletions
13
db/migrate/20221214191823_create_webauthn_verifications.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class CreateWebauthnVerifications < ActiveRecord::Migration[7.0] | ||
def change | ||
create_table :webauthn_verifications do |t| | ||
t.string :path_token, limit: 128 | ||
t.datetime :path_token_expires_at | ||
t.string :otp | ||
t.datetime :otp_expires_at | ||
t.references :user, null: false, index: { unique: true }, foreign_key: true | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
require "test_helper" | ||
|
||
class WebauthnVerificationTest < ActiveSupport::TestCase | ||
subject { build(:webauthn_verification) } | ||
|
||
should belong_to :user | ||
|
||
should validate_uniqueness_of(:user_id) | ||
should validate_presence_of(:path_token) | ||
should validate_uniqueness_of(:path_token) | ||
should validate_presence_of(:path_token_expires_at) | ||
end |