2017-11-06 11:14:43 +01:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* UsersPermissions.js controller
|
|
|
|
*
|
|
|
|
* @description: A set of functions called "actions" of the `users-permissions` plugin.
|
|
|
|
*/
|
|
|
|
|
2017-11-15 15:06:09 +01:00
|
|
|
const _ = require('lodash');
|
|
|
|
|
2017-11-06 11:14:43 +01:00
|
|
|
module.exports = {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Default action.
|
|
|
|
*
|
|
|
|
* @return {Object}
|
|
|
|
*/
|
|
|
|
|
|
|
|
index: async (ctx) => {
|
|
|
|
// Add your own logic here.
|
|
|
|
|
|
|
|
// Send 200 `ok`
|
|
|
|
ctx.send({
|
|
|
|
message: 'ok'
|
|
|
|
});
|
2017-11-14 17:09:13 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
init: async (ctx) => {
|
2017-11-15 17:27:07 +01:00
|
|
|
const hasAdmin = await strapi.query('user', 'users-permissions').find({
|
|
|
|
where: {
|
|
|
|
admin: true
|
|
|
|
}
|
2017-11-15 15:06:09 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
ctx.send({ hasAdmin: !_.isEmpty(hasAdmin) });
|
2017-11-06 11:14:43 +01:00
|
|
|
}
|
|
|
|
};
|