diff options
-rw-r--r-- | app/views/profiles/two_factor_auths/_codes.html.haml | 13 | ||||
-rw-r--r-- | changelogs/unreleased/add-2fa-button.yml | 5 |
2 files changed, 18 insertions, 0 deletions
diff --git a/app/views/profiles/two_factor_auths/_codes.html.haml b/app/views/profiles/two_factor_auths/_codes.html.haml index 93722d7b034..aab45d9fb4b 100644 --- a/app/views/profiles/two_factor_auths/_codes.html.haml +++ b/app/views/profiles/two_factor_auths/_codes.html.haml @@ -10,4 +10,17 @@ %li %span.monospace= code +:javascript + function download(text) { + var element = document.createElement('a'); + element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text)); + element.setAttribute('download', 'gitlab-recovery-codes.txt'); + + element.style.display = 'none'; + document.body.appendChild(element); + element.click(); + document.body.removeChild(element); + } + +%button{:class => 'btn', :onclick => "download('#{@codes.join('\n')}')"} Download Codes = link_to 'Proceed', profile_account_path, class: 'btn btn-success' diff --git a/changelogs/unreleased/add-2fa-button.yml b/changelogs/unreleased/add-2fa-button.yml new file mode 100644 index 00000000000..6cb71d52781 --- /dev/null +++ b/changelogs/unreleased/add-2fa-button.yml @@ -0,0 +1,5 @@ +--- +title: Add button to download 2FA codes +merge_request: +author: Luke Picciau +type: added |