Files
noisedash/src/components/login.js
2022-05-26 17:08:00 -07:00

39 lines
832 B
JavaScript

export default {
name: 'Login',
data: () => ({
valid: false,
username: '',
password: '',
snackbar: false,
snackbarText: '',
usernameRules: [
v => !!v || 'Username is required'
],
passwordRules: [
v => !!v || 'Password is required'
]
}),
methods: {
login () {
this.$http.post('/login/password', {
username: this.username,
password: this.password
})
.then(response => {
if (response.status === 200) {
this.$router.push('/')
}
})
.catch((error) => {
if (error.response.status === 401) {
this.snackbarText = 'Login Failed: Unauthorized'
} else {
this.snackbarText = 'Login Failed'
}
this.snackbar = true
})
}
}
}