CoreID/app/controllers/dash/Users.controller.js

48 lines
1.2 KiB
JavaScript
Raw Normal View History

2020-05-04 01:16:54 +00:00
const { Controller } = require('libflitter')
class UsersController extends Controller {
static get services() {
return [...super.services, 'models', 'cobalt']
}
async get_listing(req, res, next) {
// Columns: Username, First, Last, E-Mail
const User = this.models.get('auth:User')
const users = await User.find()
const formatted = users.map(x => {
return {
username: x.uid,
first: x.first_name,
last: x.last_name,
email: x.email,
}
})
return this.cobalt.listing(req, res, {
title: 'Users',
columns: [
{
name: 'Username',
field: 'username',
},
{
name: 'First Name',
field: 'first',
},
{
name: 'Last Name',
field: 'last',
},
{
name: 'E-Mail Address',
field: 'email',
},
],
data: formatted,
})
}
}
module.exports = exports = UsersController