2FAuth/resources/js/views/Error.vue

97 lines
2.7 KiB
Vue
Raw Normal View History

<template>
<div class="error-message">
<modal v-model="ShowModal">
<div class="error-message" v-if="$route.name == '404'">
<p class="error-404"></p>
<p>{{ $t('errors.resource_not_found') }}</p>
2020-10-14 23:33:07 +02:00
<p class=""><router-link :to="{ name: 'accounts' }" class="is-text">{{ $t('errors.refresh') }}</router-link></p>
</div>
<div v-else-if="$route.name == 'flooded'">
<p class="error-generic"></p>
<p>
{{ $t('errors.already_one_user_registered') }}<br>
{{ $t('errors.cannot_register_more_user') }}
</p>
2020-10-14 23:33:07 +02:00
<p><router-link :to="{ name: 'accounts' }" class="is-text">{{ $t('auth.sign_in') }}</router-link></p>
</div>
<div v-else>
<p class="error-generic"></p>
<p>{{ $t('errors.error_occured') }} </p>
2020-01-27 20:27:11 +01:00
<p v-if="error" class="has-text-grey-lighter">{{ error.message }}</p>
<p v-if="error.originalMessage" class="has-text-grey-lighter">{{ error.originalMessage }}</p>
2020-10-14 23:33:07 +02:00
<p><router-link :to="{ name: 'accounts' }" class="is-text">{{ $t('errors.refresh') }}</router-link></p>
2020-11-04 22:42:54 +01:00
<p v-if="debugMode == 'development' && error.debug">
2020-01-27 20:27:11 +01:00
<br>
2020-01-23 17:05:24 +01:00
{{ error.debug }}
2020-01-17 00:23:38 +01:00
</p>
</div>
</modal>
</div>
</template>
<script>
import Modal from '../components/Modal'
export default {
data(){
return {
ShowModal : true,
}
},
computed: {
2020-01-23 17:05:24 +01:00
debugMode: function() {
return process.env.NODE_ENV
2020-01-17 00:23:38 +01:00
},
2020-01-23 17:05:24 +01:00
2020-01-17 00:23:38 +01:00
error: function() {
if( this.err == null ) {
return false
2020-01-23 17:05:24 +01:00
}
else
{
if(this.err.data) {
2020-11-04 22:42:54 +01:00
console.log(this.err.data)
2020-01-23 17:05:24 +01:00
return this.err.data
}
else
{
2020-11-04 22:42:54 +01:00
return { 'message' : this.err }
2020-01-23 17:05:24 +01:00
}
}
}
2020-01-23 17:05:24 +01:00
},
props: ['err'], // on object (error.response) or a string
components: {
Modal
},
mounted(){
// stop OTP generation on modal close
this.$on('modalClose', function() {
this.$router.push({name: 'accounts' });
});
},
beforeRouteEnter (to, from, next) {
next(vm => {
if( !vm.err ) {
next({ name: 'accounts' });
}
});
next();
},
}
</script>