mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-01-11 16:58:58 +01:00
Better bad QR code handling in create form
This commit is contained in:
parent
102d98863b
commit
543f6b89db
@ -42,22 +42,12 @@ public function decode(Request $request)
|
||||
// delete uploaded file
|
||||
Storage::delete($path);
|
||||
|
||||
if( empty($uri) ) {
|
||||
|
||||
return response()->json([
|
||||
'error' => [
|
||||
'qrcode' => 'Nothing readable in this QR code 😕'
|
||||
]
|
||||
], 400);
|
||||
|
||||
}
|
||||
|
||||
// Check uri validity
|
||||
if( !TimedTOTP::get($uri) ) {
|
||||
|
||||
return response()->json([
|
||||
'error' => [
|
||||
'uri' => 'This uri do not return any TOTP code 😕'
|
||||
'qrcode' => 'No valid TOTP resource in this QR code'
|
||||
]
|
||||
], 400);
|
||||
|
||||
|
@ -161,6 +161,7 @@
|
||||
.catch(error => {
|
||||
if (error.response.status === 400) {
|
||||
this.errors = error.response.data.error
|
||||
this.clearTwofaccount()
|
||||
}
|
||||
});
|
||||
},
|
||||
@ -203,15 +204,26 @@
|
||||
|
||||
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['Authorization'] = 'Bearer ' + token
|
||||
axios.defaults.headers.common['Content-Type'] = 'application/json'
|
||||
axios.defaults.headers.common['Authorization'] = 'Bearer ' + token
|
||||
|
||||
axios.delete('/api/icon/delete/' + this.tempIcon).then(response => {
|
||||
this.tempIcon = ''
|
||||
}
|
||||
)
|
||||
axios.delete('/api/icon/delete/' + this.tempIcon).then(response => {
|
||||
this.tempIcon = ''
|
||||
}
|
||||
)
|
||||
}
|
||||
},
|
||||
|
||||
clearTwofaccount() {
|
||||
this.twofaccount.service = ''
|
||||
this.twofaccount.account = ''
|
||||
this.twofaccount.uri = ''
|
||||
this.twofaccount.icon = ''
|
||||
|
||||
this.deleteIcon()
|
||||
}
|
||||
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user