auth0/auth0-angular — pull request #110 by gdi2290 (2014-11-10 20:08:36+00:00)
Title: fix(authenticate): return for error catching

If there is an error trying to get the token/profile and the user doesn't exist anymore you get an error. The problem is that you can't hook into that error to redirect them etc

here is an example of what I'm using
```javascript
function checkAuth() {
if (!auth.isAuthenticated) {
var token = store.get(prefix+'token');
// var token = auth.idToken || store.get(prefix+'token');
if (token) {
if (!jwtHelper.isTokenExpired(token)) {
auth.authenticate(auth.profile || store.get(prefix+'profile'), token)['catch'](function() {
Auth.loginModal(true);
});
} else {
var refreshToken = store.get(prefix+'refreshToken');
// Either show Login page or use the refresh token to get a new idToken
if (refreshToken) {
auth.refreshIdToken(refreshToken).then(function(idToken) {
store.set(prefix+'token', idToken);
auth.authenticate(auth.profile || store.get(prefix+'profile'), idToken);
})['catch'](function() {
Auth.loginModal(true);
});
} else {
Auth.loginModal(true);
}
}
} else {
Auth.loginModal(true);
}
}
}
$rootScope.$on('$locationChangeStart', checkAuth);
```