From dbedf3a61b5fe233b87b217596dea5572fc741b3 Mon Sep 17 00:00:00 2001 From: Timothy Andrew Date: Thu, 18 Aug 2016 12:28:36 +0530 Subject: [PATCH] Address review comments from @smcgivern. 1. Remove an unnecessary (since we're fetching all the records anyway) `pluck` while fetching U2F registration records. 2. Align "Your device was successfully set up!" section with the "U2F Devices" table below. --- .../profiles/two_factor_auths_controller.rb | 3 +-- app/views/u2f/_register.html.haml | 17 +++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/controllers/profiles/two_factor_auths_controller.rb b/app/controllers/profiles/two_factor_auths_controller.rb index cfa84c3bf4d..9eb75bb3891 100644 --- a/app/controllers/profiles/two_factor_auths_controller.rb +++ b/app/controllers/profiles/two_factor_auths_controller.rb @@ -92,11 +92,10 @@ class Profiles::TwoFactorAuthsController < Profiles::ApplicationController def setup_u2f_registration @u2f_registration ||= U2fRegistration.new @u2f_registrations = current_user.u2f_registrations - @registration_key_handles = @u2f_registrations.pluck(:key_handle) u2f = U2F::U2F.new(u2f_app_id) registration_requests = u2f.registration_requests - sign_requests = u2f.authentication_requests(@registration_key_handles) + sign_requests = u2f.authentication_requests(@u2f_registrations.map(&:key_handle)) session[:challenges] = registration_requests.map(&:challenge) gon.push(u2f: { challenges: session[:challenges], app_id: u2f_app_id, diff --git a/app/views/u2f/_register.html.haml b/app/views/u2f/_register.html.haml index 7a4b7d7a77a..8f7b42eb351 100644 --- a/app/views/u2f/_register.html.haml +++ b/app/views/u2f/_register.html.haml @@ -28,14 +28,15 @@ %script#js-register-u2f-registered{ type: "text/template" } %div.row.append-bottom-10 - %p Your device was successfully set up! Give it a name and register it with the GitLab server. - = form_tag(create_u2f_profile_two_factor_auth_path, method: :post) do - .row.append-bottom-10 - .col-md-3 - = text_field_tag 'u2f_registration[name]', nil, class: 'form-control', placeholder: "Pick a name" - .col-md-3 - = hidden_field_tag 'u2f_registration[device_response]', nil, class: 'form-control', required: true, id: "js-device-response" - = submit_tag "Register U2F Device", class: "btn btn-success" + .col-md-12 + %p Your device was successfully set up! Give it a name and register it with the GitLab server. + = form_tag(create_u2f_profile_two_factor_auth_path, method: :post) do + .row.append-bottom-10 + .col-md-3 + = text_field_tag 'u2f_registration[name]', nil, class: 'form-control', placeholder: "Pick a name" + .col-md-3 + = hidden_field_tag 'u2f_registration[device_response]', nil, class: 'form-control', required: true, id: "js-device-response" + = submit_tag "Register U2F Device", class: "btn btn-success" :javascript var u2fRegister = new U2FRegister($("#js-register-u2f"), gon.u2f);