@@ -66,7 +79,12 @@
export default {
data() {
return {
- twofaccount: {}
+ twofaccount: {
+ 'name' : '',
+ 'email' : '',
+ 'uri' : '',
+ 'icon' : ''
+ }
}
},
@@ -90,7 +108,7 @@
axios.defaults.headers.common['Content-Type'] = 'application/json'
axios.defaults.headers.common['Authorization'] = 'Bearer ' + token
- let files = this.$refs.fileInput.files
+ let files = this.$refs.qrcodeInput.files
if (!files.length) {
console.log('no files');
@@ -115,6 +133,40 @@
this.twofaccount = response.data;
}
)
+ },
+
+ uploadIcon(event) {
+
+ let token = localStorage.getItem('jwt')
+
+ axios.defaults.headers.common['Content-Type'] = 'application/json'
+ axios.defaults.headers.common['Authorization'] = 'Bearer ' + token
+
+ let files = this.$refs.iconInput.files
+
+ if (!files.length) {
+ console.log('no files');
+ return false;
+ }
+ else {
+ console.log(files.length + ' file(s) found');
+ }
+
+ let imgdata = new FormData();
+
+ imgdata.append('icon', files[0]);
+
+ let config = {
+ header : {
+ 'Content-Type' : 'multipart/form-data',
+ }
+ }
+
+ axios.post('/api/icon/upload', imgdata, config).then(response => {
+ console.log('icon path > ', response);
+ this.twofaccount.icon = response.data;
+ }
+ )
}
},
diff --git a/resources/js/views/Edit.vue b/resources/js/views/Edit.vue
index 16f1a9d2..0a534ce5 100644
--- a/resources/js/views/Edit.vue
+++ b/resources/js/views/Edit.vue
@@ -17,13 +17,26 @@
+
+
+
+
+
@@ -77,6 +90,40 @@
this.$router.push({name: 'accounts'});
})
},
+
+ uploadIcon(event) {
+
+ let token = localStorage.getItem('jwt')
+
+ axios.defaults.headers.common['Content-Type'] = 'application/json'
+ axios.defaults.headers.common['Authorization'] = 'Bearer ' + token
+
+ let files = this.$refs.iconInput.files
+
+ if (!files.length) {
+ console.log('no files');
+ return false;
+ }
+ else {
+ console.log(files.length + ' file(s) found');
+ }
+
+ let imgdata = new FormData();
+
+ imgdata.append('icon', files[0]);
+
+ let config = {
+ header : {
+ 'Content-Type' : 'multipart/form-data',
+ }
+ }
+
+ axios.post('/api/icon/upload', imgdata, config).then(response => {
+ console.log('icon path > ', response);
+ this.twofaccount.icon = response.data;
+ }
+ )
+ }
},
}
diff --git a/routes/api.php b/routes/api.php
index 1760d1d2..aae49da0 100644
--- a/routes/api.php
+++ b/routes/api.php
@@ -22,5 +22,6 @@
Route::apiResource('twofaccounts', 'TwoFAccountController');
Route::get('twofaccounts/{twofaccount}/totp', 'TwoFAccountController@generateTOTP')->name('twofaccounts.generateTOTP');
Route::post('qrcode/decode', 'QrCodeController@decode');
+ Route::post('icon/upload', 'IconController@upload');
Route::delete('twofaccounts/force/{id}', 'TwoFAccountController@forceDestroy')->name('twofaccounts.forceDestroy');
});
\ No newline at end of file