Skip to content

Commit

Permalink
fix: accessing keys of session as strings no longer working
Browse files Browse the repository at this point in the history
  • Loading branch information
santiagorodriguez96 committed Dec 8, 2023
1 parent 76fc201 commit 5a65d1c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions app/controllers/credentials_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def create
def callback
webauthn_credential = relying_party.verify_registration(
params,
session["current_registration"]["challenge"],
session[:current_registration][:challenge],
user_verification: true,
)

Expand All @@ -41,7 +41,7 @@ def callback
rescue WebAuthn::Error => e
render json: "Verification failed: #{e.message}", status: :unprocessable_entity
ensure
session.delete("current_registration")
session.delete(:current_registration)
end

def destroy
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ def create
end

def callback
user = User.create!(session["current_registration"]["user_attributes"])
user = User.create!(session[:current_registration][:user_attributes])

begin
webauthn_credential = relying_party.verify_registration(
params,
session["current_registration"]["challenge"],
session[:current_registration][:challenge],
user_verification: true,
)

Expand All @@ -55,7 +55,7 @@ def callback
rescue WebAuthn::Error => e
render json: "Verification failed: #{e.message}", status: :unprocessable_entity
ensure
session.delete("current_registration")
session.delete(:current_registration)
end
end
end
8 changes: 4 additions & 4 deletions app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ def create
end

def callback
user = User.find_by(username: session["current_authentication"]["username"])
raise "user #{session["current_authentication"]["username"]} never initiated sign up" unless user
user = User.find_by(username: session[:current_authentication][:username])
raise "user #{session[:current_authentication][:username]} never initiated sign up" unless user

begin
verified_webauthn_credential, stored_credential = relying_party.verify_authentication(
params,
session["current_authentication"]["challenge"],
session[:current_authentication][:challenge],
user_verification: true,
) do |webauthn_credential|
user.credentials.find_by(external_id: Base64.strict_encode64(webauthn_credential.raw_id))
Expand All @@ -45,7 +45,7 @@ def callback
rescue WebAuthn::Error => e
render json: "Verification failed: #{e.message}", status: :unprocessable_entity
ensure
session.delete("current_authentication")
session.delete(:current_authentication)
end
end

Expand Down

0 comments on commit 5a65d1c

Please sign in to comment.