mirror of
https://github.com/Bubka/2FAuth.git
synced 2024-11-22 08:13:11 +01:00
Remove catch blocks where possible
This commit is contained in:
parent
59fe66710a
commit
a1f5358e4a
@ -75,7 +75,7 @@
|
||||
// we check if a user account already exists
|
||||
const { data } = await this.axios.post('api/checkuser')
|
||||
|
||||
if( data.userCount > 0) {
|
||||
if( data.userCount > 0 ) {
|
||||
this.errorMessage = this.$t('errors.already_one_user_registered') + ' ' + this.$t('errors.cannot_register_more_user')
|
||||
this.$router.push({ name: 'flooded' });
|
||||
}
|
||||
@ -83,23 +83,20 @@
|
||||
},
|
||||
|
||||
methods : {
|
||||
handleSubmit(e) {
|
||||
async handleSubmit(e) {
|
||||
e.preventDefault()
|
||||
|
||||
this.form.post('api/register')
|
||||
.then(response => {
|
||||
localStorage.setItem('user',response.data.message.name)
|
||||
localStorage.setItem('jwt',response.data.message.token)
|
||||
const { data } = await this.form.post('api/register')
|
||||
|
||||
if (localStorage.getItem('jwt') != null){
|
||||
if( this.form.errors.any() === false ) {
|
||||
|
||||
localStorage.setItem('user',data.message.name)
|
||||
localStorage.setItem('jwt',data.message.token)
|
||||
|
||||
if (localStorage.getItem('jwt') != null) {
|
||||
this.$router.push({name: 'accounts'})
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
if( error.response.status !== 422 ) {
|
||||
this.$router.push({ name: 'genericError', params: { err: error.response } });
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -109,19 +109,15 @@
|
||||
|
||||
methods: {
|
||||
|
||||
createAccount() {
|
||||
async createAccount() {
|
||||
// set current temp icon as account icon
|
||||
this.form.icon = this.tempIcon
|
||||
|
||||
this.form.post('/api/twofaccounts')
|
||||
.then(response => {
|
||||
await this.form.post('/api/twofaccounts')
|
||||
|
||||
if( this.form.errors.any() === false ) {
|
||||
this.$router.push({name: 'accounts', params: { InitialEditMode: false }});
|
||||
})
|
||||
.catch(error => {
|
||||
if( error.response.status !== 422 ) {
|
||||
this.$router.push({ name: 'genericError', params: { err: error.response } });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
@ -132,26 +128,18 @@
|
||||
this.$router.push({name: 'accounts', params: { InitialEditMode: false }});
|
||||
},
|
||||
|
||||
uploadQrcode(event) {
|
||||
async uploadQrcode(event) {
|
||||
|
||||
let imgdata = new FormData();
|
||||
imgdata.append('qrcode', this.$refs.qrcodeInput.files[0]);
|
||||
|
||||
this.form.upload('/api/qrcode/decode', imgdata)
|
||||
.then(response => {
|
||||
this.form.service = response.data.service;
|
||||
this.form.account = response.data.account;
|
||||
this.form.uri = response.data.uri;
|
||||
})
|
||||
.catch(error => {
|
||||
if( error.response.status !== 422 ) {
|
||||
this.$router.push({ name: 'genericError', params: { err: error.response } });
|
||||
}
|
||||
});
|
||||
const { data } = await this.form.upload('/api/qrcode/decode', imgdata)
|
||||
|
||||
this.form.fill(data)
|
||||
|
||||
},
|
||||
|
||||
uploadIcon(event) {
|
||||
async uploadIcon(event) {
|
||||
|
||||
// clean possible already uploaded temp icon
|
||||
this.deleteIcon()
|
||||
@ -159,15 +147,9 @@
|
||||
let imgdata = new FormData();
|
||||
imgdata.append('icon', this.$refs.iconInput.files[0]);
|
||||
|
||||
this.form.upload('/api/icon/upload', imgdata)
|
||||
.then(response => {
|
||||
this.tempIcon = response.data;
|
||||
})
|
||||
.catch(error => {
|
||||
if( error.response.status !== 422 ) {
|
||||
this.$router.push({ name: 'genericError', params: { err: error.response } });
|
||||
}
|
||||
});
|
||||
const { data } = await this.form.upload('/api/icon/upload', imgdata)
|
||||
|
||||
this.tempIcon = data;
|
||||
|
||||
},
|
||||
|
||||
|
@ -128,15 +128,11 @@
|
||||
this.deleteIcon()
|
||||
}
|
||||
|
||||
this.form.put('/api/twofaccounts/' + this.$route.params.twofaccountId)
|
||||
.then(response => {
|
||||
this.$router.push({name: 'accounts', params: { InitialEditMode: true }});
|
||||
})
|
||||
.catch(error => {
|
||||
if( error.response.status !== 422 ) {
|
||||
this.$router.push({ name: 'genericError', params: { err: error.response } });
|
||||
}
|
||||
});
|
||||
await this.form.put('/api/twofaccounts/' + this.$route.params.twofaccountId)
|
||||
|
||||
if( this.form.errors.any() === false ) {
|
||||
this.$router.push({name: 'accounts', params: { InitialEditMode: true }})
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
@ -147,7 +143,7 @@
|
||||
this.$router.push({name: 'accounts', params: { InitialEditMode: true }});
|
||||
},
|
||||
|
||||
uploadIcon(event) {
|
||||
async uploadIcon(event) {
|
||||
|
||||
// clean possible tempIcon but keep original one
|
||||
this.deleteIcon()
|
||||
@ -155,15 +151,9 @@
|
||||
let imgdata = new FormData();
|
||||
imgdata.append('icon', this.$refs.iconInput.files[0]);
|
||||
|
||||
this.form.upload('/api/icon/upload', imgdata)
|
||||
.then(response => {
|
||||
this.tempIcon = response.data;
|
||||
})
|
||||
.catch(error => {
|
||||
if( error.response.status !== 422 ) {
|
||||
this.$router.push({ name: 'genericError', params: { err: error.response } });
|
||||
}
|
||||
});
|
||||
const { data } = await this.form.upload('/api/icon/upload', imgdata)
|
||||
|
||||
this.tempIcon = data;
|
||||
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user