aranzaiger
8931f4bd86
- example test and simple delete usr test added - extract delete user logics from controller
51 lines
No EOL
1.3 KiB
JavaScript
51 lines
No EOL
1.3 KiB
JavaScript
'use strict'
|
|
const User = use('App/Models/User');
|
|
const Child = use('App/Models/Child');
|
|
const Link = use('App/Models/Link');
|
|
const IceServer = use('App/Models/IceServer');
|
|
|
|
const EmailUtils = use('App/Utils/EmailUtils');
|
|
const UserUtils = use('App/Utils/UserUtils');
|
|
class AdminApiController {
|
|
async getUsers({ response }) {
|
|
const users = await User.all();
|
|
// console.log(typeof users);
|
|
// return users.rows.map(u => {
|
|
// return u.publicJSON();
|
|
// });
|
|
return users;
|
|
}
|
|
|
|
async deleteUser({ request, response }) {
|
|
const { id } = request.params
|
|
|
|
return UserUtils.deleteUser(id)
|
|
}
|
|
|
|
async addStunServer({ request, response }) {}
|
|
async addTurnServer({ request, response }) {}
|
|
|
|
async testEmailSettings({ auth, response }) {
|
|
try {
|
|
if (EmailUtils.sendTestEmail(auth.user)) {
|
|
return {
|
|
code: 0,
|
|
data: {}
|
|
}
|
|
}
|
|
return {
|
|
code: 500,
|
|
message: 'Something went wrong'
|
|
}
|
|
|
|
} catch (e) {
|
|
response.code(500);
|
|
return {
|
|
code: 500,
|
|
message: e.message
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = AdminApiController |