mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-08-10 06:07:54 +02:00
Better bad QR code handling in create form
This commit is contained in:
@ -42,22 +42,12 @@ class QrCodecontroller extends Controller
|
|||||||
// delete uploaded file
|
// delete uploaded file
|
||||||
Storage::delete($path);
|
Storage::delete($path);
|
||||||
|
|
||||||
if( empty($uri) ) {
|
|
||||||
|
|
||||||
return response()->json([
|
|
||||||
'error' => [
|
|
||||||
'qrcode' => 'Nothing readable in this QR code 😕'
|
|
||||||
]
|
|
||||||
], 400);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check uri validity
|
// Check uri validity
|
||||||
if( !TimedTOTP::get($uri) ) {
|
if( !TimedTOTP::get($uri) ) {
|
||||||
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'error' => [
|
'error' => [
|
||||||
'uri' => 'This uri do not return any TOTP code 😕'
|
'qrcode' => 'No valid TOTP resource in this QR code'
|
||||||
]
|
]
|
||||||
], 400);
|
], 400);
|
||||||
|
|
||||||
|
@ -161,6 +161,7 @@
|
|||||||
.catch(error => {
|
.catch(error => {
|
||||||
if (error.response.status === 400) {
|
if (error.response.status === 400) {
|
||||||
this.errors = error.response.data.error
|
this.errors = error.response.data.error
|
||||||
|
this.clearTwofaccount()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -203,15 +204,26 @@
|
|||||||
|
|
||||||
deleteIcon(event) {
|
deleteIcon(event) {
|
||||||
|
|
||||||
let token = localStorage.getItem('jwt')
|
if(this.tempIcon) {
|
||||||
|
let token = localStorage.getItem('jwt')
|
||||||
|
|
||||||
axios.defaults.headers.common['Content-Type'] = 'application/json'
|
axios.defaults.headers.common['Content-Type'] = 'application/json'
|
||||||
axios.defaults.headers.common['Authorization'] = 'Bearer ' + token
|
axios.defaults.headers.common['Authorization'] = 'Bearer ' + token
|
||||||
|
|
||||||
axios.delete('/api/icon/delete/' + this.tempIcon).then(response => {
|
axios.delete('/api/icon/delete/' + this.tempIcon).then(response => {
|
||||||
this.tempIcon = ''
|
this.tempIcon = ''
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
clearTwofaccount() {
|
||||||
|
this.twofaccount.service = ''
|
||||||
|
this.twofaccount.account = ''
|
||||||
|
this.twofaccount.uri = ''
|
||||||
|
this.twofaccount.icon = ''
|
||||||
|
|
||||||
|
this.deleteIcon()
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user