Register fixed
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Pünkösd Marcell 2020-12-06 02:18:48 +01:00
parent 5a727a6872
commit b18c3180d5
2 changed files with 14 additions and 10 deletions

View File

@ -1,7 +1,7 @@
<template> <template>
<div> <div>
<form novalidate @submit.prevent="performLogin" @input="loginCredsChanged"> <form novalidate @submit.prevent="performLogin" @input="invalidLogin = false">
<md-card-content> <md-card-content>
<md-content class="text-alert" v-if="invalidLogin">Wrong username or password</md-content> <md-content class="text-alert" v-if="invalidLogin">Wrong username or password</md-content>
<md-field> <md-field>
@ -18,7 +18,7 @@
<md-card-actions> <md-card-actions>
<md-progress-spinner :md-diameter="30" :md-stroke="3" md-mode="indeterminate" v-if="authInProgress" <md-progress-spinner :md-diameter="30" :md-stroke="3" md-mode="indeterminate" v-if="authInProgress"
class="md-accent"></md-progress-spinner> class="md-accent"/>
<md-button type="submit" class="md-primary" :disabled="authInProgress">Login</md-button> <md-button type="submit" class="md-primary" :disabled="authInProgress">Login</md-button>
</md-card-actions> </md-card-actions>
</form> </form>
@ -46,9 +46,6 @@ export default {
}).catch(() => { }).catch(() => {
this.invalidLogin = true; this.invalidLogin = true;
}) })
},
loginCredsChanged() {
this.invalidLogin = false;
} }
}, },
computed: { computed: {

View File

@ -1,8 +1,8 @@
<template> <template>
<div> <div>
<form novalidate @submit.prevent="performRegister"> <form novalidate @submit.prevent="performRegister" @input="duplicate = false">
<md-card-content> <md-card-content>
<md-content class="text-alert" v-if="duplicate">Username already taken</md-content>
<md-field> <md-field>
<label>Username</label> <label>Username</label>
<md-input v-model="form.name" :disabled="authInProgress"></md-input> <md-input v-model="form.name" :disabled="authInProgress"></md-input>
@ -22,7 +22,7 @@
<md-card-actions> <md-card-actions>
<md-progress-spinner :md-diameter="30" :md-stroke="3" md-mode="indeterminate" v-if="authInProgress" <md-progress-spinner :md-diameter="30" :md-stroke="3" md-mode="indeterminate" v-if="authInProgress"
class="md-accent"></md-progress-spinner> class="md-accent"/>
<md-button type="submit" class="md-primary" :disabled="authInProgress || !passwordGood">Register <md-button type="submit" class="md-primary" :disabled="authInProgress || !passwordGood">Register
</md-button> </md-button>
</md-card-actions> </md-card-actions>
@ -41,7 +41,8 @@ export default {
name: "", name: "",
password: "", password: "",
passwordConfirm: "" passwordConfirm: ""
} },
duplicate: false
} }
}, },
methods: { methods: {
@ -49,6 +50,9 @@ export default {
const creds = {name: this.form.name, password: this.form.password}; const creds = {name: this.form.name, password: this.form.password};
this.$store.dispatch("auth/performRegister", creds).then(() => { this.$store.dispatch("auth/performRegister", creds).then(() => {
this.$router.push({name: 'Dashboard'}); this.$router.push({name: 'Dashboard'});
}).catch(() => {
// Interpret any error returned by the server as conflict
this.duplicate = true;
}) })
} }
}, },
@ -62,5 +66,8 @@ export default {
</script> </script>
<style scoped> <style scoped>
.text-alert {
color: red !important;
font-weight: bold;
}
</style> </style>