Register users from admin page

This commit is contained in:
Kevin Thomas
2021-11-05 23:04:34 -07:00
parent f2d1b80673
commit 69a467b13b
11 changed files with 245 additions and 69 deletions

View File

@@ -5,7 +5,17 @@ export default {
currentUser: {},
users: [],
snackbar: false,
updateText: ''
updateText: '',
addUserDialog: false,
isUserValid: false,
name: '',
username: '',
password: '',
isAdmin: false,
canUpload: false,
rules: {
required: v => !!v || 'Required'
}
}),
created () {
this.getCurrentUser()
@@ -72,6 +82,27 @@ export default {
.catch((error) => {
console.error(error.response)
})
},
addUser () {
this.$http.post('/users', {
name: this.name,
username: this.username,
password: this.password,
isAdmin: this.isAdmin,
darkMode: 0,
canUpload: this.canUpload
})
.then(response => {
if (response.status === 200) {
this.addUserDialog = false
this.updateText = 'User Registered'
this.snackbar = true
this.getUsers()
}
})
.catch((error) => {
console.error(error.response)
})
}
}
}