Skip to content

Instantly share code, notes, and snippets.

@truongnmt
Created January 9, 2022 22:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save truongnmt/c8ee0b31b504ce359c8580509a1c5af6 to your computer and use it in GitHub Desktop.
Save truongnmt/c8ee0b31b504ce359c8580509a1c5af6 to your computer and use it in GitHub Desktop.
credentials_controller.rb
class CredentialsController < ApplicationController
def create
create_options = WebAuthn::Credential.options_for_create(
user: {
id: current_user.webauthn_id,
name: current_user.username,
},
exclude: current_user.credentials.pluck(:external_id)
)
session[:current_registration] = { challenge: create_options.challenge }
respond_to do |format|
format.json { render json: create_options }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment