mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-05-29 22:39:11 +02:00
Fix FieldError components not reacting when an error occurs
This commit is contained in:
parent
bfe75069a4
commit
fcc7e6db03
@ -78,7 +78,7 @@
|
|||||||
<button v-else class="button is-link is-medium is-rounded is-main" @click="capture()">
|
<button v-else class="button is-link is-medium is-rounded is-main" @click="capture()">
|
||||||
{{ $t('twofaccounts.forms.scan_qrcode') }}
|
{{ $t('twofaccounts.forms.scan_qrcode') }}
|
||||||
</button>
|
</button>
|
||||||
<FieldError v-if="form.hasAny" :error="form.errors.get('qrcode')" :field="'qrcode'" />
|
<FieldError v-if="form.errors.hasAny('qrcode')" :error="form.errors.get('qrcode')" :field="'qrcode'" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- alternative methods -->
|
<!-- alternative methods -->
|
||||||
|
@ -28,7 +28,12 @@
|
|||||||
counter: null,
|
counter: null,
|
||||||
period: null,
|
period: null,
|
||||||
image: '',
|
image: '',
|
||||||
qrcode: null,
|
}))
|
||||||
|
const qrcodeForm = reactive(new Form({
|
||||||
|
qrcode: null
|
||||||
|
}))
|
||||||
|
const iconForm = reactive(new Form({
|
||||||
|
icon: null
|
||||||
}))
|
}))
|
||||||
const otp_types = [
|
const otp_types = [
|
||||||
{ text: 'TOTP', value: 'totp' },
|
{ text: 'TOTP', value: 'totp' },
|
||||||
@ -215,17 +220,19 @@
|
|||||||
function uploadIcon() {
|
function uploadIcon() {
|
||||||
// clean possible already uploaded temp icon
|
// clean possible already uploaded temp icon
|
||||||
deleteIcon()
|
deleteIcon()
|
||||||
|
iconForm.icon = iconInput.value.files[0]
|
||||||
const iconForm = new Form({
|
|
||||||
icon: iconInput.value.files[0]
|
|
||||||
})
|
|
||||||
|
|
||||||
iconForm.upload('/api/v1/icons', { returnError: true })
|
iconForm.upload('/api/v1/icons', { returnError: true })
|
||||||
.then(response => {
|
.then(response => {
|
||||||
tempIcon.value = response.data.filename;
|
tempIcon.value = response.data.filename
|
||||||
|
if (showQuickForm.value) {
|
||||||
|
form.icon = tempIcon.value
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
notify.alert({ text: trans(error.response.data.message) })
|
if (error.response.status !== 422) {
|
||||||
|
notify.alert({ text: error.response.data.message})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,9 +274,7 @@
|
|||||||
* Sends a QR code to backend for decoding and prefill the form with the qr data
|
* Sends a QR code to backend for decoding and prefill the form with the qr data
|
||||||
*/
|
*/
|
||||||
function uploadQrcode() {
|
function uploadQrcode() {
|
||||||
const qrcodeForm = new Form({
|
qrcodeForm.qrcode = qrcodeInput.value.files[0]
|
||||||
qrcode: qrcodeInput.value.files[0]
|
|
||||||
})
|
|
||||||
|
|
||||||
// First we get the uri encoded in the qrcode
|
// First we get the uri encoded in the qrcode
|
||||||
qrcodeForm.upload('/api/v1/qrcode/decode', { returnError: true })
|
qrcodeForm.upload('/api/v1/qrcode/decode', { returnError: true })
|
||||||
@ -293,8 +298,9 @@
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
notify.alert({ text: trans(error.response.data.message) })
|
if (error.response.status !== 422) {
|
||||||
return false
|
notify.alert({ text: error.response.data.message})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -375,6 +381,7 @@
|
|||||||
<div class="container preview has-text-centered">
|
<div class="container preview has-text-centered">
|
||||||
<div class="columns is-mobile">
|
<div class="columns is-mobile">
|
||||||
<div class="column">
|
<div class="column">
|
||||||
|
<FieldError v-if="iconForm.errors.hasAny('icon')" :error="iconForm.errors.get('icon')" :field="'icon'" class="help-for-file" />
|
||||||
<label class="add-icon-button" v-if="!tempIcon">
|
<label class="add-icon-button" v-if="!tempIcon">
|
||||||
<input class="file-input" type="file" accept="image/*" v-on:change="uploadIcon" ref="iconInput">
|
<input class="file-input" type="file" accept="image/*" v-on:change="uploadIcon" ref="iconInput">
|
||||||
<FontAwesomeIcon :icon="['fas', 'image']" size="2x" />
|
<FontAwesomeIcon :icon="['fas', 'image']" size="2x" />
|
||||||
@ -429,7 +436,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<FieldError v-if="!isEditMode && form.errors.hasAny('qrcode')" :error="form.errors.get('qrcode')" :field="'qrcode'" class="help-for-file" />
|
<FieldError v-if="qrcodeForm.errors.hasAny('qrcode')" :error="qrcodeForm.errors.get('qrcode')" :field="'qrcode'" class="help-for-file" />
|
||||||
<!-- service -->
|
<!-- service -->
|
||||||
<FormField v-model="form.service" fieldName="service" :fieldError="form.errors.get('email')" :isDisabled="form.otp_type === 'steamtotp'" label="twofaccounts.service" :placeholder="$t('twofaccounts.forms.service.placeholder')" autofocus />
|
<FormField v-model="form.service" fieldName="service" :fieldError="form.errors.get('email')" :isDisabled="form.otp_type === 'steamtotp'" label="twofaccounts.service" :placeholder="$t('twofaccounts.forms.service.placeholder')" autofocus />
|
||||||
<!-- account -->
|
<!-- account -->
|
||||||
@ -470,7 +477,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<FieldError v-if="form.errors.hasAny('icon')" :error="form.errors.get('icon')" :field="'icon'" class="help-for-file" />
|
<FieldError v-if="iconForm.errors.hasAny('icon')" :error="iconForm.errors.get('icon')" :field="'icon'" class="help-for-file" />
|
||||||
<p v-if="user.preferences.getOfficialIcons" class="help" v-html="$t('twofaccounts.forms.i_m_lucky_legend')"></p>
|
<p v-if="user.preferences.getOfficialIcons" class="help" v-html="$t('twofaccounts.forms.i_m_lucky_legend')"></p>
|
||||||
</div>
|
</div>
|
||||||
<!-- otp type -->
|
<!-- otp type -->
|
||||||
|
@ -29,14 +29,14 @@
|
|||||||
counter: null,
|
counter: null,
|
||||||
period: null,
|
period: null,
|
||||||
}))
|
}))
|
||||||
const fileForm = new Form({
|
const fileForm = reactive(new Form({
|
||||||
file: null,
|
file: null,
|
||||||
withSecret: true
|
withSecret: true
|
||||||
})
|
}))
|
||||||
const qrcodeForm = new Form({
|
const qrcodeForm = reactive(new Form({
|
||||||
qrcode: null,
|
qrcode: null,
|
||||||
withSecret: true
|
withSecret: true
|
||||||
})
|
}))
|
||||||
const showTwofaccountInModal = ref(false)
|
const showTwofaccountInModal = ref(false)
|
||||||
const supportedSources = [
|
const supportedSources = [
|
||||||
{app: '2FAuth', format: 'JSON'},
|
{app: '2FAuth', format: 'JSON'},
|
||||||
@ -173,6 +173,7 @@
|
|||||||
* Uploads the submitted file to the backend for parsing
|
* Uploads the submitted file to the backend for parsing
|
||||||
*/
|
*/
|
||||||
function submitFile() {
|
function submitFile() {
|
||||||
|
fileForm.clear()
|
||||||
isFetching.value = true
|
isFetching.value = true
|
||||||
fileForm.file = fileInput.value.files[0]
|
fileForm.file = fileInput.value.files[0]
|
||||||
|
|
||||||
@ -199,6 +200,7 @@
|
|||||||
* Uploads the submitted QR code file to the backend for decoding
|
* Uploads the submitted QR code file to the backend for decoding
|
||||||
*/
|
*/
|
||||||
function submitQrCode() {
|
function submitQrCode() {
|
||||||
|
qrcodeForm.clear()
|
||||||
isFetching.value = true
|
isFetching.value = true
|
||||||
qrcodeForm.qrcode = qrcodeInput.value.files[0]
|
qrcodeForm.qrcode = qrcodeInput.value.files[0]
|
||||||
|
|
||||||
@ -208,7 +210,7 @@
|
|||||||
.catch(error => {
|
.catch(error => {
|
||||||
if( error.response.status === 422 ) {
|
if( error.response.status === 422 ) {
|
||||||
if (error.response.data.errors.qrcode == undefined) {
|
if (error.response.data.errors.qrcode == undefined) {
|
||||||
notify.alert({ text: this.$t('errors.invalid_2fa_data') })
|
notify.alert({ text: trans('errors.invalid_2fa_data') })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else notify.alert({ text: error.response.data.message})
|
else notify.alert({ text: error.response.data.message})
|
||||||
@ -251,7 +253,7 @@
|
|||||||
<input aria-hidden="true" tabindex="-1" class="file-input" type="file" accept="image/*" v-on:change="submitQrCode" ref="qrcodeInput">
|
<input aria-hidden="true" tabindex="-1" class="file-input" type="file" accept="image/*" v-on:change="submitQrCode" ref="qrcodeInput">
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<FieldError v-if="qrcodeForm.errors.get('qrcode') != undefined" :error="qrcodeForm.errors.get('qrcode')" :field="qrcodeForm.qrcode" />
|
<FieldError v-if="qrcodeForm.errors.hasAny('qrcode')" :error="qrcodeForm.errors.get('qrcode')" :field="'qrcode'" />
|
||||||
<p class="help">{{ $t('twofaccounts.import.supported_formats_for_qrcode_upload') }}</p>
|
<p class="help">{{ $t('twofaccounts.import.supported_formats_for_qrcode_upload') }}</p>
|
||||||
</div>
|
</div>
|
||||||
<h5 class="title is-5 mb-3 has-text-grey">{{ $t('commons.file') }}</h5>
|
<h5 class="title is-5 mb-3 has-text-grey">{{ $t('commons.file') }}</h5>
|
||||||
@ -261,7 +263,7 @@
|
|||||||
<input aria-hidden="true" tabindex="-1" class="file-input" type="file" accept="text/plain,application/json,text/csv,.2fas" v-on:change="submitFile" ref="fileInput">
|
<input aria-hidden="true" tabindex="-1" class="file-input" type="file" accept="text/plain,application/json,text/csv,.2fas" v-on:change="submitFile" ref="fileInput">
|
||||||
{{ $t('twofaccounts.import.upload') }}
|
{{ $t('twofaccounts.import.upload') }}
|
||||||
</label>
|
</label>
|
||||||
<FieldError v-if="fileForm.errors.get('file') != undefined" :error="fileForm.errors.get('file')" :field="fileForm.file" />
|
<FieldError v-if="fileForm.errors.hasAny('file')" :error="fileForm.errors.get('file')" :field="'file'" />
|
||||||
<p class="help">{{ $t('twofaccounts.import.supported_formats_for_file_upload') }}</p>
|
<p class="help">{{ $t('twofaccounts.import.supported_formats_for_file_upload') }}</p>
|
||||||
</div>
|
</div>
|
||||||
<!-- Supported migration resources -->
|
<!-- Supported migration resources -->
|
||||||
|
Loading…
x
Reference in New Issue
Block a user