Created
January 9, 2022 22:14
-
-
Save truongnmt/c8ee0b31b504ce359c8580509a1c5af6 to your computer and use it in GitHub Desktop.
credentials_controller.rb
This file contains hidden or 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
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