Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I add auth to all actions of a Resource? #237

Open
amrecords opened this issue May 16, 2019 · 1 comment
Open

How do I add auth to all actions of a Resource? #237

amrecords opened this issue May 16, 2019 · 1 comment

Comments

@amrecords
Copy link

I can use
userResource.create.auth(function(req, res, context) { }
to protect the auth action, but when I want to use the same auth check for all actions, I'd like to use something like
userResource.allActions.auth(function(req, res, context) { }

Instead I need to use
userResource.create.auth(function(req, res, context) { }
userResource.list.auth(function(req, res, context) { }
userResource.read.auth(function(req, res, context) { }
userResource.update.auth(function(req, res, context) { }
userResource.delete.auth(function(req, res, context) { }

Is a short version possible without producing lots of duplicate code?

@harsha-bhat
Copy link

Use userResource.all.auth(function (req, res, context) { }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants