Skip to content
This repository was archived by the owner on Aug 6, 2021. It is now read-only.

Commit d056a4d

Browse files
committed
Remove obsolete accessControl function
1 parent e8ee888 commit d056a4d

File tree

1 file changed

+0
-38
lines changed

1 file changed

+0
-38
lines changed

templates/advanced/api/blueprints/_util/actionUtil.js

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -38,42 +38,6 @@ module.exports = {
3838
return associations;
3939
},
4040

41-
/**
42-
* AccessControl proxy function, expects a Waterline query object for before* hooks and an array of records for after* hooks.
43-
* @param {Collection} model Waterline collectio, from parseModel
44-
* @param {String} action blueprint or hook, e.g. beforeFind, afterFind, beforeCreate, afterCreate --> translates to accessControlBeforeFind, etc.
45-
* @param {Object} options Options: query {Query} Waterline query object for before* hooks, records: {Array} records for after* hooks, {Model} current user record
46-
* @return {Query|Array} returns the modified query (with altered criteria) for before* or the filtered/extended record array for after*.
47-
*/
48-
accessControl: function ( model, action, options, callback ) {
49-
var primaryArgument = null;
50-
var capitaliseFirstLetter = function ( string ) {
51-
return string.charAt( 0 ).toUpperCase() + string.slice( 1 );
52-
};
53-
54-
if ( action.indexOf( "before" ) === 0 ) {
55-
if ( !options.criteria ) throw new Error( "accessControl before* hook needs option: criteria!" );
56-
primaryArgument = options.criteria;
57-
} else if ( action.indexOf( "after" ) === 0 ) { // turns out that access control after querying the database is a bad idea, because counting and pagination patterns are broken
58-
if ( !options.records ) throw new Error( "accessControl after* hook needs option: records!" );
59-
primaryArgument = options.records;
60-
} else {
61-
throw new Error( "accessControl action '" + action + "' doesn't fit into before/after pattern." );
62-
}
63-
64-
action = capitaliseFirstLetter( action );
65-
66-
if ( typeof model[ "control" + action ] === "function" ) {
67-
primaryArgument = model[ "control" + action ]( primaryArgument, options, callback );
68-
} else {
69-
console.log( "Dev: Model " + model.identity + " is missing control " + action + "!" );
70-
if ( callback ) {
71-
callback( null, primaryArgument );
72-
}
73-
}
74-
return primaryArgument;
75-
},
76-
7741
/**
7842
* helper function to populate a record with an array for indexes for associated models, running various Waterline queries on the join tables if neccessary ( defined as: include -> index )
7943
* @param {Waterine Collection} parentModel [description]
@@ -144,8 +108,6 @@ module.exports = {
144108
var aliasFilter = req.param( 'populate' );
145109
var shouldPopulate = _options.populate;
146110

147-
console.log( "Populate: ", aliasFilter, shouldPopulate );
148-
149111
// Convert the string representation of the filter list to an Array. We
150112
// need this to provide flexibility in the request param. This way both
151113
// list string representations are supported:

0 commit comments

Comments
 (0)