diff options
| author | Clement Ho <clemmakesapps@gmail.com> | 2018-03-01 18:14:53 +0000 |
|---|---|---|
| committer | Clement Ho <clemmakesapps@gmail.com> | 2018-03-01 18:14:53 +0000 |
| commit | 119cdf3b3b56aa3c237b070ffde856f09992a8a1 (patch) | |
| tree | 02e6cd5efb2a7f2f2247da0ca811ef70c54f40a9 /app/assets/javascripts/u2f/register.js | |
| parent | 56e106d47f76c8692bfc2acdd018f5b2d11afd95 (diff) | |
| parent | bb41a889487463f626796a390148ae7870c16824 (diff) | |
| download | gitlab-ce-webpack-registry.tar.gz | |
Merge branch 'master' into 'webpack-registry'webpack-registry
# Conflicts:
# config/webpack.config.js
Diffstat (limited to 'app/assets/javascripts/u2f/register.js')
| -rw-r--r-- | app/assets/javascripts/u2f/register.js | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/app/assets/javascripts/u2f/register.js b/app/assets/javascripts/u2f/register.js index cc3f02e75f6..869fac658e8 100644 --- a/app/assets/javascripts/u2f/register.js +++ b/app/assets/javascripts/u2f/register.js @@ -1,8 +1,5 @@ -/* eslint-disable func-names, wrap-iife */ -/* global u2f */ - import _ from 'underscore'; -import isU2FSupported from './util'; +import importU2FLibrary from './util'; import U2FError from './error'; // Register U2F (universal 2nd factor) devices for users to authenticate with. @@ -11,6 +8,7 @@ import U2FError from './error'; // State Flow #2: setup -> in_progress -> error -> setup export default class U2FRegister { constructor(container, u2fParams) { + this.u2fUtils = null; this.container = container; this.renderNotSupported = this.renderNotSupported.bind(this); this.renderRegistered = this.renderRegistered.bind(this); @@ -34,22 +32,23 @@ export default class U2FRegister { } start() { - if (isU2FSupported()) { - return this.renderSetup(); - } - return this.renderNotSupported(); + return importU2FLibrary() + .then((utils) => { + this.u2fUtils = utils; + this.renderSetup(); + }) + .catch(() => this.renderNotSupported()); } register() { - return u2f.register(this.appId, this.registerRequests, this.signRequests, (function (_this) { - return function (response) { + return this.u2fUtils.register(this.appId, this.registerRequests, this.signRequests, + (response) => { if (response.errorCode) { const error = new U2FError(response.errorCode, 'register'); - return _this.renderError(error); + return this.renderError(error); } - return _this.renderRegistered(JSON.stringify(response)); - }; - })(this), 10); + return this.renderRegistered(JSON.stringify(response)); + }, 10); } renderTemplate(name, params) { |
