This repository has been archived on 2024-12-15. You can view files and clone it, but cannot push or open issues or pull requests.
seepur/app/Controllers/Http/AdminApiController.js

55 lines
1.5 KiB
JavaScript
Raw Normal View History

2020-03-17 22:16:34 +00:00
'use strict'
const User = use('App/Models/User');
2020-04-12 14:25:42 +00:00
const Child = use('App/Models/Child');
const Link = use('App/Models/Link');
const IceServer = use('App/Models/IceServer');
const EmailUtils = use('App/Utils/EmailUtils');
2020-03-17 22:16:34 +00:00
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 }) {
console.log('in delete user')
const { id } = request.params
const user = await User.find(id)
let userLinks = await user.links().fetch();
const links = userLinks.rows
const promises = [...links.map(l => (l.delete())), user.delete()];
return await Promise.all(promises);
}
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
}
}
}
2020-03-17 22:16:34 +00:00
}
module.exports = AdminApiController