{"id":16387482,"url":"https://github.com/mastilver/sails-hook-parametized-policies","last_synced_at":"2025-10-26T11:31:50.552Z","repository":{"id":33451391,"uuid":"37096785","full_name":"mastilver/sails-hook-parametized-policies","owner":"mastilver","description":null,"archived":false,"fork":false,"pushed_at":"2016-12-23T13:02:33.000Z","size":24,"stargazers_count":3,"open_issues_count":3,"forks_count":4,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-01-31T19:01:50.616Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mastilver.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-08T22:39:28.000Z","updated_at":"2022-10-25T07:13:51.000Z","dependencies_parsed_at":"2022-09-07T15:51:17.898Z","dependency_job_id":null,"html_url":"https://github.com/mastilver/sails-hook-parametized-policies","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mastilver%2Fsails-hook-parametized-policies","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mastilver%2Fsails-hook-parametized-policies/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mastilver%2Fsails-hook-parametized-policies/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mastilver%2Fsails-hook-parametized-policies/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mastilver","download_url":"https://codeload.github.com/mastilver/sails-hook-parametized-policies/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238319530,"owners_count":19452353,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T04:26:39.766Z","updated_at":"2025-10-26T11:31:45.289Z","avatar_url":"https://github.com/mastilver.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sails-hook-parametized-policies [![Build Status](https://travis-ci.org/mastilver/sails-hook-parametized-policies.svg?branch=master)](https://travis-ci.org/mastilver/sails-hook-parametized-policies) [![Coverage Status](https://coveralls.io/repos/mastilver/sails-hook-parametized-policies/badge.svg?branch=master)](https://coveralls.io/r/mastilver/sails-hook-parametized-policies?branch=master)\n\n## Install\n\n`$ npm install --save sails-hook-parametized-policies`\n\n## Setup\n\nadd your factories inside `api/policyFactories` or in the folder you defined on `sails.config.paths.policyFactories`\n\nexample: `is.js`\n\n```\nmodule.exports = function(userType){\n\n    return function(req, res, next){\n\n        var roles = req.user.roles;\n\n        if(roles.indexOf(userType) \u003e 0){\n            return next();\n        }\n\n        res.forbidden('You must be an ' + userType + ' to access this resource');\n    };\n};\n```\n\nor a more complex one: `or.js`\n\n[example of OR policy with a number of arguments](https://gist.github.com/1nstinct/12399f8adc4e5cfd6e88)\n\n## Usage\n\nin your `config/policies.js`\n\n```\n{\n    ProfileController: {\n        edit: 'isLoggedIn'\n        create: ['or(is(\\'Admin\\'), is(\\'SubAdmin\\'))', 'isLoggedIn'],\n        delete: ['is(\\'Admin\\')', 'isLoggedIn'],\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmastilver%2Fsails-hook-parametized-policies","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmastilver%2Fsails-hook-parametized-policies","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmastilver%2Fsails-hook-parametized-policies/lists"}