-
Notifications
You must be signed in to change notification settings - Fork 2
Page Restriction
Let's say you have a route that you want to restrict to logged-in users; maybe you have a /profile
page that lets your users fill in some information about themselves, but it wouldn't work if they weren't logged in. Open /client/app/profile/profile.js, and add authenticate: true
to the options passed to $routeProvider.when like so:
$routeProvider
.when('/profile', {
templateUrl: 'app/profile/profile.html',
controller: 'ProfileCtrl',
authenticate: true // restrict to authenticated users
});
This way, if the user isn't authenticated when they try to access the /profile
page, they'll be redirected to your login screen to authenticate before continuing to their profile page.
Learn to code and help nonprofits. Join our open source community in 15 seconds at http://freecodecamp.com
Follow our Medium blog
Follow Quincy on Quora
Follow us on Twitter
Like us on Facebook
And be sure to click the "Star" button in the upper right of this page.
New to Free Code Camp?
JS Concepts
JS Language Reference
- arguments
- Array.prototype.filter
- Array.prototype.indexOf
- Array.prototype.map
- Array.prototype.pop
- Array.prototype.push
- Array.prototype.shift
- Array.prototype.slice
- Array.prototype.some
- Array.prototype.toString
- Boolean
- for loop
- for..in loop
- for..of loop
- String.prototype.split
- String.prototype.toLowerCase
- String.prototype.toUpperCase
- undefined
Other Links