-
Notifications
You must be signed in to change notification settings - Fork 41
Refactor JS #241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Refactor JS #241
Changes from 1 commit
ac998c2
1532925
cb11999
521b0c2
7bddc67
871ab25
cbf503e
a990e01
bd72e31
6115812
e19ef24
9b46e85
6fe61ca
6002921
e93e3e8
95b5664
331859e
c42c9fc
7a35c2c
81ad153
c2753ed
1c92613
5307cb1
449c9cb
e8b7ea3
9e58703
672bcb1
b9edbe2
23a316e
55e10a6
e35488d
3accfb1
18b76a5
72e5f40
82a766f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,7 @@ def create_options | |
| end | ||
|
|
||
| def create | ||
| webauthn_credential = WebAuthn::Credential.from_create(params) | ||
| webauthn_credential = WebAuthn::Credential.from_create(JSON.parse(params[:credential][:public_key_credential])) | ||
|
|
||
| begin | ||
| webauthn_credential.verify(session[:current_registration]["challenge"], user_verification: true) | ||
|
|
@@ -29,13 +29,13 @@ def create | |
| ) | ||
|
|
||
| if credential.update( | ||
| nickname: params[:credential_nickname], | ||
| nickname: params[:credential][:nickname], | ||
| public_key: webauthn_credential.public_key, | ||
| sign_count: webauthn_credential.sign_count | ||
| ) | ||
| render json: { status: "ok" }, status: :ok | ||
| redirect_to root_path, notice: "Security Key registered successfully" | ||
| else | ||
| render json: "Couldn't add your Security Key", status: :unprocessable_content | ||
| redirect_to root_path, alert: "Couldn't register your Security Key" | ||
|
||
| end | ||
| rescue WebAuthn::Error => e | ||
| render json: "Verification failed: #{e.message}", status: :unprocessable_content | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,7 +29,7 @@ def create_options | |
| end | ||
|
|
||
| def create | ||
| webauthn_credential = WebAuthn::Credential.from_create(params) | ||
| webauthn_credential = WebAuthn::Credential.from_create(JSON.parse(params[:registration][:public_key_credential])) | ||
|
|
||
| user = User.new(session[:current_registration]["user_attributes"]) | ||
|
|
||
|
|
@@ -38,17 +38,17 @@ def create | |
|
|
||
| user.credentials.build( | ||
| external_id: webauthn_credential.id, | ||
| nickname: params[:credential_nickname], | ||
| nickname: params[:registration][:nickname], | ||
| public_key: webauthn_credential.public_key, | ||
| sign_count: webauthn_credential.sign_count | ||
| ) | ||
|
|
||
| if user.save | ||
| sign_in(user) | ||
|
|
||
| render json: { status: "ok" }, status: :ok | ||
| redirect_to root_path, notice: "Security Key registered successfully" | ||
| else | ||
| render json: "Couldn't register your Security Key", status: :unprocessable_content | ||
| redirect_to new_registration_path, alert: "Couldn't register your Security Key" | ||
|
||
| end | ||
| rescue WebAuthn::Error => e | ||
| render json: "Verification failed: #{e.message}", status: :unprocessable_content | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |

Uh oh!
There was an error while loading. Please reload this page.