mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-08-19 01:46:03 +02:00
Add ctrl+click on 2FA to get and copy an OTP in yolo mode - Closes #220
This commit is contained in:
@@ -141,7 +141,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</transition>
|
</transition>
|
||||||
<div tabindex="0" class="tfa-cell tfa-content is-size-3 is-size-4-mobile" @click="showOrCopy(account)" @keyup.enter="showOrCopy(account)" role="button">
|
<div tabindex="0" class="tfa-cell tfa-content is-size-3 is-size-4-mobile" @click.exact="showOrCopy(account)" @keyup.enter="showOrCopy(account)" @click.ctrl="getAndCopyOTP(account)" role="button">
|
||||||
<div class="tfa-text has-ellipsis">
|
<div class="tfa-text has-ellipsis">
|
||||||
<img :src="$root.appConfig.subdirectory + '/storage/icons/' + account.icon" v-if="account.icon && $root.userPreferences.showAccountsIcons" :alt="$t('twofaccounts.icon_for_account_x_at_service_y', {account: account.account, service: account.service})">
|
<img :src="$root.appConfig.subdirectory + '/storage/icons/' + account.icon" v-if="account.icon && $root.userPreferences.showAccountsIcons" :alt="$t('twofaccounts.icon_for_account_x_at_service_y', {account: account.account, service: account.service})">
|
||||||
{{ displayService(account.service) }}<font-awesome-icon class="has-text-danger is-size-5 ml-2" v-if="$root.appSettings.useEncryption && account.account === $t('errors.indecipherable')" :icon="['fas', 'exclamation-circle']" />
|
{{ displayService(account.service) }}<font-awesome-icon class="has-text-danger is-size-5 ml-2" v-if="$root.appSettings.useEncryption && account.account === $t('errors.indecipherable')" :icon="['fas', 'exclamation-circle']" />
|
||||||
@@ -431,14 +431,32 @@
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
copyOTP (otp) {
|
async getAndCopyOTP(account) {
|
||||||
|
await this.axios.get('/api/v1/twofaccounts/' + account.id + '/otp').then(response => {
|
||||||
|
let otp = response.data
|
||||||
|
this.copyOTP(otp.password)
|
||||||
|
|
||||||
|
if (otp.otp_type == 'hotp') {
|
||||||
|
let hotpToIncrement = this.accounts.find((acc) => acc.id == account.id)
|
||||||
|
|
||||||
|
if (hotpToIncrement != undefined) {
|
||||||
|
hotpToIncrement.counter = otp.counter
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
copyOTP (password) {
|
||||||
// see https://web.dev/async-clipboard/ for futur Clipboard API usage.
|
// see https://web.dev/async-clipboard/ for futur Clipboard API usage.
|
||||||
// The API should allow to copy the password on each trip without user interaction.
|
// The API should allow to copy the password on each trip without user interaction.
|
||||||
|
|
||||||
// For now too many browsers don't support the clipboard-write permission
|
// For now too many browsers don't support the clipboard-write permission
|
||||||
// (see https://developer.mozilla.org/en-US/docs/Web/API/Permissions#browser_support)
|
// (see https://developer.mozilla.org/en-US/docs/Web/API/Permissions#browser_support)
|
||||||
|
|
||||||
const success = this.$clipboard(otp)
|
const success = this.$clipboard(password)
|
||||||
|
|
||||||
if (success == true) {
|
if (success == true) {
|
||||||
if(this.$root.userPreferences.kickUserAfter == -1) {
|
if(this.$root.userPreferences.kickUserAfter == -1) {
|
||||||
|
Reference in New Issue
Block a user