added hinge animation when login fails

This commit is contained in:
Paul Wilde 2023-03-17 15:29:39 +00:00
parent a5b3970d7f
commit b80bba3d3d

View file

@ -14,10 +14,10 @@
@keyup.enter="submitLogin" @keyup.enter="submitLogin"
v-model="user.password" clearable v-model="user.password" clearable
type="password"></v-text-field> type="password"></v-text-field>
<v-banner v-if="error" color="error" icon="mdi-exclamation-thick" theme="dark">
<v-banner-text>{{ error }}</v-banner-text>
</v-banner>
<v-btn color="blue" :loading="logging_in" @click="submitLogin">Login</v-btn> <v-btn color="blue" :loading="logging_in" @click="submitLogin">Login</v-btn>
<v-banner v-if="show_error" color="error" icon="mdi-exclamation-thick" theme="dark">
<v-banner-text>{{ error_message }}</v-banner-text>
</v-banner>
</v-responsive> </v-responsive>
</v-form> </v-form>
</v-card> </v-card>
@ -34,13 +34,16 @@ export default {
email: "", email: "",
password: "" password: ""
}, },
error: "", show_error: false,
error_message: "",
error_count: 0, error_count: 0,
logging_in: false logging_in: false
} }
}, },
methods: { methods: {
submitLogin() { submitLogin() {
this.error_message = ""
this.show_error = false
let url = this.$api_url + "/users/login" let url = this.$api_url + "/users/login"
this.logging_in = true this.logging_in = true
console.log("Logging in...") console.log("Logging in...")
@ -62,17 +65,20 @@ export default {
window.location.href = '/' window.location.href = '/'
} }
} else { } else {
this.error = "Login failed. Invalid username or password." this.error_message = "Login failed. Invalid username or password."
this.error_count += 1 this.error_count += 1
} }
}) })
.catch(error => { .catch(error => {
console.log(error) console.log(error)
this.error = "Login failed. Invalid username or password." this.error_message = "Login failed. Invalid username or password."
this.error_count += 1 this.error_count += 1
}) })
.finally(() => { .finally(() => {
console.log(this.error_count) setTimeout(() => {
if (this.error_message != ""){
this.show_error = true
}
this.logging_in = false this.logging_in = false
if (this.error_count > 2) { if (this.error_count > 2) {
let box = document.getElementById("login-box") let box = document.getElementById("login-box")
@ -84,6 +90,7 @@ export default {
},5000) },5000)
this.error_count = 0 this.error_count = 0
} }
},2000)
}) })
} }
} }