{"metadata":{"image":[],"title":"","description":""},"api":{"url":"","auth":"required","settings":"","params":[],"results":{"codes":[]}},"next":{"description":"","pages":[]},"title":"Authenticated routes (front-end)","type":"basic","slug":"authenticated-routes-front-end","excerpt":"","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`.","updates":["574b3f30e0ae8a170055adb3"],"order":6,"isReference":false,"hidden":false,"sync_unique":"","link_url":"","link_external":false,"_id":"57ffd85f755a2e1700c2bb14","__v":0,"githubsync":"","createdAt":"2016-04-20T23:35:33.721Z","parentDoc":null,"category":{"sync":{"isSync":false,"url":""},"pages":[],"title":"JWT Auth","slug":"jwt-auth","order":5,"from_sync":false,"reference":false,"_id":"57ffd85f755a2e1700c2bb0b","__v":0,"version":"57ffd85f755a2e1700c2bb05","project":"567083021dabd80d00b122ae","createdAt":"2015-12-18T23:14:19.433Z"},"project":"567083021dabd80d00b122ae","user":"567082433a32d20d00c45cab","version":{"version":"3.4","version_clean":"3.4.0","codename":"","is_stable":true,"is_beta":false,"is_hidden":false,"is_deprecated":false,"categories":["57ffd85f755a2e1700c2bb06","57ffd85f755a2e1700c2bb07","57ffd85f755a2e1700c2bb08","57ffd85f755a2e1700c2bb09","57ffd85f755a2e1700c2bb0a","57ffd85f755a2e1700c2bb0b","57ffd85f755a2e1700c2bb0c","57ffd85f755a2e1700c2bb0d"],"_id":"57ffd85f755a2e1700c2bb05","project":"567083021dabd80d00b122ae","releaseDate":"2016-10-13T18:54:23.018Z","__v":1,"createdAt":"2016-10-13T18:54:23.018Z"}}

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`.