Skip to content

(Add) Button to copy 2fa recovery codes #4874

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

Open
wants to merge 15 commits into
base: development
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions resources/views/livewire/two-factor-auth-form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,33 @@ class="form__button form__button--filled"
>
{{ __('Regenerate Recovery Codes') }}
</button>
@script
<script nonce="{{ HDVinnie\SecureHeaders\SecureHeaders::nonce('script') }}">
Alpine.data('recoverycodes', () => ({
copy() {
let text = document.createElement('textarea');
navigator.clipboard.writeText(
JSON.parse(atob('{{ base64_encode(decrypt($this->user->two_factor_recovery_codes)) }}')).join("\n")
);
Swal.fire({
toast: true,
position: 'top-end',
showConfirmButton: false,
timer: 3000,
icon: 'success',
title: 'Copied to clipboard!',
});
},
}));
</script>
@endscript
<button
class="form__button form__button--filled"
x-data="recoverycodes"
x-on:click.stop="copy"
>
{{ __('Copy Recovery Codes') }}
</button>
@elseif ($showingConfirmation)
<button
class="form__button form__button--filled"
Expand Down