99 lines
2.6 KiB
Vue
99 lines
2.6 KiB
Vue
<template lang="pug">
|
|
#userlist
|
|
h3 Registered Users ({{ pagination.total }})
|
|
pagination(:page="pagination.page" :pages="pagination.pages" v-on:page="getUsers")
|
|
.list.users
|
|
user(v-for='user in users' v-bind="user" :key="user.id")
|
|
ban-modal(:show='banning' @close='banning = 0' :id='banning')
|
|
user-modal(:show='editing' @close='editing = 0' :id='editing')
|
|
</template>
|
|
|
|
<script>
|
|
import Pagination from './Pagination.vue'
|
|
import User from './User.vue'
|
|
import BanModal from './BanModal.vue'
|
|
import UserModal from './UserModal.vue'
|
|
const csrfToken = document.querySelector('meta[name="csrf-token"]').content
|
|
|
|
export default {
|
|
data: function () {
|
|
return {
|
|
pagination: {
|
|
offset: 0,
|
|
page: 1,
|
|
pages: 1,
|
|
perPage: 6,
|
|
total: 0
|
|
},
|
|
users: [],
|
|
banning: 0,
|
|
editing: 0
|
|
}
|
|
},
|
|
components: {
|
|
Pagination, User, BanModal, UserModal
|
|
},
|
|
methods: {
|
|
getUsers: function (page) {
|
|
this.$http.get('/admin/api/users?page=' + page).then(data => {
|
|
if (data.body && data.body.error) return
|
|
this.pagination = data.body.page
|
|
this.users = data.body.users
|
|
})
|
|
}
|
|
},
|
|
mounted: function () {
|
|
this.getUsers(1)
|
|
|
|
this.$on('ban', function (id) {
|
|
this.banning = id
|
|
})
|
|
|
|
this.$on('edit', function (id) {
|
|
this.editing = id
|
|
})
|
|
|
|
this.$on('activation', function (id) {
|
|
this.$http.post('/admin/api/user/resend_activation', {
|
|
user_id: id,
|
|
csrf: csrfToken
|
|
}).then(data => {
|
|
alert('Email sent!')
|
|
}).catch(err => {
|
|
console.error(err)
|
|
alert('Failed to send activation email to this user.')
|
|
})
|
|
})
|
|
|
|
this.$on('totp-revoke', function (id) {
|
|
this.$http.post('/admin/api/user/revoke_totp', {
|
|
user_id: id,
|
|
csrf: csrfToken
|
|
}).then(data => {
|
|
alert('Success!')
|
|
this.getUsers(this.pagination.page)
|
|
}).catch(err => {
|
|
console.error(err)
|
|
alert('An error occured.')
|
|
})
|
|
})
|
|
|
|
this.$on('reset-password', function (id) {
|
|
this.$http.post('/admin/api/user/reset_password', {
|
|
user_id: id,
|
|
csrf: csrfToken
|
|
}).then(data => {
|
|
alert('Email sent!')
|
|
}).catch(err => {
|
|
console.error(err)
|
|
alert('Failed to send activation email to this user.')
|
|
})
|
|
})
|
|
|
|
this.$root.$on('reload_users', () => {
|
|
this.getUsers(this.pagination.page)
|
|
})
|
|
}
|
|
}
|
|
</script>
|