From 9b60f638401abf0b2f715eaba40bde781a0622cb Mon Sep 17 00:00:00 2001 From: Jeremy Shimko Date: Sat, 8 Aug 2015 14:32:35 -0400 Subject: [PATCH] add content protection instructions to README --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README.md b/README.md index b5c2e5c..98aad43 100644 --- a/README.md +++ b/README.md @@ -89,5 +89,26 @@ AccountsTemplates.configureRoute('signIn', { All options are passed to FlowRouter.route() which then creates a new custom route (see the official Flow Router documentation [here](https://atmospherejs.com/kadira/flow-router) for more details). All the above fields are optional and fall back to default values in case you don't provide them. +## Content Protection + +If you want to protect a route by making sure a user is signed in, you can add the `AccountsTemplates.ensureSignedIn` check in your route's enter triggers like this: + +```js +FlowRouter.route('/private', { + triggersEnter: [AccountsTemplates.ensureSignedIn], + action: function() { + BlazeLayout.render(...) + } +}); +``` + +If the user isn't signed in, they will be redirected to your sign in route and then redirected back to the original route after they have successfully signed in. + +Or if you want to protect ALL routes in your app: + +```js +FlowRouter.triggers.enter([AccountsTemplates.ensureSignedIn]); +``` + [1]: https://atmospherejs.com/kadira/flow-router [2]: https://atmospherejs.com/kadira/blaze-layout \ No newline at end of file