Reputation: 90
I'm creating an API for clients with different roles and locations, they will all request the same url but depending on the role and location the Server will serve different values. So, I am wondering if Sails Policies have a feature where depending on the context I can redirect them to the correct Controller function without sending back a res.redirect('/checkoutLocationXUserY');
Upvotes: 0
Views: 97
Reputation: 212
Instead of using policies, you could implement separate helper functions and within the action you call the correct helper function depending on the client and role.
This way, the same controller action serves the same request but gives different responses depending on the client/role.
That said, within a policy, you have access to the response object so you can do something like
res.redirect('some/route')
This seems a little hacky though - also, be sure the redirected route does not have policies etc...
Upvotes: 1