Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const parseConfig = (hook) => {
appId: ENV.APP_ID,
appName: ENV.APP_NAME,
masterKey: ENV.MASTER_KEY,
masterKeyIps: ENV.MASTER_KEY_IPS,
enforcePrivateUsers: false,
sessionLength: 31536000000,
databaseURI: ENV.DATABASE_URI,
Expand All @@ -20,7 +21,6 @@ const parseConfig = (hook) => {
preserveFileName: ENV.PARSE_PRESERVE_FILENAME,
publicServerURL: ENV.PUBLIC_SERVER_URI + ENV.PARSE_MOUNT,
allowClientClassCreation: ENV.PARSE_ALLOW_CLIENT_CLASS_CREATION,
masterKeyIps: ENV.MASTER_KEY_IPS,
maxUploadSize: ENV.MAX_UPLOAD_SIZE,
};

Expand Down Expand Up @@ -82,6 +82,7 @@ Actinium.Middleware.register('parse', async (app) => {
appId,
appName,
masterKey,
masterKeyIps,
sessionLength,
serverURL,
publicServerURL,
Expand All @@ -95,22 +96,22 @@ Actinium.Middleware.register('parse', async (app) => {
appId,
appName,
masterKey,
masterKeyIps,
sessionLength,
serverURL,
publicServerURL,
},
],
};

Hook.runSync('parse-dashboard-config', dashboardConfig);

const dashboardOptions = {
allowInsecureHTTP: ENV.PARSE_DASHBOARD_ALLOW_INSECURE_HTTP,
cookieSessionSecret:
'RhbhlE9ze74MALtA2UtqqZzglN2oWgQ0a7jGSZt4sY6eIXeN0yHG7my0dYpA93cl',
};

Hook.runSync('parse-dashboard-config', dashboardOptions);
Hook.runSync('parse-dashboard-config', dashboardConfig);
Hook.runSync('parse-dashboard-config-options', dashboardOptions);

const dashboard = new ParseDashboard(dashboardConfig, dashboardOptions);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"version": "5.0.0"
},
"name": "@atomic-reactor/actinium-core",
"version": "5.1.17",
"version": "5.1.18",
"description": "Actinium Core",
"main": "actinium.js",
"type": "module",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"type": "module",
"name": "@atomic-reactor/actinium-users",
"version": "5.0.2",
"version": "5.0.4",
"description": "Actinium core plugin",
"main": "index.js",
"scripts": {
Expand Down
26 changes: 26 additions & 0 deletions actinium_modules/@atomic-reactor/actinium-users/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ const MOD = () => {
return objects;
}

/*
* ---------------------------------------------------------------------------------------------------
// TODO: Figure out a better way to implement this w/o iterating over the objects on every find
* ---------------------------------------------------------------------------------------------------
for (let i = 0; i < objects.length; i++) {
let user = objects[i];

Expand All @@ -52,6 +56,9 @@ const MOD = () => {
user.set('capabilities', capabilities);
objects[i] = user;
}
*/

await Actinium.Hook.run('user-fetch', objects);

return Promise.resolve(objects);
};
Expand All @@ -77,6 +84,23 @@ const MOD = () => {
return Actinium.User.retrieve(req.params, options);
};

const roles = async (req) => {
if (!req.user) return [];

const options = { useMaskterKey: true, json: false };
const qry = new Actinium.Query(Actinium.Role);
qry.equalTo('users', req.user);
qry.descending('level');

const results = await qry.find(options);

return results.reduce((roles, item) => {
roles['anonymous'] = 0;
roles[item.get('name')] = item.get('level');
return roles;
}, {});
};

const save = (req) => {
const options = CloudRunOptions(req);
return Actinium.User.save(req.params, options);
Expand Down Expand Up @@ -244,6 +268,8 @@ const MOD = () => {

Actinium.Cloud.define(PLUGIN.ID, 'user-retrieve', retrieve);

Actinium.Cloud.define(PLUGIN.ID, 'user-roles', roles);

Actinium.Cloud.define(PLUGIN.ID, 'user-save', save);

Actinium.Cloud.define(PLUGIN.ID, 'user-trash', trash);
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/app/documentation/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Hooks are synchronous and will execute in the order they are registered unless t
* @apiParam (Hooks) user-before-find Triggered when the `user-find` cloud function is called.
* @apiParam (Hooks) user-before-login Triggered before a sign in attempt.
* @apiParam (Hooks) user-before-save Triggered after a Parse.User object is saved.
* @apiParam (Hooks) user-fetch Triggered when a user is fetched from the server. The fetched `Parse.User` object is passed to the hook.
* @apiParam (Hooks) user-fetch Triggered when a users are fetched from the server. The fetched `Parse.User` objects are passed to the hook as an Array.
* @apiParam (Hooks) warning Triggered when the startup warnings are logged.
*/

Expand Down