{"_id":"57ffd85f755a2e1700c2bb14","__v":0,"parentDoc":null,"category":{"_id":"57ffd85f755a2e1700c2bb0b","__v":0,"version":"57ffd85f755a2e1700c2bb05","project":"567083021dabd80d00b122ae","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-12-18T23:14:19.433Z","from_sync":false,"order":5,"slug":"jwt-auth","title":"JWT Auth"},"project":"567083021dabd80d00b122ae","user":"567082433a32d20d00c45cab","version":{"_id":"57ffd85f755a2e1700c2bb05","project":"567083021dabd80d00b122ae","__v":1,"createdAt":"2016-10-13T18:54:23.018Z","releaseDate":"2016-10-13T18:54:23.018Z","categories":["57ffd85f755a2e1700c2bb06","57ffd85f755a2e1700c2bb07","57ffd85f755a2e1700c2bb08","57ffd85f755a2e1700c2bb09","57ffd85f755a2e1700c2bb0a","57ffd85f755a2e1700c2bb0b","57ffd85f755a2e1700c2bb0c","57ffd85f755a2e1700c2bb0d"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"3.4.0","version":"3.4"},"updates":["574b3f30e0ae8a170055adb3"],"next":{"pages":[],"description":""},"createdAt":"2016-04-20T23:35:33.721Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"settings":"","results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":6,"body":"If you open the `angular/config/routes.config.js` file, you notice that we're passing an empty `data: {}` parameter which every state inherits because it's set on the abstract route `app`.\n\nAlthough this is an optional argument, we've implemented a custom logic in `angular/run/routes.run.js` that reads this value from inside this `data` object and sets authentication accordingly.\n\nif you set\n```\ndata: {\n     auth: true\n}\n```\nthen those routes become protected. They would require authentication.\n\nThis behaviour can be enabled on a per route basis. Or per a group of routes, by creating abstract routes.\n\nYou can also extend this behaviour by setting a string value to auth, such as: `auth: 'admin'`. And then you would implement your own logic in `routes.run.js`.","excerpt":"","slug":"authenticated-routes-front-end","type":"basic","title":"Authenticated routes (front-end)"}

Authenticated routes (front-end)


If you open the `angular/config/routes.config.js` file, you notice that we're passing an empty `data: {}` parameter which every state inherits because it's set on the abstract route `app`. Although this is an optional argument, we've implemented a custom logic in `angular/run/routes.run.js` that reads this value from inside this `data` object and sets authentication accordingly. if you set ``` data: { auth: true } ``` then those routes become protected. They would require authentication. This behaviour can be enabled on a per route basis. Or per a group of routes, by creating abstract routes. You can also extend this behaviour by setting a string value to auth, such as: `auth: 'admin'`. And then you would implement your own logic in `routes.run.js`.