2020-04-24 09:03:00 +02:00
|
|
|
<template>
|
2020-11-23 19:30:58 +01:00
|
|
|
<!-- static landing UI -->
|
|
|
|
<div class="container has-text-centered">
|
|
|
|
<div class="columns quick-uploader">
|
|
|
|
<!-- trailer phrase that invite to add an account -->
|
2020-11-25 21:56:04 +01:00
|
|
|
<div class="column is-full quick-uploader-header" :class="{ 'is-invisible' : accountCount !== 0 }">
|
2020-11-23 19:30:58 +01:00
|
|
|
{{ $t('twofaccounts.no_account_here') }}<br>
|
|
|
|
{{ $t('twofaccounts.add_first_account') }}
|
|
|
|
</div>
|
|
|
|
<!-- Livescan button -->
|
|
|
|
<div class="column is-full quick-uploader-button" >
|
|
|
|
<div class="quick-uploader-centerer">
|
|
|
|
<!-- upload a qr code (with basic file field and backend decoding) -->
|
2023-02-17 17:12:53 +01:00
|
|
|
<label role="button" tabindex="0" v-if="$root.userPreferences.useBasicQrcodeReader" class="button is-link is-medium is-rounded is-main" ref="qrcodeInputLabel" @keyup.enter="$refs.qrcodeInputLabel.click()">
|
2022-10-12 11:30:20 +02:00
|
|
|
<input aria-hidden="true" tabindex="-1" class="file-input" type="file" accept="image/*" v-on:change="submitQrCode" ref="qrcodeInput">
|
2020-11-23 19:30:58 +01:00
|
|
|
{{ $t('twofaccounts.forms.upload_qrcode') }}
|
|
|
|
</label>
|
|
|
|
<!-- scan button that launch camera stream -->
|
2022-10-18 13:41:46 +02:00
|
|
|
<button v-else class="button is-link is-medium is-rounded is-main" @click="capture()">
|
2020-11-23 19:30:58 +01:00
|
|
|
{{ $t('twofaccounts.forms.scan_qrcode') }}
|
2022-10-12 11:30:20 +02:00
|
|
|
</button>
|
2020-04-24 09:03:00 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2020-11-23 19:30:58 +01:00
|
|
|
<!-- alternative methods -->
|
|
|
|
<div class="column is-full">
|
2023-02-01 17:21:55 +01:00
|
|
|
<div class="block" :class="$root.showDarkMode ? 'has-text-light':'has-text-grey-dark'">{{ $t('twofaccounts.forms.alternative_methods') }}</div>
|
2020-11-23 19:30:58 +01:00
|
|
|
<!-- upload a qr code -->
|
2023-02-17 17:12:53 +01:00
|
|
|
<div class="block has-text-link" v-if="!$root.userPreferences.useBasicQrcodeReader">
|
2022-10-12 11:30:20 +02:00
|
|
|
<label role="button" tabindex="0" class="button is-link is-outlined is-rounded" ref="qrcodeInputLabel" @keyup.enter="$refs.qrcodeInputLabel.click()">
|
|
|
|
<input aria-hidden="true" tabindex="-1" class="file-input" type="file" accept="image/*" v-on:change="submitQrCode" ref="qrcodeInput">
|
2020-11-23 19:30:58 +01:00
|
|
|
{{ $t('twofaccounts.forms.upload_qrcode') }}
|
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
<!-- link to advanced form -->
|
2022-06-20 17:49:46 +02:00
|
|
|
<div v-if="showAdvancedFormButton" class="block has-text-link">
|
2020-11-23 19:30:58 +01:00
|
|
|
<router-link class="button is-link is-outlined is-rounded" :to="{ name: 'createAccount' }" >
|
|
|
|
{{ $t('twofaccounts.forms.use_advanced_form') }}
|
2020-11-20 14:11:32 +01:00
|
|
|
</router-link>
|
2020-11-23 19:30:58 +01:00
|
|
|
</div>
|
2022-10-07 18:58:48 +02:00
|
|
|
<!-- link to import view -->
|
|
|
|
<div v-if="showImportButton" class="block has-text-link">
|
|
|
|
<router-link class="button is-link is-outlined is-rounded" :to="{ name: 'importAccounts' }" >
|
|
|
|
{{ $t('twofaccounts.import.import') }}
|
|
|
|
</router-link>
|
|
|
|
</div>
|
2020-04-24 09:03:00 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2020-11-23 19:30:58 +01:00
|
|
|
<!-- Footer -->
|
2020-12-03 00:17:53 +01:00
|
|
|
<vue-footer :showButtons="true" >
|
2020-11-23 19:30:58 +01:00
|
|
|
<!-- back button -->
|
2020-12-03 00:17:53 +01:00
|
|
|
<p class="control" v-if="accountCount > 0">
|
2023-02-01 17:21:55 +01:00
|
|
|
<router-link class="button is-rounded" :class="{'is-dark' : $root.showDarkMode}" :to="{ name: returnToView }" >
|
2020-11-23 19:30:58 +01:00
|
|
|
{{ $t('commons.back') }}
|
|
|
|
</router-link>
|
|
|
|
</p>
|
|
|
|
</vue-footer>
|
2020-04-24 09:03:00 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
2020-11-20 18:47:32 +01:00
|
|
|
/**
|
|
|
|
* Start view
|
|
|
|
*
|
|
|
|
* route: '/start'
|
|
|
|
*
|
|
|
|
* Offer the user all available possibilities for capturing an account :
|
2020-11-23 19:30:58 +01:00
|
|
|
* - By sending the user to the live scanner
|
2020-11-20 18:47:32 +01:00
|
|
|
* - By decoding a QR code submitted with a form 'File' field
|
2020-11-23 19:30:58 +01:00
|
|
|
* - By sending the user to the advanced form
|
2020-11-20 18:47:32 +01:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-11-24 23:52:42 +01:00
|
|
|
import Form from './../components/Form'
|
2020-04-24 09:03:00 +02:00
|
|
|
|
|
|
|
export default {
|
2020-11-20 14:11:32 +01:00
|
|
|
name: 'Start',
|
2020-04-24 09:03:00 +02:00
|
|
|
|
|
|
|
data(){
|
|
|
|
return {
|
2020-11-21 19:41:36 +01:00
|
|
|
accountCount: null,
|
2020-11-24 23:52:42 +01:00
|
|
|
form: new Form(),
|
2022-10-07 18:58:48 +02:00
|
|
|
alternativeMethod: null,
|
2020-04-24 09:03:00 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2022-06-20 17:49:46 +02:00
|
|
|
props: {
|
|
|
|
showAdvancedFormButton: {
|
|
|
|
type: Boolean,
|
|
|
|
default: true
|
|
|
|
},
|
2022-10-07 18:58:48 +02:00
|
|
|
showImportButton: {
|
|
|
|
type: Boolean,
|
|
|
|
default: true
|
|
|
|
},
|
2022-06-20 17:49:46 +02:00
|
|
|
returnToView: {
|
|
|
|
type: String,
|
|
|
|
default: 'accounts'
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2020-11-21 19:41:36 +01:00
|
|
|
mounted() {
|
|
|
|
|
2021-11-07 21:57:22 +01:00
|
|
|
this.axios.get('api/v1/twofaccounts/count').then(response => {
|
2020-11-21 19:41:36 +01:00
|
|
|
this.accountCount = response.data.count
|
|
|
|
})
|
|
|
|
},
|
2020-04-24 09:03:00 +02:00
|
|
|
|
|
|
|
created() {
|
2020-11-20 18:59:36 +01:00
|
|
|
|
|
|
|
this.$nextTick(() => {
|
2023-02-17 17:12:53 +01:00
|
|
|
if( this.$root.userPreferences.useDirectCapture && this.$root.userPreferences.defaultCaptureMode === 'upload' ) {
|
2020-11-20 18:59:36 +01:00
|
|
|
this.$refs.qrcodeInputLabel.click()
|
|
|
|
}
|
|
|
|
})
|
2020-04-24 09:03:00 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
|
2020-11-20 14:11:32 +01:00
|
|
|
/**
|
2021-10-09 19:23:24 +02:00
|
|
|
* Upload the submitted QR code file to the backend for decoding, then route the user
|
2022-05-25 13:42:43 +02:00
|
|
|
* to the Create or Import form with decoded URI to prefill the form
|
2020-11-20 14:11:32 +01:00
|
|
|
*/
|
2022-09-02 14:28:57 +02:00
|
|
|
submitQrCode() {
|
2020-04-24 09:03:00 +02:00
|
|
|
|
2020-11-20 14:11:32 +01:00
|
|
|
let imgdata = new FormData();
|
|
|
|
imgdata.append('qrcode', this.$refs.qrcodeInput.files[0]);
|
|
|
|
imgdata.append('inputFormat', 'fileUpload');
|
2020-04-24 09:03:00 +02:00
|
|
|
|
2022-09-02 14:28:57 +02:00
|
|
|
this.form.upload('/api/v1/qrcode/decode', imgdata, {returnError: true}).then(response => {
|
|
|
|
if( response.data.data.slice(0, 33).toLowerCase() === "otpauth-migration://offline?data=" ) {
|
|
|
|
this.$router.push({ name: 'importAccounts', params: { migrationUri: response.data.data } });
|
|
|
|
}
|
|
|
|
else this.$router.push({ name: 'createAccount', params: { decodedUri: response.data.data } });
|
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
this.$notify({type: 'is-danger', text: this.$t(error.response.data.message) })
|
|
|
|
});
|
2020-11-20 14:11:32 +01:00
|
|
|
},
|
2020-04-24 09:03:00 +02:00
|
|
|
|
2020-11-20 14:11:32 +01:00
|
|
|
/**
|
2020-11-23 19:30:58 +01:00
|
|
|
* Push user to the dedicated capture view for live scan
|
2020-11-20 14:11:32 +01:00
|
|
|
*/
|
2020-11-23 19:30:58 +01:00
|
|
|
capture() {
|
|
|
|
this.$router.push({ name: 'capture' });
|
2020-04-24 09:03:00 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
</script>
|