Error feedback
This commit is contained in:
parent
8b3c77cc92
commit
76ef520f3e
|
@ -21,8 +21,8 @@ export async function login(username: string, password: string, ip: string) {
|
||||||
await pa.login(username, ip, user.domain)
|
await pa.login(username, ip, user.domain)
|
||||||
|
|
||||||
return user
|
return user
|
||||||
} catch (error) {
|
} catch (error: any) {
|
||||||
console.log(error)
|
console.log(error.message)
|
||||||
throw new Error('Login failed')
|
throw new Error(`Login failed: ${error.message}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
25
src/web/components/LoginErrorAlert.vue
Normal file
25
src/web/components/LoginErrorAlert.vue
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
<template>
|
||||||
|
<v-alert class="mt-5" type="error" v-if="error" prominent variant="tonal">
|
||||||
|
<div>
|
||||||
|
Não foi possível fazer login. Tente novamente. Se o problema persistir,
|
||||||
|
entre em contato com o SERTI do campus.
|
||||||
|
<a href="" @click.prevent="showDetails = !showDetails" variant="plain">
|
||||||
|
Mostrar detalhes
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<code v-if="showDetails">
|
||||||
|
{{ error }}
|
||||||
|
</code>
|
||||||
|
</v-alert>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { ref } from 'vue'
|
||||||
|
|
||||||
|
defineProps({
|
||||||
|
error: String
|
||||||
|
})
|
||||||
|
|
||||||
|
const showDetails = ref(false)
|
||||||
|
</script>
|
|
@ -55,10 +55,7 @@
|
||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
</v-card>
|
</v-card>
|
||||||
<v-scale-transition>
|
<v-scale-transition>
|
||||||
<v-alert class="mt-5" type="error" v-if="error">
|
<login-error-alert :error="error" />
|
||||||
Não foi possível fazer login. Tente novamente. Se o problema persistir,
|
|
||||||
entre em contato com o SERTI do campus.
|
|
||||||
</v-alert>
|
|
||||||
</v-scale-transition>
|
</v-scale-transition>
|
||||||
</v-form>
|
</v-form>
|
||||||
</template>
|
</template>
|
||||||
|
@ -67,6 +64,7 @@
|
||||||
import { ref, computed } from 'vue'
|
import { ref, computed } from 'vue'
|
||||||
import { trpc } from '../trpc'
|
import { trpc } from '../trpc'
|
||||||
import { VForm } from 'vuetify/lib/components/index.mjs'
|
import { VForm } from 'vuetify/lib/components/index.mjs'
|
||||||
|
import LoginErrorAlert from './LoginErrorAlert.vue'
|
||||||
|
|
||||||
const emit = defineEmits(['login'])
|
const emit = defineEmits(['login'])
|
||||||
|
|
||||||
|
@ -78,7 +76,7 @@ const showPassword = ref(false)
|
||||||
|
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
|
|
||||||
const error = ref(false)
|
const error = ref('')
|
||||||
|
|
||||||
const form = ref<VForm>()
|
const form = ref<VForm>()
|
||||||
|
|
||||||
|
@ -89,7 +87,7 @@ const valid = computed(() => {
|
||||||
async function doLogin() {
|
async function doLogin() {
|
||||||
try {
|
try {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
error.value = false
|
error.value = ''
|
||||||
|
|
||||||
const loginResult = await trpc.login.mutate({
|
const loginResult = await trpc.login.mutate({
|
||||||
username: username.value,
|
username: username.value,
|
||||||
|
@ -99,7 +97,7 @@ async function doLogin() {
|
||||||
emit('login', loginResult)
|
emit('login', loginResult)
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
console.log(e.message)
|
console.log(e.message)
|
||||||
error.value = true
|
error.value = e.message
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user